* natCollator.cc: New file.
[official-gcc.git] / gcc / emit-rtl.c
blob88edee3bb0b527e22fc567acda8c1d40aef16701
1 /* Emit RTL for the GNU C-Compiler expander.
2 Copyright (C) 1987, 88, 92-97, 1998, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* Middle-to-low level generation of rtx code and insns.
24 This file contains the functions `gen_rtx', `gen_reg_rtx'
25 and `gen_label_rtx' that are the usual ways of creating rtl
26 expressions for most purposes.
28 It also has the functions for creating insns and linking
29 them in the doubly-linked chain.
31 The patterns of the insns are created by machine-dependent
32 routines in insn-emit.c, which is generated automatically from
33 the machine description. These routines use `gen_rtx' to make
34 the individual rtx's of the pattern; what is machine dependent
35 is the kind of rtx's they make and what arguments they use. */
37 #include "config.h"
38 #include "system.h"
39 #include "toplev.h"
40 #include "rtl.h"
41 #include "tree.h"
42 #include "flags.h"
43 #include "except.h"
44 #include "function.h"
45 #include "expr.h"
46 #include "regs.h"
47 #include "hard-reg-set.h"
48 #include "insn-config.h"
49 #include "recog.h"
50 #include "real.h"
51 #include "obstack.h"
52 #include "bitmap.h"
54 /* Commonly used modes. */
56 enum machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */
57 enum machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */
58 enum machine_mode double_mode; /* Mode whose width is DOUBLE_TYPE_SIZE. */
59 enum machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */
61 /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function.
62 After rtl generation, it is 1 plus the largest register number used. */
64 int reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
66 /* This is *not* reset after each function. It gives each CODE_LABEL
67 in the entire compilation a unique label number. */
69 static int label_num = 1;
71 /* Lowest label number in current function. */
73 static int first_label_num;
75 /* Highest label number in current function.
76 Zero means use the value of label_num instead.
77 This is nonzero only when belatedly compiling an inline function. */
79 static int last_label_num;
81 /* Value label_num had when set_new_first_and_last_label_number was called.
82 If label_num has not changed since then, last_label_num is valid. */
84 static int base_label_num;
86 /* Nonzero means do not generate NOTEs for source line numbers. */
88 static int no_line_numbers;
90 /* Commonly used rtx's, so that we only need space for one copy.
91 These are initialized once for the entire compilation.
92 All of these except perhaps the floating-point CONST_DOUBLEs
93 are unique; no other rtx-object will be equal to any of these. */
95 /* Avoid warnings by initializing the `fld' field. Since its a union,
96 bypass problems with KNR compilers by only doing so when __GNUC__. */
97 #ifdef __GNUC__
98 #define FLDI , {{0}}
99 #else
100 #define FLDI
101 #endif
103 struct _global_rtl global_rtl =
105 {PC, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* pc_rtx */
106 {CC0, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* cc0_rtx */
107 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* stack_pointer_rtx */
108 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* frame_pointer_rtx */
109 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* hard_frame_pointer_rtx */
110 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* arg_pointer_rtx */
111 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_incoming_args_rtx */
112 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_stack_vars_rtx */
113 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_stack_dynamic_rtx */
114 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_outgoing_args_rtx */
115 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_cfa_rtx */
118 /* We record floating-point CONST_DOUBLEs in each floating-point mode for
119 the values of 0, 1, and 2. For the integer entries and VOIDmode, we
120 record a copy of const[012]_rtx. */
122 rtx const_tiny_rtx[3][(int) MAX_MACHINE_MODE];
124 rtx const_true_rtx;
126 REAL_VALUE_TYPE dconst0;
127 REAL_VALUE_TYPE dconst1;
128 REAL_VALUE_TYPE dconst2;
129 REAL_VALUE_TYPE dconstm1;
131 /* All references to the following fixed hard registers go through
132 these unique rtl objects. On machines where the frame-pointer and
133 arg-pointer are the same register, they use the same unique object.
135 After register allocation, other rtl objects which used to be pseudo-regs
136 may be clobbered to refer to the frame-pointer register.
137 But references that were originally to the frame-pointer can be
138 distinguished from the others because they contain frame_pointer_rtx.
140 When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little
141 tricky: until register elimination has taken place hard_frame_pointer_rtx
142 should be used if it is being set, and frame_pointer_rtx otherwise. After
143 register elimination hard_frame_pointer_rtx should always be used.
144 On machines where the two registers are same (most) then these are the
145 same.
147 In an inline procedure, the stack and frame pointer rtxs may not be
148 used for anything else. */
149 rtx struct_value_rtx; /* (REG:Pmode STRUCT_VALUE_REGNUM) */
150 rtx struct_value_incoming_rtx; /* (REG:Pmode STRUCT_VALUE_INCOMING_REGNUM) */
151 rtx static_chain_rtx; /* (REG:Pmode STATIC_CHAIN_REGNUM) */
152 rtx static_chain_incoming_rtx; /* (REG:Pmode STATIC_CHAIN_INCOMING_REGNUM) */
153 rtx pic_offset_table_rtx; /* (REG:Pmode PIC_OFFSET_TABLE_REGNUM) */
155 /* This is used to implement __builtin_return_address for some machines.
156 See for instance the MIPS port. */
157 rtx return_address_pointer_rtx; /* (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM) */
159 /* We make one copy of (const_int C) where C is in
160 [- MAX_SAVED_CONST_INT, MAX_SAVED_CONST_INT]
161 to save space during the compilation and simplify comparisons of
162 integers. */
164 struct rtx_def const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
166 /* The ends of the doubly-linked chain of rtl for the current function.
167 Both are reset to null at the start of rtl generation for the function.
169 start_sequence saves both of these on `sequence_stack' along with
170 `sequence_rtl_expr' and then starts a new, nested sequence of insns. */
172 static rtx first_insn = NULL;
173 static rtx last_insn = NULL;
175 /* RTL_EXPR within which the current sequence will be placed. Use to
176 prevent reuse of any temporaries within the sequence until after the
177 RTL_EXPR is emitted. */
179 tree sequence_rtl_expr = NULL;
181 /* INSN_UID for next insn emitted.
182 Reset to 1 for each function compiled. */
184 static int cur_insn_uid = 1;
186 /* Line number and source file of the last line-number NOTE emitted.
187 This is used to avoid generating duplicates. */
189 static int last_linenum = 0;
190 static char *last_filename = 0;
192 /* A vector indexed by pseudo reg number. The allocated length
193 of this vector is regno_pointer_flag_length. Since this
194 vector is needed during the expansion phase when the total
195 number of registers in the function is not yet known,
196 it is copied and made bigger when necessary. */
198 char *regno_pointer_flag;
199 int regno_pointer_flag_length;
201 /* Indexed by pseudo register number, if nonzero gives the known alignment
202 for that pseudo (if regno_pointer_flag is set).
203 Allocated in parallel with regno_pointer_flag. */
204 char *regno_pointer_align;
206 /* Indexed by pseudo register number, gives the rtx for that pseudo.
207 Allocated in parallel with regno_pointer_flag. */
209 rtx *regno_reg_rtx;
211 /* Stack of pending (incomplete) sequences saved by `start_sequence'.
212 Each element describes one pending sequence.
213 The main insn-chain is saved in the last element of the chain,
214 unless the chain is empty. */
216 struct sequence_stack *sequence_stack;
218 /* start_sequence and gen_sequence can make a lot of rtx expressions which are
219 shortly thrown away. We use two mechanisms to prevent this waste:
221 First, we keep a list of the expressions used to represent the sequence
222 stack in sequence_element_free_list.
224 Second, for sizes up to 5 elements, we keep a SEQUENCE and its associated
225 rtvec for use by gen_sequence. One entry for each size is sufficient
226 because most cases are calls to gen_sequence followed by immediately
227 emitting the SEQUENCE. Reuse is safe since emitting a sequence is
228 destructive on the insn in it anyway and hence can't be redone.
230 We do not bother to save this cached data over nested function calls.
231 Instead, we just reinitialize them. */
233 #define SEQUENCE_RESULT_SIZE 5
235 static struct sequence_stack *sequence_element_free_list;
236 static rtx sequence_result[SEQUENCE_RESULT_SIZE];
238 /* During RTL generation, we also keep a list of free INSN rtl codes. */
239 static rtx free_insn;
241 extern int rtx_equal_function_value_matters;
243 /* Filename and line number of last line-number note,
244 whether we actually emitted it or not. */
245 extern char *emit_filename;
246 extern int emit_lineno;
248 static rtx make_jump_insn_raw PROTO((rtx));
249 static rtx make_call_insn_raw PROTO((rtx));
250 static rtx find_line_note PROTO((rtx));
253 gen_rtx_CONST_INT (mode, arg)
254 enum machine_mode mode;
255 HOST_WIDE_INT arg;
257 if (arg >= - MAX_SAVED_CONST_INT && arg <= MAX_SAVED_CONST_INT)
258 return &const_int_rtx[arg + MAX_SAVED_CONST_INT];
260 #if STORE_FLAG_VALUE != 1 && STORE_FLAG_VALUE != -1
261 if (const_true_rtx && arg == STORE_FLAG_VALUE)
262 return const_true_rtx;
263 #endif
265 return gen_rtx_raw_CONST_INT (mode, arg);
268 /* CONST_DOUBLEs needs special handling because its length is known
269 only at run-time. */
271 gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2)
272 enum machine_mode mode;
273 rtx arg0;
274 HOST_WIDE_INT arg1, arg2;
276 rtx r = rtx_alloc (CONST_DOUBLE);
277 int i;
279 PUT_MODE (r, mode);
280 XEXP (r, 0) = arg0;
281 XEXP (r, 1) = NULL_RTX;
282 XWINT (r, 2) = arg1;
283 XWINT (r, 3) = arg2;
285 for (i = GET_RTX_LENGTH (CONST_DOUBLE) - 1; i > 3; --i)
286 XWINT (r, i) = 0;
288 return r;
292 gen_rtx_REG (mode, regno)
293 enum machine_mode mode;
294 int regno;
296 /* In case the MD file explicitly references the frame pointer, have
297 all such references point to the same frame pointer. This is
298 used during frame pointer elimination to distinguish the explicit
299 references to these registers from pseudos that happened to be
300 assigned to them.
302 If we have eliminated the frame pointer or arg pointer, we will
303 be using it as a normal register, for example as a spill
304 register. In such cases, we might be accessing it in a mode that
305 is not Pmode and therefore cannot use the pre-allocated rtx.
307 Also don't do this when we are making new REGs in reload, since
308 we don't want to get confused with the real pointers. */
310 if (mode == Pmode && !reload_in_progress)
312 if (regno == FRAME_POINTER_REGNUM)
313 return frame_pointer_rtx;
314 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
315 if (regno == HARD_FRAME_POINTER_REGNUM)
316 return hard_frame_pointer_rtx;
317 #endif
318 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
319 if (regno == ARG_POINTER_REGNUM)
320 return arg_pointer_rtx;
321 #endif
322 #ifdef RETURN_ADDRESS_POINTER_REGNUM
323 if (regno == RETURN_ADDRESS_POINTER_REGNUM)
324 return return_address_pointer_rtx;
325 #endif
326 if (regno == STACK_POINTER_REGNUM)
327 return stack_pointer_rtx;
330 return gen_rtx_raw_REG (mode, regno);
334 gen_rtx_MEM (mode, addr)
335 enum machine_mode mode;
336 rtx addr;
338 rtx rt = gen_rtx_raw_MEM (mode, addr);
340 /* This field is not cleared by the mere allocation of the rtx, so
341 we clear it here. */
342 MEM_ALIAS_SET (rt) = 0;
344 return rt;
347 /* rtx gen_rtx (code, mode, [element1, ..., elementn])
349 ** This routine generates an RTX of the size specified by
350 ** <code>, which is an RTX code. The RTX structure is initialized
351 ** from the arguments <element1> through <elementn>, which are
352 ** interpreted according to the specific RTX type's format. The
353 ** special machine mode associated with the rtx (if any) is specified
354 ** in <mode>.
356 ** gen_rtx can be invoked in a way which resembles the lisp-like
357 ** rtx it will generate. For example, the following rtx structure:
359 ** (plus:QI (mem:QI (reg:SI 1))
360 ** (mem:QI (plusw:SI (reg:SI 2) (reg:SI 3))))
362 ** ...would be generated by the following C code:
364 ** gen_rtx (PLUS, QImode,
365 ** gen_rtx (MEM, QImode,
366 ** gen_rtx (REG, SImode, 1)),
367 ** gen_rtx (MEM, QImode,
368 ** gen_rtx (PLUS, SImode,
369 ** gen_rtx (REG, SImode, 2),
370 ** gen_rtx (REG, SImode, 3)))),
373 /*VARARGS2*/
375 gen_rtx VPROTO((enum rtx_code code, enum machine_mode mode, ...))
377 #ifndef ANSI_PROTOTYPES
378 enum rtx_code code;
379 enum machine_mode mode;
380 #endif
381 va_list p;
382 register int i; /* Array indices... */
383 register char *fmt; /* Current rtx's format... */
384 register rtx rt_val; /* RTX to return to caller... */
386 VA_START (p, mode);
388 #ifndef ANSI_PROTOTYPES
389 code = va_arg (p, enum rtx_code);
390 mode = va_arg (p, enum machine_mode);
391 #endif
393 switch (code)
395 case CONST_INT:
396 rt_val = gen_rtx_CONST_INT (mode, va_arg (p, HOST_WIDE_INT));
397 break;
399 case CONST_DOUBLE:
401 rtx arg0 = va_arg (p, rtx);
402 HOST_WIDE_INT arg1 = va_arg (p, HOST_WIDE_INT);
403 HOST_WIDE_INT arg2 = va_arg (p, HOST_WIDE_INT);
404 rt_val = gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2);
406 break;
408 case REG:
409 rt_val = gen_rtx_REG (mode, va_arg (p, int));
410 break;
412 case MEM:
413 rt_val = gen_rtx_MEM (mode, va_arg (p, rtx));
414 break;
416 default:
417 rt_val = rtx_alloc (code); /* Allocate the storage space. */
418 rt_val->mode = mode; /* Store the machine mode... */
420 fmt = GET_RTX_FORMAT (code); /* Find the right format... */
421 for (i = 0; i < GET_RTX_LENGTH (code); i++)
423 switch (*fmt++)
425 case '0': /* Unused field. */
426 break;
428 case 'i': /* An integer? */
429 XINT (rt_val, i) = va_arg (p, int);
430 break;
432 case 'w': /* A wide integer? */
433 XWINT (rt_val, i) = va_arg (p, HOST_WIDE_INT);
434 break;
436 case 's': /* A string? */
437 XSTR (rt_val, i) = va_arg (p, char *);
438 break;
440 case 'e': /* An expression? */
441 case 'u': /* An insn? Same except when printing. */
442 XEXP (rt_val, i) = va_arg (p, rtx);
443 break;
445 case 'E': /* An RTX vector? */
446 XVEC (rt_val, i) = va_arg (p, rtvec);
447 break;
449 case 'b': /* A bitmap? */
450 XBITMAP (rt_val, i) = va_arg (p, bitmap);
451 break;
453 case 't': /* A tree? */
454 XTREE (rt_val, i) = va_arg (p, tree);
455 break;
457 default:
458 abort ();
461 break;
464 va_end (p);
465 return rt_val;
468 /* gen_rtvec (n, [rt1, ..., rtn])
470 ** This routine creates an rtvec and stores within it the
471 ** pointers to rtx's which are its arguments.
474 /*VARARGS1*/
475 rtvec
476 gen_rtvec VPROTO((int n, ...))
478 #ifndef ANSI_PROTOTYPES
479 int n;
480 #endif
481 int i;
482 va_list p;
483 rtx *vector;
485 VA_START (p, n);
487 #ifndef ANSI_PROTOTYPES
488 n = va_arg (p, int);
489 #endif
491 if (n == 0)
492 return NULL_RTVEC; /* Don't allocate an empty rtvec... */
494 vector = (rtx *) alloca (n * sizeof (rtx));
496 for (i = 0; i < n; i++)
497 vector[i] = va_arg (p, rtx);
498 va_end (p);
500 return gen_rtvec_v (n, vector);
503 rtvec
504 gen_rtvec_v (n, argp)
505 int n;
506 rtx *argp;
508 register int i;
509 register rtvec rt_val;
511 if (n == 0)
512 return NULL_RTVEC; /* Don't allocate an empty rtvec... */
514 rt_val = rtvec_alloc (n); /* Allocate an rtvec... */
516 for (i = 0; i < n; i++)
517 rt_val->elem[i].rtx = *argp++;
519 return rt_val;
522 rtvec
523 gen_rtvec_vv (n, argp)
524 int n;
525 rtunion *argp;
527 register int i;
528 register rtvec rt_val;
530 if (n == 0)
531 return NULL_RTVEC; /* Don't allocate an empty rtvec... */
533 rt_val = rtvec_alloc (n); /* Allocate an rtvec... */
535 for (i = 0; i < n; i++)
536 rt_val->elem[i].rtx = (argp++)->rtx;
538 return rt_val;
541 /* Generate a REG rtx for a new pseudo register of mode MODE.
542 This pseudo is assigned the next sequential register number. */
545 gen_reg_rtx (mode)
546 enum machine_mode mode;
548 register rtx val;
550 /* Don't let anything called after initial flow analysis create new
551 registers. */
552 if (no_new_pseudos)
553 abort ();
555 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
556 || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
558 /* For complex modes, don't make a single pseudo.
559 Instead, make a CONCAT of two pseudos.
560 This allows noncontiguous allocation of the real and imaginary parts,
561 which makes much better code. Besides, allocating DCmode
562 pseudos overstrains reload on some machines like the 386. */
563 rtx realpart, imagpart;
564 int size = GET_MODE_UNIT_SIZE (mode);
565 enum machine_mode partmode
566 = mode_for_size (size * BITS_PER_UNIT,
567 (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
568 ? MODE_FLOAT : MODE_INT),
571 realpart = gen_reg_rtx (partmode);
572 imagpart = gen_reg_rtx (partmode);
573 return gen_rtx_CONCAT (mode, realpart, imagpart);
576 /* Make sure regno_pointer_flag and regno_reg_rtx are large
577 enough to have an element for this pseudo reg number. */
579 if (reg_rtx_no == regno_pointer_flag_length)
581 rtx *new1;
582 char *new =
583 (char *) savealloc (regno_pointer_flag_length * 2);
584 bcopy (regno_pointer_flag, new, regno_pointer_flag_length);
585 bzero (&new[regno_pointer_flag_length], regno_pointer_flag_length);
586 regno_pointer_flag = new;
588 new = (char *) savealloc (regno_pointer_flag_length * 2);
589 bcopy (regno_pointer_align, new, regno_pointer_flag_length);
590 bzero (&new[regno_pointer_flag_length], regno_pointer_flag_length);
591 regno_pointer_align = new;
593 new1 = (rtx *) savealloc (regno_pointer_flag_length * 2 * sizeof (rtx));
594 bcopy ((char *) regno_reg_rtx, (char *) new1,
595 regno_pointer_flag_length * sizeof (rtx));
596 bzero ((char *) &new1[regno_pointer_flag_length],
597 regno_pointer_flag_length * sizeof (rtx));
598 regno_reg_rtx = new1;
600 regno_pointer_flag_length *= 2;
603 val = gen_rtx_raw_REG (mode, reg_rtx_no);
604 regno_reg_rtx[reg_rtx_no++] = val;
605 return val;
608 /* Identify REG (which may be a CONCAT) as a user register. */
610 void
611 mark_user_reg (reg)
612 rtx reg;
614 if (GET_CODE (reg) == CONCAT)
616 REG_USERVAR_P (XEXP (reg, 0)) = 1;
617 REG_USERVAR_P (XEXP (reg, 1)) = 1;
619 else if (GET_CODE (reg) == REG)
620 REG_USERVAR_P (reg) = 1;
621 else
622 abort ();
625 /* Identify REG as a probable pointer register and show its alignment
626 as ALIGN, if nonzero. */
628 void
629 mark_reg_pointer (reg, align)
630 rtx reg;
631 int align;
633 REGNO_POINTER_FLAG (REGNO (reg)) = 1;
635 if (align)
636 REGNO_POINTER_ALIGN (REGNO (reg)) = align;
639 /* Return 1 plus largest pseudo reg number used in the current function. */
642 max_reg_num ()
644 return reg_rtx_no;
647 /* Return 1 + the largest label number used so far in the current function. */
650 max_label_num ()
652 if (last_label_num && label_num == base_label_num)
653 return last_label_num;
654 return label_num;
657 /* Return first label number used in this function (if any were used). */
660 get_first_label_num ()
662 return first_label_num;
665 /* Return a value representing some low-order bits of X, where the number
666 of low-order bits is given by MODE. Note that no conversion is done
667 between floating-point and fixed-point values, rather, the bit
668 representation is returned.
670 This function handles the cases in common between gen_lowpart, below,
671 and two variants in cse.c and combine.c. These are the cases that can
672 be safely handled at all points in the compilation.
674 If this is not a case we can handle, return 0. */
677 gen_lowpart_common (mode, x)
678 enum machine_mode mode;
679 register rtx x;
681 int word = 0;
683 if (GET_MODE (x) == mode)
684 return x;
686 /* MODE must occupy no more words than the mode of X. */
687 if (GET_MODE (x) != VOIDmode
688 && ((GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD
689 > ((GET_MODE_SIZE (GET_MODE (x)) + (UNITS_PER_WORD - 1))
690 / UNITS_PER_WORD)))
691 return 0;
693 if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
694 word = ((GET_MODE_SIZE (GET_MODE (x))
695 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
696 / UNITS_PER_WORD);
698 if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)
699 && (GET_MODE_CLASS (mode) == MODE_INT
700 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT))
702 /* If we are getting the low-order part of something that has been
703 sign- or zero-extended, we can either just use the object being
704 extended or make a narrower extension. If we want an even smaller
705 piece than the size of the object being extended, call ourselves
706 recursively.
708 This case is used mostly by combine and cse. */
710 if (GET_MODE (XEXP (x, 0)) == mode)
711 return XEXP (x, 0);
712 else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (XEXP (x, 0))))
713 return gen_lowpart_common (mode, XEXP (x, 0));
714 else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (x)))
715 return gen_rtx_fmt_e (GET_CODE (x), mode, XEXP (x, 0));
717 else if (GET_CODE (x) == SUBREG
718 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
719 || GET_MODE_SIZE (mode) == GET_MODE_UNIT_SIZE (GET_MODE (x))))
720 return (GET_MODE (SUBREG_REG (x)) == mode && SUBREG_WORD (x) == 0
721 ? SUBREG_REG (x)
722 : gen_rtx_SUBREG (mode, SUBREG_REG (x), SUBREG_WORD (x) + word));
723 else if (GET_CODE (x) == REG)
725 /* Let the backend decide how many registers to skip. This is needed
726 in particular for Sparc64 where fp regs are smaller than a word. */
727 /* ??? Note that subregs are now ambiguous, in that those against
728 pseudos are sized by the Word Size, while those against hard
729 regs are sized by the underlying register size. Better would be
730 to always interpret the subreg offset parameter as bytes or bits. */
732 if (WORDS_BIG_ENDIAN && REGNO (x) < FIRST_PSEUDO_REGISTER)
733 word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
734 - HARD_REGNO_NREGS (REGNO (x), mode));
736 /* If the register is not valid for MODE, return 0. If we don't
737 do this, there is no way to fix up the resulting REG later.
738 But we do do this if the current REG is not valid for its
739 mode. This latter is a kludge, but is required due to the
740 way that parameters are passed on some machines, most
741 notably Sparc. */
742 if (REGNO (x) < FIRST_PSEUDO_REGISTER
743 && ! HARD_REGNO_MODE_OK (REGNO (x) + word, mode)
744 && HARD_REGNO_MODE_OK (REGNO (x), GET_MODE (x)))
745 return 0;
746 else if (REGNO (x) < FIRST_PSEUDO_REGISTER
747 /* integrate.c can't handle parts of a return value register. */
748 && (! REG_FUNCTION_VALUE_P (x)
749 || ! rtx_equal_function_value_matters)
750 #ifdef CLASS_CANNOT_CHANGE_SIZE
751 && ! (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (x))
752 && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_INT
753 && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_FLOAT
754 && (TEST_HARD_REG_BIT
755 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
756 REGNO (x))))
757 #endif
758 /* We want to keep the stack, frame, and arg pointers
759 special. */
760 && x != frame_pointer_rtx
761 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
762 && x != arg_pointer_rtx
763 #endif
764 && x != stack_pointer_rtx)
765 return gen_rtx_REG (mode, REGNO (x) + word);
766 else
767 return gen_rtx_SUBREG (mode, x, word);
769 /* If X is a CONST_INT or a CONST_DOUBLE, extract the appropriate bits
770 from the low-order part of the constant. */
771 else if ((GET_MODE_CLASS (mode) == MODE_INT
772 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
773 && GET_MODE (x) == VOIDmode
774 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE))
776 /* If MODE is twice the host word size, X is already the desired
777 representation. Otherwise, if MODE is wider than a word, we can't
778 do this. If MODE is exactly a word, return just one CONST_INT.
779 If MODE is smaller than a word, clear the bits that don't belong
780 in our mode, unless they and our sign bit are all one. So we get
781 either a reasonable negative value or a reasonable unsigned value
782 for this mode. */
784 if (GET_MODE_BITSIZE (mode) >= 2 * HOST_BITS_PER_WIDE_INT)
785 return x;
786 else if (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT)
787 return 0;
788 else if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT)
789 return (GET_CODE (x) == CONST_INT ? x
790 : GEN_INT (CONST_DOUBLE_LOW (x)));
791 else
793 /* MODE must be narrower than HOST_BITS_PER_WIDE_INT. */
794 int width = GET_MODE_BITSIZE (mode);
795 HOST_WIDE_INT val = (GET_CODE (x) == CONST_INT ? INTVAL (x)
796 : CONST_DOUBLE_LOW (x));
798 /* Sign extend to HOST_WIDE_INT. */
799 val = val << (HOST_BITS_PER_WIDE_INT - width) >> (HOST_BITS_PER_WIDE_INT - width);
801 return (GET_CODE (x) == CONST_INT && INTVAL (x) == val ? x
802 : GEN_INT (val));
806 /* If X is an integral constant but we want it in floating-point, it
807 must be the case that we have a union of an integer and a floating-point
808 value. If the machine-parameters allow it, simulate that union here
809 and return the result. The two-word and single-word cases are
810 different. */
812 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
813 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
814 || flag_pretend_float)
815 && GET_MODE_CLASS (mode) == MODE_FLOAT
816 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
817 && GET_CODE (x) == CONST_INT
818 && sizeof (float) * HOST_BITS_PER_CHAR == HOST_BITS_PER_WIDE_INT)
819 #ifdef REAL_ARITHMETIC
821 REAL_VALUE_TYPE r;
822 HOST_WIDE_INT i;
824 i = INTVAL (x);
825 r = REAL_VALUE_FROM_TARGET_SINGLE (i);
826 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
828 #else
830 union {HOST_WIDE_INT i; float d; } u;
832 u.i = INTVAL (x);
833 return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
835 #endif
836 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
837 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
838 || flag_pretend_float)
839 && GET_MODE_CLASS (mode) == MODE_FLOAT
840 && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
841 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE)
842 && GET_MODE (x) == VOIDmode
843 && (sizeof (double) * HOST_BITS_PER_CHAR
844 == 2 * HOST_BITS_PER_WIDE_INT))
845 #ifdef REAL_ARITHMETIC
847 REAL_VALUE_TYPE r;
848 HOST_WIDE_INT i[2];
849 HOST_WIDE_INT low, high;
851 if (GET_CODE (x) == CONST_INT)
852 low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
853 else
854 low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
856 /* REAL_VALUE_TARGET_DOUBLE takes the addressing order of the
857 target machine. */
858 if (WORDS_BIG_ENDIAN)
859 i[0] = high, i[1] = low;
860 else
861 i[0] = low, i[1] = high;
863 r = REAL_VALUE_FROM_TARGET_DOUBLE (i);
864 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
866 #else
868 union {HOST_WIDE_INT i[2]; double d; } u;
869 HOST_WIDE_INT low, high;
871 if (GET_CODE (x) == CONST_INT)
872 low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
873 else
874 low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
876 #ifdef HOST_WORDS_BIG_ENDIAN
877 u.i[0] = high, u.i[1] = low;
878 #else
879 u.i[0] = low, u.i[1] = high;
880 #endif
882 return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
884 #endif
886 /* We need an extra case for machines where HOST_BITS_PER_WIDE_INT is the
887 same as sizeof (double) or when sizeof (float) is larger than the
888 size of a word on the target machine. */
889 #ifdef REAL_ARITHMETIC
890 else if (mode == SFmode && GET_CODE (x) == CONST_INT)
892 REAL_VALUE_TYPE r;
893 HOST_WIDE_INT i;
895 i = INTVAL (x);
896 r = REAL_VALUE_FROM_TARGET_SINGLE (i);
897 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
899 #endif
901 /* Similarly, if this is converting a floating-point value into a
902 single-word integer. Only do this is the host and target parameters are
903 compatible. */
905 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
906 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
907 || flag_pretend_float)
908 && (GET_MODE_CLASS (mode) == MODE_INT
909 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
910 && GET_CODE (x) == CONST_DOUBLE
911 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
912 && GET_MODE_BITSIZE (mode) == BITS_PER_WORD)
913 return operand_subword (x, word, 0, GET_MODE (x));
915 /* Similarly, if this is converting a floating-point value into a
916 two-word integer, we can do this one word at a time and make an
917 integer. Only do this is the host and target parameters are
918 compatible. */
920 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
921 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
922 || flag_pretend_float)
923 && (GET_MODE_CLASS (mode) == MODE_INT
924 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
925 && GET_CODE (x) == CONST_DOUBLE
926 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
927 && GET_MODE_BITSIZE (mode) == 2 * BITS_PER_WORD)
929 rtx lowpart
930 = operand_subword (x, word + WORDS_BIG_ENDIAN, 0, GET_MODE (x));
931 rtx highpart
932 = operand_subword (x, word + ! WORDS_BIG_ENDIAN, 0, GET_MODE (x));
934 if (lowpart && GET_CODE (lowpart) == CONST_INT
935 && highpart && GET_CODE (highpart) == CONST_INT)
936 return immed_double_const (INTVAL (lowpart), INTVAL (highpart), mode);
939 /* Otherwise, we can't do this. */
940 return 0;
943 /* Return the real part (which has mode MODE) of a complex value X.
944 This always comes at the low address in memory. */
947 gen_realpart (mode, x)
948 enum machine_mode mode;
949 register rtx x;
951 if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
952 return XEXP (x, 0);
953 else if (WORDS_BIG_ENDIAN)
954 return gen_highpart (mode, x);
955 else
956 return gen_lowpart (mode, x);
959 /* Return the imaginary part (which has mode MODE) of a complex value X.
960 This always comes at the high address in memory. */
963 gen_imagpart (mode, x)
964 enum machine_mode mode;
965 register rtx x;
967 if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
968 return XEXP (x, 1);
969 else if (WORDS_BIG_ENDIAN)
970 return gen_lowpart (mode, x);
971 else
972 return gen_highpart (mode, x);
975 /* Return 1 iff X, assumed to be a SUBREG,
976 refers to the real part of the complex value in its containing reg.
977 Complex values are always stored with the real part in the first word,
978 regardless of WORDS_BIG_ENDIAN. */
981 subreg_realpart_p (x)
982 rtx x;
984 if (GET_CODE (x) != SUBREG)
985 abort ();
987 return SUBREG_WORD (x) * UNITS_PER_WORD < GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (x)));
990 /* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a value,
991 return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
992 least-significant part of X.
993 MODE specifies how big a part of X to return;
994 it usually should not be larger than a word.
995 If X is a MEM whose address is a QUEUED, the value may be so also. */
998 gen_lowpart (mode, x)
999 enum machine_mode mode;
1000 register rtx x;
1002 rtx result = gen_lowpart_common (mode, x);
1004 if (result)
1005 return result;
1006 else if (GET_CODE (x) == REG)
1008 /* Must be a hard reg that's not valid in MODE. */
1009 result = gen_lowpart_common (mode, copy_to_reg (x));
1010 if (result == 0)
1011 abort ();
1012 return result;
1014 else if (GET_CODE (x) == MEM)
1016 /* The only additional case we can do is MEM. */
1017 register int offset = 0;
1018 if (WORDS_BIG_ENDIAN)
1019 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
1020 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
1022 if (BYTES_BIG_ENDIAN)
1023 /* Adjust the address so that the address-after-the-data
1024 is unchanged. */
1025 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
1026 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
1028 return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
1030 else if (GET_CODE (x) == ADDRESSOF)
1031 return gen_lowpart (mode, force_reg (GET_MODE (x), x));
1032 else
1033 abort ();
1036 /* Like `gen_lowpart', but refer to the most significant part.
1037 This is used to access the imaginary part of a complex number. */
1040 gen_highpart (mode, x)
1041 enum machine_mode mode;
1042 register rtx x;
1044 /* This case loses if X is a subreg. To catch bugs early,
1045 complain if an invalid MODE is used even in other cases. */
1046 if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
1047 && GET_MODE_SIZE (mode) != GET_MODE_UNIT_SIZE (GET_MODE (x)))
1048 abort ();
1049 if (GET_CODE (x) == CONST_DOUBLE
1050 #if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined (REAL_IS_NOT_DOUBLE))
1051 && GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT
1052 #endif
1054 return GEN_INT (CONST_DOUBLE_HIGH (x) & GET_MODE_MASK (mode));
1055 else if (GET_CODE (x) == CONST_INT)
1057 if (HOST_BITS_PER_WIDE_INT <= BITS_PER_WORD)
1058 return const0_rtx;
1059 return GEN_INT (INTVAL (x) >> (HOST_BITS_PER_WIDE_INT - BITS_PER_WORD));
1061 else if (GET_CODE (x) == MEM)
1063 register int offset = 0;
1064 if (! WORDS_BIG_ENDIAN)
1065 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
1066 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
1068 if (! BYTES_BIG_ENDIAN
1069 && GET_MODE_SIZE (mode) < UNITS_PER_WORD)
1070 offset -= (GET_MODE_SIZE (mode)
1071 - MIN (UNITS_PER_WORD,
1072 GET_MODE_SIZE (GET_MODE (x))));
1074 return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
1076 else if (GET_CODE (x) == SUBREG)
1078 /* The only time this should occur is when we are looking at a
1079 multi-word item with a SUBREG whose mode is the same as that of the
1080 item. It isn't clear what we would do if it wasn't. */
1081 if (SUBREG_WORD (x) != 0)
1082 abort ();
1083 return gen_highpart (mode, SUBREG_REG (x));
1085 else if (GET_CODE (x) == REG)
1087 int word;
1089 /* Let the backend decide how many registers to skip. This is needed
1090 in particular for sparc64 where fp regs are smaller than a word. */
1091 /* ??? Note that subregs are now ambiguous, in that those against
1092 pseudos are sized by the word size, while those against hard
1093 regs are sized by the underlying register size. Better would be
1094 to always interpret the subreg offset parameter as bytes or bits. */
1096 if (WORDS_BIG_ENDIAN)
1097 word = 0;
1098 else if (REGNO (x) < FIRST_PSEUDO_REGISTER)
1099 word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
1100 - HARD_REGNO_NREGS (REGNO (x), mode));
1101 else
1102 word = ((GET_MODE_SIZE (GET_MODE (x))
1103 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
1104 / UNITS_PER_WORD);
1106 if (REGNO (x) < FIRST_PSEUDO_REGISTER
1107 /* integrate.c can't handle parts of a return value register. */
1108 && (! REG_FUNCTION_VALUE_P (x)
1109 || ! rtx_equal_function_value_matters)
1110 /* We want to keep the stack, frame, and arg pointers special. */
1111 && x != frame_pointer_rtx
1112 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1113 && x != arg_pointer_rtx
1114 #endif
1115 && x != stack_pointer_rtx)
1116 return gen_rtx_REG (mode, REGNO (x) + word);
1117 else
1118 return gen_rtx_SUBREG (mode, x, word);
1120 else
1121 abort ();
1124 /* Return 1 iff X, assumed to be a SUBREG,
1125 refers to the least significant part of its containing reg.
1126 If X is not a SUBREG, always return 1 (it is its own low part!). */
1129 subreg_lowpart_p (x)
1130 rtx x;
1132 if (GET_CODE (x) != SUBREG)
1133 return 1;
1134 else if (GET_MODE (SUBREG_REG (x)) == VOIDmode)
1135 return 0;
1137 if (WORDS_BIG_ENDIAN
1138 && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) > UNITS_PER_WORD)
1139 return (SUBREG_WORD (x)
1140 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
1141 - MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD))
1142 / UNITS_PER_WORD));
1144 return SUBREG_WORD (x) == 0;
1147 /* Return subword I of operand OP.
1148 The word number, I, is interpreted as the word number starting at the
1149 low-order address. Word 0 is the low-order word if not WORDS_BIG_ENDIAN,
1150 otherwise it is the high-order word.
1152 If we cannot extract the required word, we return zero. Otherwise, an
1153 rtx corresponding to the requested word will be returned.
1155 VALIDATE_ADDRESS is nonzero if the address should be validated. Before
1156 reload has completed, a valid address will always be returned. After
1157 reload, if a valid address cannot be returned, we return zero.
1159 If VALIDATE_ADDRESS is zero, we simply form the required address; validating
1160 it is the responsibility of the caller.
1162 MODE is the mode of OP in case it is a CONST_INT. */
1165 operand_subword (op, i, validate_address, mode)
1166 rtx op;
1167 int i;
1168 int validate_address;
1169 enum machine_mode mode;
1171 HOST_WIDE_INT val;
1172 int size_ratio = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
1173 int bits_per_word = BITS_PER_WORD;
1175 if (mode == VOIDmode)
1176 mode = GET_MODE (op);
1178 if (mode == VOIDmode)
1179 abort ();
1181 /* If OP is narrower than a word, fail. */
1182 if (mode != BLKmode
1183 && (GET_MODE_SIZE (mode) < UNITS_PER_WORD))
1184 return 0;
1186 /* If we want a word outside OP, return zero. */
1187 if (mode != BLKmode
1188 && (i + 1) * UNITS_PER_WORD > GET_MODE_SIZE (mode))
1189 return const0_rtx;
1191 /* If OP is already an integer word, return it. */
1192 if (GET_MODE_CLASS (mode) == MODE_INT
1193 && GET_MODE_SIZE (mode) == UNITS_PER_WORD)
1194 return op;
1196 /* If OP is a REG or SUBREG, we can handle it very simply. */
1197 if (GET_CODE (op) == REG)
1199 /* If the register is not valid for MODE, return 0. If we don't
1200 do this, there is no way to fix up the resulting REG later. */
1201 if (REGNO (op) < FIRST_PSEUDO_REGISTER
1202 && ! HARD_REGNO_MODE_OK (REGNO (op) + i, word_mode))
1203 return 0;
1204 else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
1205 || (REG_FUNCTION_VALUE_P (op)
1206 && rtx_equal_function_value_matters)
1207 /* We want to keep the stack, frame, and arg pointers
1208 special. */
1209 || op == frame_pointer_rtx
1210 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1211 || op == arg_pointer_rtx
1212 #endif
1213 || op == stack_pointer_rtx)
1214 return gen_rtx_SUBREG (word_mode, op, i);
1215 else
1216 return gen_rtx_REG (word_mode, REGNO (op) + i);
1218 else if (GET_CODE (op) == SUBREG)
1219 return gen_rtx_SUBREG (word_mode, SUBREG_REG (op), i + SUBREG_WORD (op));
1220 else if (GET_CODE (op) == CONCAT)
1222 int partwords = GET_MODE_UNIT_SIZE (GET_MODE (op)) / UNITS_PER_WORD;
1223 if (i < partwords)
1224 return operand_subword (XEXP (op, 0), i, validate_address, mode);
1225 return operand_subword (XEXP (op, 1), i - partwords,
1226 validate_address, mode);
1229 /* Form a new MEM at the requested address. */
1230 if (GET_CODE (op) == MEM)
1232 rtx addr = plus_constant (XEXP (op, 0), i * UNITS_PER_WORD);
1233 rtx new;
1235 if (validate_address)
1237 if (reload_completed)
1239 if (! strict_memory_address_p (word_mode, addr))
1240 return 0;
1242 else
1243 addr = memory_address (word_mode, addr);
1246 new = gen_rtx_MEM (word_mode, addr);
1248 MEM_COPY_ATTRIBUTES (new, op);
1249 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (op);
1251 return new;
1254 /* The only remaining cases are when OP is a constant. If the host and
1255 target floating formats are the same, handling two-word floating
1256 constants are easy. Note that REAL_VALUE_TO_TARGET_{SINGLE,DOUBLE}
1257 are defined as returning one or two 32 bit values, respectively,
1258 and not values of BITS_PER_WORD bits. */
1259 #ifdef REAL_ARITHMETIC
1260 /* The output is some bits, the width of the target machine's word.
1261 A wider-word host can surely hold them in a CONST_INT. A narrower-word
1262 host can't. */
1263 if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1264 && GET_MODE_CLASS (mode) == MODE_FLOAT
1265 && GET_MODE_BITSIZE (mode) == 64
1266 && GET_CODE (op) == CONST_DOUBLE)
1268 long k[2];
1269 REAL_VALUE_TYPE rv;
1271 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1272 REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
1274 /* We handle 32-bit and >= 64-bit words here. Note that the order in
1275 which the words are written depends on the word endianness.
1277 ??? This is a potential portability problem and should
1278 be fixed at some point. */
1279 if (BITS_PER_WORD == 32)
1280 return GEN_INT ((HOST_WIDE_INT) k[i]);
1281 #if HOST_BITS_PER_WIDE_INT > 32
1282 else if (BITS_PER_WORD >= 64 && i == 0)
1283 return GEN_INT ((((HOST_WIDE_INT) k[! WORDS_BIG_ENDIAN]) << 32)
1284 | (HOST_WIDE_INT) k[WORDS_BIG_ENDIAN]);
1285 #endif
1286 else if (BITS_PER_WORD == 16)
1288 long value;
1289 value = k[i >> 1];
1290 if ((i & 0x1) == !WORDS_BIG_ENDIAN)
1291 value >>= 16;
1292 value &= 0xffff;
1293 return GEN_INT ((HOST_WIDE_INT) value);
1295 else
1296 abort ();
1298 else if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1299 && GET_MODE_CLASS (mode) == MODE_FLOAT
1300 && GET_MODE_BITSIZE (mode) > 64
1301 && GET_CODE (op) == CONST_DOUBLE)
1303 long k[4];
1304 REAL_VALUE_TYPE rv;
1306 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1307 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
1309 if (BITS_PER_WORD == 32)
1310 return GEN_INT ((HOST_WIDE_INT) k[i]);
1312 #else /* no REAL_ARITHMETIC */
1313 if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1314 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1315 || flag_pretend_float)
1316 && GET_MODE_CLASS (mode) == MODE_FLOAT
1317 && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
1318 && GET_CODE (op) == CONST_DOUBLE)
1320 /* The constant is stored in the host's word-ordering,
1321 but we want to access it in the target's word-ordering. Some
1322 compilers don't like a conditional inside macro args, so we have two
1323 copies of the return. */
1324 #ifdef HOST_WORDS_BIG_ENDIAN
1325 return GEN_INT (i == WORDS_BIG_ENDIAN
1326 ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
1327 #else
1328 return GEN_INT (i != WORDS_BIG_ENDIAN
1329 ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
1330 #endif
1332 #endif /* no REAL_ARITHMETIC */
1334 /* Single word float is a little harder, since single- and double-word
1335 values often do not have the same high-order bits. We have already
1336 verified that we want the only defined word of the single-word value. */
1337 #ifdef REAL_ARITHMETIC
1338 if (GET_MODE_CLASS (mode) == MODE_FLOAT
1339 && GET_MODE_BITSIZE (mode) == 32
1340 && GET_CODE (op) == CONST_DOUBLE)
1342 long l;
1343 REAL_VALUE_TYPE rv;
1345 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1346 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
1348 /* If 32 bits is an entire word for the target, but not for the host,
1349 then sign-extend on the host so that the number will look the same
1350 way on the host that it would on the target. See for instance
1351 simplify_unary_operation. The #if is needed to avoid compiler
1352 warnings. */
1354 #if HOST_BITS_PER_LONG > 32
1355 if (BITS_PER_WORD < HOST_BITS_PER_LONG && BITS_PER_WORD == 32
1356 && (l & ((long) 1 << 31)))
1357 l |= ((long) (-1) << 32);
1358 #endif
1360 if (BITS_PER_WORD == 16)
1362 if ((i & 0x1) == !WORDS_BIG_ENDIAN)
1363 l >>= 16;
1364 l &= 0xffff;
1366 return GEN_INT ((HOST_WIDE_INT) l);
1368 #else
1369 if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1370 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1371 || flag_pretend_float)
1372 && sizeof (float) * 8 == HOST_BITS_PER_WIDE_INT
1373 && GET_MODE_CLASS (mode) == MODE_FLOAT
1374 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1375 && GET_CODE (op) == CONST_DOUBLE)
1377 double d;
1378 union {float f; HOST_WIDE_INT i; } u;
1380 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1382 u.f = d;
1383 return GEN_INT (u.i);
1385 if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1386 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1387 || flag_pretend_float)
1388 && sizeof (double) * 8 == HOST_BITS_PER_WIDE_INT
1389 && GET_MODE_CLASS (mode) == MODE_FLOAT
1390 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1391 && GET_CODE (op) == CONST_DOUBLE)
1393 double d;
1394 union {double d; HOST_WIDE_INT i; } u;
1396 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1398 u.d = d;
1399 return GEN_INT (u.i);
1401 #endif /* no REAL_ARITHMETIC */
1403 /* The only remaining cases that we can handle are integers.
1404 Convert to proper endianness now since these cases need it.
1405 At this point, i == 0 means the low-order word.
1407 We do not want to handle the case when BITS_PER_WORD <= HOST_BITS_PER_INT
1408 in general. However, if OP is (const_int 0), we can just return
1409 it for any word. */
1411 if (op == const0_rtx)
1412 return op;
1414 if (GET_MODE_CLASS (mode) != MODE_INT
1415 || (GET_CODE (op) != CONST_INT && GET_CODE (op) != CONST_DOUBLE)
1416 || BITS_PER_WORD > HOST_BITS_PER_WIDE_INT)
1417 return 0;
1419 if (WORDS_BIG_ENDIAN)
1420 i = GET_MODE_SIZE (mode) / UNITS_PER_WORD - 1 - i;
1422 /* Find out which word on the host machine this value is in and get
1423 it from the constant. */
1424 val = (i / size_ratio == 0
1425 ? (GET_CODE (op) == CONST_INT ? INTVAL (op) : CONST_DOUBLE_LOW (op))
1426 : (GET_CODE (op) == CONST_INT
1427 ? (INTVAL (op) < 0 ? ~0 : 0) : CONST_DOUBLE_HIGH (op)));
1429 /* Get the value we want into the low bits of val. */
1430 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT)
1431 val = ((val >> ((i % size_ratio) * BITS_PER_WORD)));
1433 /* Clear the bits that don't belong in our mode, unless they and our sign
1434 bit are all one. So we get either a reasonable negative value or a
1435 reasonable unsigned value for this mode. */
1436 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT
1437 && ((val & ((HOST_WIDE_INT) (-1) << (bits_per_word - 1)))
1438 != ((HOST_WIDE_INT) (-1) << (bits_per_word - 1))))
1439 val &= ((HOST_WIDE_INT) 1 << bits_per_word) - 1;
1441 /* If this would be an entire word for the target, but is not for
1442 the host, then sign-extend on the host so that the number will look
1443 the same way on the host that it would on the target.
1445 For example, when building a 64 bit alpha hosted 32 bit sparc
1446 targeted compiler, then we want the 32 bit unsigned value -1 to be
1447 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1448 The later confuses the sparc backend. */
1450 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT
1451 && (val & ((HOST_WIDE_INT) 1 << (bits_per_word - 1))))
1452 val |= ((HOST_WIDE_INT) (-1) << bits_per_word);
1454 return GEN_INT (val);
1457 /* Similar to `operand_subword', but never return 0. If we can't extract
1458 the required subword, put OP into a register and try again. If that fails,
1459 abort. We always validate the address in this case. It is not valid
1460 to call this function after reload; it is mostly meant for RTL
1461 generation.
1463 MODE is the mode of OP, in case it is CONST_INT. */
1466 operand_subword_force (op, i, mode)
1467 rtx op;
1468 int i;
1469 enum machine_mode mode;
1471 rtx result = operand_subword (op, i, 1, mode);
1473 if (result)
1474 return result;
1476 if (mode != BLKmode && mode != VOIDmode)
1478 /* If this is a register which can not be accessed by words, copy it
1479 to a pseudo register. */
1480 if (GET_CODE (op) == REG)
1481 op = copy_to_reg (op);
1482 else
1483 op = force_reg (mode, op);
1486 result = operand_subword (op, i, 1, mode);
1487 if (result == 0)
1488 abort ();
1490 return result;
1493 /* Given a compare instruction, swap the operands.
1494 A test instruction is changed into a compare of 0 against the operand. */
1496 void
1497 reverse_comparison (insn)
1498 rtx insn;
1500 rtx body = PATTERN (insn);
1501 rtx comp;
1503 if (GET_CODE (body) == SET)
1504 comp = SET_SRC (body);
1505 else
1506 comp = SET_SRC (XVECEXP (body, 0, 0));
1508 if (GET_CODE (comp) == COMPARE)
1510 rtx op0 = XEXP (comp, 0);
1511 rtx op1 = XEXP (comp, 1);
1512 XEXP (comp, 0) = op1;
1513 XEXP (comp, 1) = op0;
1515 else
1517 rtx new = gen_rtx_COMPARE (VOIDmode, CONST0_RTX (GET_MODE (comp)), comp);
1518 if (GET_CODE (body) == SET)
1519 SET_SRC (body) = new;
1520 else
1521 SET_SRC (XVECEXP (body, 0, 0)) = new;
1525 /* Return a memory reference like MEMREF, but with its mode changed
1526 to MODE and its address changed to ADDR.
1527 (VOIDmode means don't change the mode.
1528 NULL for ADDR means don't change the address.) */
1531 change_address (memref, mode, addr)
1532 rtx memref;
1533 enum machine_mode mode;
1534 rtx addr;
1536 rtx new;
1538 if (GET_CODE (memref) != MEM)
1539 abort ();
1540 if (mode == VOIDmode)
1541 mode = GET_MODE (memref);
1542 if (addr == 0)
1543 addr = XEXP (memref, 0);
1545 /* If reload is in progress or has completed, ADDR must be valid.
1546 Otherwise, we can call memory_address to make it valid. */
1547 if (reload_completed || reload_in_progress)
1549 if (! memory_address_p (mode, addr))
1550 abort ();
1552 else
1553 addr = memory_address (mode, addr);
1555 if (rtx_equal_p (addr, XEXP (memref, 0)) && mode == GET_MODE (memref))
1556 return memref;
1558 new = gen_rtx_MEM (mode, addr);
1559 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (memref);
1560 MEM_COPY_ATTRIBUTES (new, memref);
1561 return new;
1564 /* Return a newly created CODE_LABEL rtx with a unique label number. */
1567 gen_label_rtx ()
1569 register rtx label;
1571 label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX,
1572 NULL_RTX, label_num++, NULL_PTR);
1574 LABEL_NUSES (label) = 0;
1575 return label;
1578 /* For procedure integration. */
1580 /* Return a newly created INLINE_HEADER rtx. Should allocate this
1581 from a permanent obstack when the opportunity arises. */
1584 gen_inline_header_rtx (first_insn, first_parm_insn, first_labelno,
1585 last_labelno, max_parm_regnum, max_regnum, args_size,
1586 pops_args, stack_slots, forced_labels, function_flags,
1587 outgoing_args_size, original_arg_vector,
1588 original_decl_initial, regno_rtx, regno_flag,
1589 regno_align, parm_reg_stack_loc)
1590 rtx first_insn, first_parm_insn;
1591 int first_labelno, last_labelno, max_parm_regnum, max_regnum, args_size;
1592 int pops_args;
1593 rtx stack_slots;
1594 rtx forced_labels;
1595 int function_flags;
1596 int outgoing_args_size;
1597 rtvec original_arg_vector;
1598 rtx original_decl_initial;
1599 rtvec regno_rtx;
1600 char *regno_flag;
1601 char *regno_align;
1602 rtvec parm_reg_stack_loc;
1604 rtx header = gen_rtx_INLINE_HEADER (VOIDmode,
1605 cur_insn_uid++, NULL_RTX,
1606 first_insn, first_parm_insn,
1607 first_labelno, last_labelno,
1608 max_parm_regnum, max_regnum, args_size,
1609 pops_args, stack_slots, forced_labels,
1610 function_flags, outgoing_args_size,
1611 original_arg_vector,
1612 original_decl_initial,
1613 regno_rtx, regno_flag, regno_align,
1614 parm_reg_stack_loc);
1615 return header;
1618 /* Install new pointers to the first and last insns in the chain.
1619 Also, set cur_insn_uid to one higher than the last in use.
1620 Used for an inline-procedure after copying the insn chain. */
1622 void
1623 set_new_first_and_last_insn (first, last)
1624 rtx first, last;
1626 rtx insn;
1628 first_insn = first;
1629 last_insn = last;
1630 cur_insn_uid = 0;
1632 for (insn = first; insn; insn = NEXT_INSN (insn))
1633 cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
1635 cur_insn_uid++;
1638 /* Set the range of label numbers found in the current function.
1639 This is used when belatedly compiling an inline function. */
1641 void
1642 set_new_first_and_last_label_num (first, last)
1643 int first, last;
1645 base_label_num = label_num;
1646 first_label_num = first;
1647 last_label_num = last;
1650 /* Save all variables describing the current status into the structure *P.
1651 This is used before starting a nested function. */
1653 void
1654 save_emit_status (p)
1655 struct function *p;
1657 p->reg_rtx_no = reg_rtx_no;
1658 p->first_label_num = first_label_num;
1659 p->first_insn = first_insn;
1660 p->last_insn = last_insn;
1661 p->sequence_rtl_expr = sequence_rtl_expr;
1662 p->sequence_stack = sequence_stack;
1663 p->cur_insn_uid = cur_insn_uid;
1664 p->last_linenum = last_linenum;
1665 p->last_filename = last_filename;
1666 p->regno_pointer_flag = regno_pointer_flag;
1667 p->regno_pointer_align = regno_pointer_align;
1668 p->regno_pointer_flag_length = regno_pointer_flag_length;
1669 p->regno_reg_rtx = regno_reg_rtx;
1672 /* Restore all variables describing the current status from the structure *P.
1673 This is used after a nested function. */
1675 void
1676 restore_emit_status (p)
1677 struct function *p;
1679 int i;
1681 reg_rtx_no = p->reg_rtx_no;
1682 first_label_num = p->first_label_num;
1683 last_label_num = 0;
1684 first_insn = p->first_insn;
1685 last_insn = p->last_insn;
1686 sequence_rtl_expr = p->sequence_rtl_expr;
1687 sequence_stack = p->sequence_stack;
1688 cur_insn_uid = p->cur_insn_uid;
1689 last_linenum = p->last_linenum;
1690 last_filename = p->last_filename;
1691 regno_pointer_flag = p->regno_pointer_flag;
1692 regno_pointer_align = p->regno_pointer_align;
1693 regno_pointer_flag_length = p->regno_pointer_flag_length;
1694 regno_reg_rtx = p->regno_reg_rtx;
1696 /* Clear our cache of rtx expressions for start_sequence and
1697 gen_sequence. */
1698 sequence_element_free_list = 0;
1699 for (i = 0; i < SEQUENCE_RESULT_SIZE; i++)
1700 sequence_result[i] = 0;
1702 free_insn = 0;
1705 /* Go through all the RTL insn bodies and copy any invalid shared structure.
1706 It does not work to do this twice, because the mark bits set here
1707 are not cleared afterwards. */
1709 void
1710 unshare_all_rtl (insn)
1711 register rtx insn;
1713 for (; insn; insn = NEXT_INSN (insn))
1714 if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
1715 || GET_CODE (insn) == CALL_INSN)
1717 PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
1718 REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
1719 LOG_LINKS (insn) = copy_rtx_if_shared (LOG_LINKS (insn));
1722 /* Make sure the addresses of stack slots found outside the insn chain
1723 (such as, in DECL_RTL of a variable) are not shared
1724 with the insn chain.
1726 This special care is necessary when the stack slot MEM does not
1727 actually appear in the insn chain. If it does appear, its address
1728 is unshared from all else at that point. */
1730 copy_rtx_if_shared (stack_slot_list);
1733 /* Mark ORIG as in use, and return a copy of it if it was already in use.
1734 Recursively does the same for subexpressions. */
1737 copy_rtx_if_shared (orig)
1738 rtx orig;
1740 register rtx x = orig;
1741 register int i;
1742 register enum rtx_code code;
1743 register char *format_ptr;
1744 int copied = 0;
1746 if (x == 0)
1747 return 0;
1749 code = GET_CODE (x);
1751 /* These types may be freely shared. */
1753 switch (code)
1755 case REG:
1756 case QUEUED:
1757 case CONST_INT:
1758 case CONST_DOUBLE:
1759 case SYMBOL_REF:
1760 case CODE_LABEL:
1761 case PC:
1762 case CC0:
1763 case SCRATCH:
1764 /* SCRATCH must be shared because they represent distinct values. */
1765 return x;
1767 case CONST:
1768 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
1769 a LABEL_REF, it isn't sharable. */
1770 if (GET_CODE (XEXP (x, 0)) == PLUS
1771 && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
1772 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
1773 return x;
1774 break;
1776 case INSN:
1777 case JUMP_INSN:
1778 case CALL_INSN:
1779 case NOTE:
1780 case BARRIER:
1781 /* The chain of insns is not being copied. */
1782 return x;
1784 case MEM:
1785 /* A MEM is allowed to be shared if its address is constant
1786 or is a constant plus one of the special registers. */
1787 if (CONSTANT_ADDRESS_P (XEXP (x, 0))
1788 || XEXP (x, 0) == virtual_stack_vars_rtx
1789 || XEXP (x, 0) == virtual_incoming_args_rtx)
1790 return x;
1792 if (GET_CODE (XEXP (x, 0)) == PLUS
1793 && (XEXP (XEXP (x, 0), 0) == virtual_stack_vars_rtx
1794 || XEXP (XEXP (x, 0), 0) == virtual_incoming_args_rtx)
1795 && CONSTANT_ADDRESS_P (XEXP (XEXP (x, 0), 1)))
1797 /* This MEM can appear in more than one place,
1798 but its address better not be shared with anything else. */
1799 if (! x->used)
1800 XEXP (x, 0) = copy_rtx_if_shared (XEXP (x, 0));
1801 x->used = 1;
1802 return x;
1804 break;
1806 default:
1807 break;
1810 /* This rtx may not be shared. If it has already been seen,
1811 replace it with a copy of itself. */
1813 if (x->used)
1815 register rtx copy;
1817 copy = rtx_alloc (code);
1818 bcopy ((char *) x, (char *) copy,
1819 (sizeof (*copy) - sizeof (copy->fld)
1820 + sizeof (copy->fld[0]) * GET_RTX_LENGTH (code)));
1821 x = copy;
1822 copied = 1;
1824 x->used = 1;
1826 /* Now scan the subexpressions recursively.
1827 We can store any replaced subexpressions directly into X
1828 since we know X is not shared! Any vectors in X
1829 must be copied if X was copied. */
1831 format_ptr = GET_RTX_FORMAT (code);
1833 for (i = 0; i < GET_RTX_LENGTH (code); i++)
1835 switch (*format_ptr++)
1837 case 'e':
1838 XEXP (x, i) = copy_rtx_if_shared (XEXP (x, i));
1839 break;
1841 case 'E':
1842 if (XVEC (x, i) != NULL)
1844 register int j;
1845 int len = XVECLEN (x, i);
1847 if (copied && len > 0)
1848 XVEC (x, i) = gen_rtvec_vv (len, XVEC (x, i)->elem);
1849 for (j = 0; j < len; j++)
1850 XVECEXP (x, i, j) = copy_rtx_if_shared (XVECEXP (x, i, j));
1852 break;
1855 return x;
1858 /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
1859 to look for shared sub-parts. */
1861 void
1862 reset_used_flags (x)
1863 rtx x;
1865 register int i, j;
1866 register enum rtx_code code;
1867 register char *format_ptr;
1869 if (x == 0)
1870 return;
1872 code = GET_CODE (x);
1874 /* These types may be freely shared so we needn't do any resetting
1875 for them. */
1877 switch (code)
1879 case REG:
1880 case QUEUED:
1881 case CONST_INT:
1882 case CONST_DOUBLE:
1883 case SYMBOL_REF:
1884 case CODE_LABEL:
1885 case PC:
1886 case CC0:
1887 return;
1889 case INSN:
1890 case JUMP_INSN:
1891 case CALL_INSN:
1892 case NOTE:
1893 case LABEL_REF:
1894 case BARRIER:
1895 /* The chain of insns is not being copied. */
1896 return;
1898 default:
1899 break;
1902 x->used = 0;
1904 format_ptr = GET_RTX_FORMAT (code);
1905 for (i = 0; i < GET_RTX_LENGTH (code); i++)
1907 switch (*format_ptr++)
1909 case 'e':
1910 reset_used_flags (XEXP (x, i));
1911 break;
1913 case 'E':
1914 for (j = 0; j < XVECLEN (x, i); j++)
1915 reset_used_flags (XVECEXP (x, i, j));
1916 break;
1921 /* Copy X if necessary so that it won't be altered by changes in OTHER.
1922 Return X or the rtx for the pseudo reg the value of X was copied into.
1923 OTHER must be valid as a SET_DEST. */
1926 make_safe_from (x, other)
1927 rtx x, other;
1929 while (1)
1930 switch (GET_CODE (other))
1932 case SUBREG:
1933 other = SUBREG_REG (other);
1934 break;
1935 case STRICT_LOW_PART:
1936 case SIGN_EXTEND:
1937 case ZERO_EXTEND:
1938 other = XEXP (other, 0);
1939 break;
1940 default:
1941 goto done;
1943 done:
1944 if ((GET_CODE (other) == MEM
1945 && ! CONSTANT_P (x)
1946 && GET_CODE (x) != REG
1947 && GET_CODE (x) != SUBREG)
1948 || (GET_CODE (other) == REG
1949 && (REGNO (other) < FIRST_PSEUDO_REGISTER
1950 || reg_mentioned_p (other, x))))
1952 rtx temp = gen_reg_rtx (GET_MODE (x));
1953 emit_move_insn (temp, x);
1954 return temp;
1956 return x;
1959 /* Emission of insns (adding them to the doubly-linked list). */
1961 /* Return the first insn of the current sequence or current function. */
1964 get_insns ()
1966 return first_insn;
1969 /* Return the last insn emitted in current sequence or current function. */
1972 get_last_insn ()
1974 return last_insn;
1977 /* Specify a new insn as the last in the chain. */
1979 void
1980 set_last_insn (insn)
1981 rtx insn;
1983 if (NEXT_INSN (insn) != 0)
1984 abort ();
1985 last_insn = insn;
1988 /* Return the last insn emitted, even if it is in a sequence now pushed. */
1991 get_last_insn_anywhere ()
1993 struct sequence_stack *stack;
1994 if (last_insn)
1995 return last_insn;
1996 for (stack = sequence_stack; stack; stack = stack->next)
1997 if (stack->last != 0)
1998 return stack->last;
1999 return 0;
2002 /* Return a number larger than any instruction's uid in this function. */
2005 get_max_uid ()
2007 return cur_insn_uid;
2010 /* Return the next insn. If it is a SEQUENCE, return the first insn
2011 of the sequence. */
2014 next_insn (insn)
2015 rtx insn;
2017 if (insn)
2019 insn = NEXT_INSN (insn);
2020 if (insn && GET_CODE (insn) == INSN
2021 && GET_CODE (PATTERN (insn)) == SEQUENCE)
2022 insn = XVECEXP (PATTERN (insn), 0, 0);
2025 return insn;
2028 /* Return the previous insn. If it is a SEQUENCE, return the last insn
2029 of the sequence. */
2032 previous_insn (insn)
2033 rtx insn;
2035 if (insn)
2037 insn = PREV_INSN (insn);
2038 if (insn && GET_CODE (insn) == INSN
2039 && GET_CODE (PATTERN (insn)) == SEQUENCE)
2040 insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1);
2043 return insn;
2046 /* Return the next insn after INSN that is not a NOTE. This routine does not
2047 look inside SEQUENCEs. */
2050 next_nonnote_insn (insn)
2051 rtx insn;
2053 while (insn)
2055 insn = NEXT_INSN (insn);
2056 if (insn == 0 || GET_CODE (insn) != NOTE)
2057 break;
2060 return insn;
2063 /* Return the previous insn before INSN that is not a NOTE. This routine does
2064 not look inside SEQUENCEs. */
2067 prev_nonnote_insn (insn)
2068 rtx insn;
2070 while (insn)
2072 insn = PREV_INSN (insn);
2073 if (insn == 0 || GET_CODE (insn) != NOTE)
2074 break;
2077 return insn;
2080 /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
2081 or 0, if there is none. This routine does not look inside
2082 SEQUENCEs. */
2085 next_real_insn (insn)
2086 rtx insn;
2088 while (insn)
2090 insn = NEXT_INSN (insn);
2091 if (insn == 0 || GET_CODE (insn) == INSN
2092 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN)
2093 break;
2096 return insn;
2099 /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
2100 or 0, if there is none. This routine does not look inside
2101 SEQUENCEs. */
2104 prev_real_insn (insn)
2105 rtx insn;
2107 while (insn)
2109 insn = PREV_INSN (insn);
2110 if (insn == 0 || GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
2111 || GET_CODE (insn) == JUMP_INSN)
2112 break;
2115 return insn;
2118 /* Find the next insn after INSN that really does something. This routine
2119 does not look inside SEQUENCEs. Until reload has completed, this is the
2120 same as next_real_insn. */
2123 next_active_insn (insn)
2124 rtx insn;
2126 while (insn)
2128 insn = NEXT_INSN (insn);
2129 if (insn == 0
2130 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN
2131 || (GET_CODE (insn) == INSN
2132 && (! reload_completed
2133 || (GET_CODE (PATTERN (insn)) != USE
2134 && GET_CODE (PATTERN (insn)) != CLOBBER))))
2135 break;
2138 return insn;
2141 /* Find the last insn before INSN that really does something. This routine
2142 does not look inside SEQUENCEs. Until reload has completed, this is the
2143 same as prev_real_insn. */
2146 prev_active_insn (insn)
2147 rtx insn;
2149 while (insn)
2151 insn = PREV_INSN (insn);
2152 if (insn == 0
2153 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN
2154 || (GET_CODE (insn) == INSN
2155 && (! reload_completed
2156 || (GET_CODE (PATTERN (insn)) != USE
2157 && GET_CODE (PATTERN (insn)) != CLOBBER))))
2158 break;
2161 return insn;
2164 /* Return the next CODE_LABEL after the insn INSN, or 0 if there is none. */
2167 next_label (insn)
2168 rtx insn;
2170 while (insn)
2172 insn = NEXT_INSN (insn);
2173 if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2174 break;
2177 return insn;
2180 /* Return the last CODE_LABEL before the insn INSN, or 0 if there is none. */
2183 prev_label (insn)
2184 rtx insn;
2186 while (insn)
2188 insn = PREV_INSN (insn);
2189 if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2190 break;
2193 return insn;
2196 #ifdef HAVE_cc0
2197 /* INSN uses CC0 and is being moved into a delay slot. Set up REG_CC_SETTER
2198 and REG_CC_USER notes so we can find it. */
2200 void
2201 link_cc0_insns (insn)
2202 rtx insn;
2204 rtx user = next_nonnote_insn (insn);
2206 if (GET_CODE (user) == INSN && GET_CODE (PATTERN (user)) == SEQUENCE)
2207 user = XVECEXP (PATTERN (user), 0, 0);
2209 REG_NOTES (user) = gen_rtx_INSN_LIST (REG_CC_SETTER, insn, REG_NOTES (user));
2210 REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_CC_USER, user, REG_NOTES (insn));
2213 /* Return the next insn that uses CC0 after INSN, which is assumed to
2214 set it. This is the inverse of prev_cc0_setter (i.e., prev_cc0_setter
2215 applied to the result of this function should yield INSN).
2217 Normally, this is simply the next insn. However, if a REG_CC_USER note
2218 is present, it contains the insn that uses CC0.
2220 Return 0 if we can't find the insn. */
2223 next_cc0_user (insn)
2224 rtx insn;
2226 rtx note = find_reg_note (insn, REG_CC_USER, NULL_RTX);
2228 if (note)
2229 return XEXP (note, 0);
2231 insn = next_nonnote_insn (insn);
2232 if (insn && GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
2233 insn = XVECEXP (PATTERN (insn), 0, 0);
2235 if (insn && GET_RTX_CLASS (GET_CODE (insn)) == 'i'
2236 && reg_mentioned_p (cc0_rtx, PATTERN (insn)))
2237 return insn;
2239 return 0;
2242 /* Find the insn that set CC0 for INSN. Unless INSN has a REG_CC_SETTER
2243 note, it is the previous insn. */
2246 prev_cc0_setter (insn)
2247 rtx insn;
2249 rtx note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
2251 if (note)
2252 return XEXP (note, 0);
2254 insn = prev_nonnote_insn (insn);
2255 if (! sets_cc0_p (PATTERN (insn)))
2256 abort ();
2258 return insn;
2260 #endif
2262 /* Try splitting insns that can be split for better scheduling.
2263 PAT is the pattern which might split.
2264 TRIAL is the insn providing PAT.
2265 LAST is non-zero if we should return the last insn of the sequence produced.
2267 If this routine succeeds in splitting, it returns the first or last
2268 replacement insn depending on the value of LAST. Otherwise, it
2269 returns TRIAL. If the insn to be returned can be split, it will be. */
2272 try_split (pat, trial, last)
2273 rtx pat, trial;
2274 int last;
2276 rtx before = PREV_INSN (trial);
2277 rtx after = NEXT_INSN (trial);
2278 rtx seq = split_insns (pat, trial);
2279 int has_barrier = 0;
2280 rtx tem;
2282 /* If we are splitting a JUMP_INSN, it might be followed by a BARRIER.
2283 We may need to handle this specially. */
2284 if (after && GET_CODE (after) == BARRIER)
2286 has_barrier = 1;
2287 after = NEXT_INSN (after);
2290 if (seq)
2292 /* SEQ can either be a SEQUENCE or the pattern of a single insn.
2293 The latter case will normally arise only when being done so that
2294 it, in turn, will be split (SFmode on the 29k is an example). */
2295 if (GET_CODE (seq) == SEQUENCE)
2297 /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
2298 SEQ and copy our JUMP_LABEL to it. If JUMP_LABEL is non-zero,
2299 increment the usage count so we don't delete the label. */
2300 int i;
2302 if (GET_CODE (trial) == JUMP_INSN)
2303 for (i = XVECLEN (seq, 0) - 1; i >= 0; i--)
2304 if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN)
2306 JUMP_LABEL (XVECEXP (seq, 0, i)) = JUMP_LABEL (trial);
2308 if (JUMP_LABEL (trial))
2309 LABEL_NUSES (JUMP_LABEL (trial))++;
2312 tem = emit_insn_after (seq, before);
2314 delete_insn (trial);
2315 if (has_barrier)
2316 emit_barrier_after (tem);
2318 /* Recursively call try_split for each new insn created; by the
2319 time control returns here that insn will be fully split, so
2320 set LAST and continue from the insn after the one returned.
2321 We can't use next_active_insn here since AFTER may be a note.
2322 Ignore deleted insns, which can be occur if not optimizing. */
2323 for (tem = NEXT_INSN (before); tem != after;
2324 tem = NEXT_INSN (tem))
2325 if (! INSN_DELETED_P (tem)
2326 && GET_RTX_CLASS (GET_CODE (tem)) == 'i')
2327 tem = try_split (PATTERN (tem), tem, 1);
2329 /* Avoid infinite loop if the result matches the original pattern. */
2330 else if (rtx_equal_p (seq, pat))
2331 return trial;
2332 else
2334 PATTERN (trial) = seq;
2335 INSN_CODE (trial) = -1;
2336 try_split (seq, trial, last);
2339 /* Return either the first or the last insn, depending on which was
2340 requested. */
2341 return last ? prev_active_insn (after) : next_active_insn (before);
2344 return trial;
2347 /* Make and return an INSN rtx, initializing all its slots.
2348 Store PATTERN in the pattern slots. */
2351 make_insn_raw (pattern)
2352 rtx pattern;
2354 register rtx insn;
2356 /* If in RTL generation phase, see if FREE_INSN can be used. */
2357 if (free_insn != 0 && rtx_equal_function_value_matters)
2359 insn = free_insn;
2360 free_insn = NEXT_INSN (free_insn);
2361 PUT_CODE (insn, INSN);
2363 else
2364 insn = rtx_alloc (INSN);
2366 INSN_UID (insn) = cur_insn_uid++;
2367 PATTERN (insn) = pattern;
2368 INSN_CODE (insn) = -1;
2369 LOG_LINKS (insn) = NULL;
2370 REG_NOTES (insn) = NULL;
2372 return insn;
2375 /* Like `make_insn' but make a JUMP_INSN instead of an insn. */
2377 static rtx
2378 make_jump_insn_raw (pattern)
2379 rtx pattern;
2381 register rtx insn;
2383 insn = rtx_alloc (JUMP_INSN);
2384 INSN_UID (insn) = cur_insn_uid++;
2386 PATTERN (insn) = pattern;
2387 INSN_CODE (insn) = -1;
2388 LOG_LINKS (insn) = NULL;
2389 REG_NOTES (insn) = NULL;
2390 JUMP_LABEL (insn) = NULL;
2392 return insn;
2395 /* Like `make_insn' but make a CALL_INSN instead of an insn. */
2397 static rtx
2398 make_call_insn_raw (pattern)
2399 rtx pattern;
2401 register rtx insn;
2403 insn = rtx_alloc (CALL_INSN);
2404 INSN_UID (insn) = cur_insn_uid++;
2406 PATTERN (insn) = pattern;
2407 INSN_CODE (insn) = -1;
2408 LOG_LINKS (insn) = NULL;
2409 REG_NOTES (insn) = NULL;
2410 CALL_INSN_FUNCTION_USAGE (insn) = NULL;
2412 return insn;
2415 /* Add INSN to the end of the doubly-linked list.
2416 INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE. */
2418 void
2419 add_insn (insn)
2420 register rtx insn;
2422 PREV_INSN (insn) = last_insn;
2423 NEXT_INSN (insn) = 0;
2425 if (NULL != last_insn)
2426 NEXT_INSN (last_insn) = insn;
2428 if (NULL == first_insn)
2429 first_insn = insn;
2431 last_insn = insn;
2434 /* Add INSN into the doubly-linked list after insn AFTER. This and
2435 the next should be the only functions called to insert an insn once
2436 delay slots have been filled since only they know how to update a
2437 SEQUENCE. */
2439 void
2440 add_insn_after (insn, after)
2441 rtx insn, after;
2443 rtx next = NEXT_INSN (after);
2445 if (optimize && INSN_DELETED_P (after))
2446 abort ();
2448 NEXT_INSN (insn) = next;
2449 PREV_INSN (insn) = after;
2451 if (next)
2453 PREV_INSN (next) = insn;
2454 if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2455 PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = insn;
2457 else if (last_insn == after)
2458 last_insn = insn;
2459 else
2461 struct sequence_stack *stack = sequence_stack;
2462 /* Scan all pending sequences too. */
2463 for (; stack; stack = stack->next)
2464 if (after == stack->last)
2466 stack->last = insn;
2467 break;
2470 if (stack == 0)
2471 abort ();
2474 NEXT_INSN (after) = insn;
2475 if (GET_CODE (after) == INSN && GET_CODE (PATTERN (after)) == SEQUENCE)
2477 rtx sequence = PATTERN (after);
2478 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2482 /* Add INSN into the doubly-linked list before insn BEFORE. This and
2483 the previous should be the only functions called to insert an insn once
2484 delay slots have been filled since only they know how to update a
2485 SEQUENCE. */
2487 void
2488 add_insn_before (insn, before)
2489 rtx insn, before;
2491 rtx prev = PREV_INSN (before);
2493 if (optimize && INSN_DELETED_P (before))
2494 abort ();
2496 PREV_INSN (insn) = prev;
2497 NEXT_INSN (insn) = before;
2499 if (prev)
2501 NEXT_INSN (prev) = insn;
2502 if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2504 rtx sequence = PATTERN (prev);
2505 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2508 else if (first_insn == before)
2509 first_insn = insn;
2510 else
2512 struct sequence_stack *stack = sequence_stack;
2513 /* Scan all pending sequences too. */
2514 for (; stack; stack = stack->next)
2515 if (before == stack->first)
2517 stack->first = insn;
2518 break;
2521 if (stack == 0)
2522 abort ();
2525 PREV_INSN (before) = insn;
2526 if (GET_CODE (before) == INSN && GET_CODE (PATTERN (before)) == SEQUENCE)
2527 PREV_INSN (XVECEXP (PATTERN (before), 0, 0)) = insn;
2530 /* Remove an insn from its doubly-linked list. This function knows how
2531 to handle sequences. */
2532 void
2533 remove_insn (insn)
2534 rtx insn;
2536 rtx next = NEXT_INSN (insn);
2537 rtx prev = PREV_INSN (insn);
2538 if (prev)
2540 NEXT_INSN (prev) = next;
2541 if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2543 rtx sequence = PATTERN (prev);
2544 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
2547 else if (first_insn == insn)
2548 first_insn = next;
2549 else
2551 struct sequence_stack *stack = sequence_stack;
2552 /* Scan all pending sequences too. */
2553 for (; stack; stack = stack->next)
2554 if (insn == stack->first)
2556 stack->first = next;
2557 break;
2560 if (stack == 0)
2561 abort ();
2564 if (next)
2566 PREV_INSN (next) = prev;
2567 if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2568 PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev;
2570 else if (last_insn == insn)
2571 last_insn = prev;
2572 else
2574 struct sequence_stack *stack = sequence_stack;
2575 /* Scan all pending sequences too. */
2576 for (; stack; stack = stack->next)
2577 if (insn == stack->last)
2579 stack->last = prev;
2580 break;
2583 if (stack == 0)
2584 abort ();
2588 /* Delete all insns made since FROM.
2589 FROM becomes the new last instruction. */
2591 void
2592 delete_insns_since (from)
2593 rtx from;
2595 if (from == 0)
2596 first_insn = 0;
2597 else
2598 NEXT_INSN (from) = 0;
2599 last_insn = from;
2602 /* This function is deprecated, please use sequences instead.
2604 Move a consecutive bunch of insns to a different place in the chain.
2605 The insns to be moved are those between FROM and TO.
2606 They are moved to a new position after the insn AFTER.
2607 AFTER must not be FROM or TO or any insn in between.
2609 This function does not know about SEQUENCEs and hence should not be
2610 called after delay-slot filling has been done. */
2612 void
2613 reorder_insns (from, to, after)
2614 rtx from, to, after;
2616 /* Splice this bunch out of where it is now. */
2617 if (PREV_INSN (from))
2618 NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
2619 if (NEXT_INSN (to))
2620 PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
2621 if (last_insn == to)
2622 last_insn = PREV_INSN (from);
2623 if (first_insn == from)
2624 first_insn = NEXT_INSN (to);
2626 /* Make the new neighbors point to it and it to them. */
2627 if (NEXT_INSN (after))
2628 PREV_INSN (NEXT_INSN (after)) = to;
2630 NEXT_INSN (to) = NEXT_INSN (after);
2631 PREV_INSN (from) = after;
2632 NEXT_INSN (after) = from;
2633 if (after == last_insn)
2634 last_insn = to;
2637 /* Return the line note insn preceding INSN. */
2639 static rtx
2640 find_line_note (insn)
2641 rtx insn;
2643 if (no_line_numbers)
2644 return 0;
2646 for (; insn; insn = PREV_INSN (insn))
2647 if (GET_CODE (insn) == NOTE
2648 && NOTE_LINE_NUMBER (insn) >= 0)
2649 break;
2651 return insn;
2654 /* Like reorder_insns, but inserts line notes to preserve the line numbers
2655 of the moved insns when debugging. This may insert a note between AFTER
2656 and FROM, and another one after TO. */
2658 void
2659 reorder_insns_with_line_notes (from, to, after)
2660 rtx from, to, after;
2662 rtx from_line = find_line_note (from);
2663 rtx after_line = find_line_note (after);
2665 reorder_insns (from, to, after);
2667 if (from_line == after_line)
2668 return;
2670 if (from_line)
2671 emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2672 NOTE_LINE_NUMBER (from_line),
2673 after);
2674 if (after_line)
2675 emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2676 NOTE_LINE_NUMBER (after_line),
2677 to);
2680 /* Emit an insn of given code and pattern
2681 at a specified place within the doubly-linked list. */
2683 /* Make an instruction with body PATTERN
2684 and output it before the instruction BEFORE. */
2687 emit_insn_before (pattern, before)
2688 register rtx pattern, before;
2690 register rtx insn = before;
2692 if (GET_CODE (pattern) == SEQUENCE)
2694 register int i;
2696 for (i = 0; i < XVECLEN (pattern, 0); i++)
2698 insn = XVECEXP (pattern, 0, i);
2699 add_insn_before (insn, before);
2701 if (XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2702 sequence_result[XVECLEN (pattern, 0)] = pattern;
2704 else
2706 insn = make_insn_raw (pattern);
2707 add_insn_before (insn, before);
2710 return insn;
2713 /* Make an instruction with body PATTERN and code JUMP_INSN
2714 and output it before the instruction BEFORE. */
2717 emit_jump_insn_before (pattern, before)
2718 register rtx pattern, before;
2720 register rtx insn;
2722 if (GET_CODE (pattern) == SEQUENCE)
2723 insn = emit_insn_before (pattern, before);
2724 else
2726 insn = make_jump_insn_raw (pattern);
2727 add_insn_before (insn, before);
2730 return insn;
2733 /* Make an instruction with body PATTERN and code CALL_INSN
2734 and output it before the instruction BEFORE. */
2737 emit_call_insn_before (pattern, before)
2738 register rtx pattern, before;
2740 register rtx insn;
2742 if (GET_CODE (pattern) == SEQUENCE)
2743 insn = emit_insn_before (pattern, before);
2744 else
2746 insn = make_call_insn_raw (pattern);
2747 add_insn_before (insn, before);
2748 PUT_CODE (insn, CALL_INSN);
2751 return insn;
2754 /* Make an insn of code BARRIER
2755 and output it before the insn BEFORE. */
2758 emit_barrier_before (before)
2759 register rtx before;
2761 register rtx insn = rtx_alloc (BARRIER);
2763 INSN_UID (insn) = cur_insn_uid++;
2765 add_insn_before (insn, before);
2766 return insn;
2769 /* Emit the label LABEL before the insn BEFORE. */
2772 emit_label_before (label, before)
2773 rtx label, before;
2775 /* This can be called twice for the same label as a result of the
2776 confusion that follows a syntax error! So make it harmless. */
2777 if (INSN_UID (label) == 0)
2779 INSN_UID (label) = cur_insn_uid++;
2780 add_insn_before (label, before);
2783 return label;
2786 /* Emit a note of subtype SUBTYPE before the insn BEFORE. */
2789 emit_note_before (subtype, before)
2790 int subtype;
2791 rtx before;
2793 register rtx note = rtx_alloc (NOTE);
2794 INSN_UID (note) = cur_insn_uid++;
2795 NOTE_SOURCE_FILE (note) = 0;
2796 NOTE_LINE_NUMBER (note) = subtype;
2798 add_insn_before (note, before);
2799 return note;
2802 /* Make an insn of code INSN with body PATTERN
2803 and output it after the insn AFTER. */
2806 emit_insn_after (pattern, after)
2807 register rtx pattern, after;
2809 register rtx insn = after;
2811 if (GET_CODE (pattern) == SEQUENCE)
2813 register int i;
2815 for (i = 0; i < XVECLEN (pattern, 0); i++)
2817 insn = XVECEXP (pattern, 0, i);
2818 add_insn_after (insn, after);
2819 after = insn;
2821 if (XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2822 sequence_result[XVECLEN (pattern, 0)] = pattern;
2824 else
2826 insn = make_insn_raw (pattern);
2827 add_insn_after (insn, after);
2830 return insn;
2833 /* Similar to emit_insn_after, except that line notes are to be inserted so
2834 as to act as if this insn were at FROM. */
2836 void
2837 emit_insn_after_with_line_notes (pattern, after, from)
2838 rtx pattern, after, from;
2840 rtx from_line = find_line_note (from);
2841 rtx after_line = find_line_note (after);
2842 rtx insn = emit_insn_after (pattern, after);
2844 if (from_line)
2845 emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2846 NOTE_LINE_NUMBER (from_line),
2847 after);
2849 if (after_line)
2850 emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2851 NOTE_LINE_NUMBER (after_line),
2852 insn);
2855 /* Make an insn of code JUMP_INSN with body PATTERN
2856 and output it after the insn AFTER. */
2859 emit_jump_insn_after (pattern, after)
2860 register rtx pattern, after;
2862 register rtx insn;
2864 if (GET_CODE (pattern) == SEQUENCE)
2865 insn = emit_insn_after (pattern, after);
2866 else
2868 insn = make_jump_insn_raw (pattern);
2869 add_insn_after (insn, after);
2872 return insn;
2875 /* Make an insn of code BARRIER
2876 and output it after the insn AFTER. */
2879 emit_barrier_after (after)
2880 register rtx after;
2882 register rtx insn = rtx_alloc (BARRIER);
2884 INSN_UID (insn) = cur_insn_uid++;
2886 add_insn_after (insn, after);
2887 return insn;
2890 /* Emit the label LABEL after the insn AFTER. */
2893 emit_label_after (label, after)
2894 rtx label, after;
2896 /* This can be called twice for the same label
2897 as a result of the confusion that follows a syntax error!
2898 So make it harmless. */
2899 if (INSN_UID (label) == 0)
2901 INSN_UID (label) = cur_insn_uid++;
2902 add_insn_after (label, after);
2905 return label;
2908 /* Emit a note of subtype SUBTYPE after the insn AFTER. */
2911 emit_note_after (subtype, after)
2912 int subtype;
2913 rtx after;
2915 register rtx note = rtx_alloc (NOTE);
2916 INSN_UID (note) = cur_insn_uid++;
2917 NOTE_SOURCE_FILE (note) = 0;
2918 NOTE_LINE_NUMBER (note) = subtype;
2919 add_insn_after (note, after);
2920 return note;
2923 /* Emit a line note for FILE and LINE after the insn AFTER. */
2926 emit_line_note_after (file, line, after)
2927 char *file;
2928 int line;
2929 rtx after;
2931 register rtx note;
2933 if (no_line_numbers && line > 0)
2935 cur_insn_uid++;
2936 return 0;
2939 note = rtx_alloc (NOTE);
2940 INSN_UID (note) = cur_insn_uid++;
2941 NOTE_SOURCE_FILE (note) = file;
2942 NOTE_LINE_NUMBER (note) = line;
2943 add_insn_after (note, after);
2944 return note;
2947 /* Make an insn of code INSN with pattern PATTERN
2948 and add it to the end of the doubly-linked list.
2949 If PATTERN is a SEQUENCE, take the elements of it
2950 and emit an insn for each element.
2952 Returns the last insn emitted. */
2955 emit_insn (pattern)
2956 rtx pattern;
2958 rtx insn = last_insn;
2960 if (GET_CODE (pattern) == SEQUENCE)
2962 register int i;
2964 for (i = 0; i < XVECLEN (pattern, 0); i++)
2966 insn = XVECEXP (pattern, 0, i);
2967 add_insn (insn);
2969 if (XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2970 sequence_result[XVECLEN (pattern, 0)] = pattern;
2972 else
2974 insn = make_insn_raw (pattern);
2975 add_insn (insn);
2978 return insn;
2981 /* Emit the insns in a chain starting with INSN.
2982 Return the last insn emitted. */
2985 emit_insns (insn)
2986 rtx insn;
2988 rtx last = 0;
2990 while (insn)
2992 rtx next = NEXT_INSN (insn);
2993 add_insn (insn);
2994 last = insn;
2995 insn = next;
2998 return last;
3001 /* Emit the insns in a chain starting with INSN and place them in front of
3002 the insn BEFORE. Return the last insn emitted. */
3005 emit_insns_before (insn, before)
3006 rtx insn;
3007 rtx before;
3009 rtx last = 0;
3011 while (insn)
3013 rtx next = NEXT_INSN (insn);
3014 add_insn_before (insn, before);
3015 last = insn;
3016 insn = next;
3019 return last;
3022 /* Emit the insns in a chain starting with FIRST and place them in back of
3023 the insn AFTER. Return the last insn emitted. */
3026 emit_insns_after (first, after)
3027 register rtx first;
3028 register rtx after;
3030 register rtx last;
3031 register rtx after_after;
3033 if (!after)
3034 abort ();
3036 if (!first)
3037 return first;
3039 for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
3040 continue;
3042 after_after = NEXT_INSN (after);
3044 NEXT_INSN (after) = first;
3045 PREV_INSN (first) = after;
3046 NEXT_INSN (last) = after_after;
3047 if (after_after)
3048 PREV_INSN (after_after) = last;
3050 if (after == last_insn)
3051 last_insn = last;
3052 return last;
3055 /* Make an insn of code JUMP_INSN with pattern PATTERN
3056 and add it to the end of the doubly-linked list. */
3059 emit_jump_insn (pattern)
3060 rtx pattern;
3062 if (GET_CODE (pattern) == SEQUENCE)
3063 return emit_insn (pattern);
3064 else
3066 register rtx insn = make_jump_insn_raw (pattern);
3067 add_insn (insn);
3068 return insn;
3072 /* Make an insn of code CALL_INSN with pattern PATTERN
3073 and add it to the end of the doubly-linked list. */
3076 emit_call_insn (pattern)
3077 rtx pattern;
3079 if (GET_CODE (pattern) == SEQUENCE)
3080 return emit_insn (pattern);
3081 else
3083 register rtx insn = make_call_insn_raw (pattern);
3084 add_insn (insn);
3085 PUT_CODE (insn, CALL_INSN);
3086 return insn;
3090 /* Add the label LABEL to the end of the doubly-linked list. */
3093 emit_label (label)
3094 rtx label;
3096 /* This can be called twice for the same label
3097 as a result of the confusion that follows a syntax error!
3098 So make it harmless. */
3099 if (INSN_UID (label) == 0)
3101 INSN_UID (label) = cur_insn_uid++;
3102 add_insn (label);
3104 return label;
3107 /* Make an insn of code BARRIER
3108 and add it to the end of the doubly-linked list. */
3111 emit_barrier ()
3113 register rtx barrier = rtx_alloc (BARRIER);
3114 INSN_UID (barrier) = cur_insn_uid++;
3115 add_insn (barrier);
3116 return barrier;
3119 /* Make an insn of code NOTE
3120 with data-fields specified by FILE and LINE
3121 and add it to the end of the doubly-linked list,
3122 but only if line-numbers are desired for debugging info. */
3125 emit_line_note (file, line)
3126 char *file;
3127 int line;
3129 emit_filename = file;
3130 emit_lineno = line;
3132 #if 0
3133 if (no_line_numbers)
3134 return 0;
3135 #endif
3137 return emit_note (file, line);
3140 /* Make an insn of code NOTE
3141 with data-fields specified by FILE and LINE
3142 and add it to the end of the doubly-linked list.
3143 If it is a line-number NOTE, omit it if it matches the previous one. */
3146 emit_note (file, line)
3147 char *file;
3148 int line;
3150 register rtx note;
3152 if (line > 0)
3154 if (file && last_filename && !strcmp (file, last_filename)
3155 && line == last_linenum)
3156 return 0;
3157 last_filename = file;
3158 last_linenum = line;
3161 if (no_line_numbers && line > 0)
3163 cur_insn_uid++;
3164 return 0;
3167 note = rtx_alloc (NOTE);
3168 INSN_UID (note) = cur_insn_uid++;
3169 NOTE_SOURCE_FILE (note) = file;
3170 NOTE_LINE_NUMBER (note) = line;
3171 add_insn (note);
3172 return note;
3175 /* Emit a NOTE, and don't omit it even if LINE is the previous note. */
3178 emit_line_note_force (file, line)
3179 char *file;
3180 int line;
3182 last_linenum = -1;
3183 return emit_line_note (file, line);
3186 /* Cause next statement to emit a line note even if the line number
3187 has not changed. This is used at the beginning of a function. */
3189 void
3190 force_next_line_note ()
3192 last_linenum = -1;
3195 /* Place a note of KIND on insn INSN with DATUM as the datum. If a
3196 note of this type already exists, remove it first. */
3198 void
3199 set_unique_reg_note (insn, kind, datum)
3200 rtx insn;
3201 enum reg_note kind;
3202 rtx datum;
3204 rtx note = find_reg_note (insn, kind, NULL_RTX);
3206 /* First remove the note if there already is one. */
3207 if (note)
3208 remove_note (insn, note);
3210 REG_NOTES (insn) = gen_rtx_EXPR_LIST (kind, datum, REG_NOTES (insn));
3213 /* Return an indication of which type of insn should have X as a body.
3214 The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN. */
3216 enum rtx_code
3217 classify_insn (x)
3218 rtx x;
3220 if (GET_CODE (x) == CODE_LABEL)
3221 return CODE_LABEL;
3222 if (GET_CODE (x) == CALL)
3223 return CALL_INSN;
3224 if (GET_CODE (x) == RETURN)
3225 return JUMP_INSN;
3226 if (GET_CODE (x) == SET)
3228 if (SET_DEST (x) == pc_rtx)
3229 return JUMP_INSN;
3230 else if (GET_CODE (SET_SRC (x)) == CALL)
3231 return CALL_INSN;
3232 else
3233 return INSN;
3235 if (GET_CODE (x) == PARALLEL)
3237 register int j;
3238 for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
3239 if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
3240 return CALL_INSN;
3241 else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3242 && SET_DEST (XVECEXP (x, 0, j)) == pc_rtx)
3243 return JUMP_INSN;
3244 else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3245 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
3246 return CALL_INSN;
3248 return INSN;
3251 /* Emit the rtl pattern X as an appropriate kind of insn.
3252 If X is a label, it is simply added into the insn chain. */
3255 emit (x)
3256 rtx x;
3258 enum rtx_code code = classify_insn (x);
3260 if (code == CODE_LABEL)
3261 return emit_label (x);
3262 else if (code == INSN)
3263 return emit_insn (x);
3264 else if (code == JUMP_INSN)
3266 register rtx insn = emit_jump_insn (x);
3267 if (simplejump_p (insn) || GET_CODE (x) == RETURN)
3268 return emit_barrier ();
3269 return insn;
3271 else if (code == CALL_INSN)
3272 return emit_call_insn (x);
3273 else
3274 abort ();
3277 /* Begin emitting insns to a sequence which can be packaged in an RTL_EXPR. */
3279 void
3280 start_sequence ()
3282 struct sequence_stack *tem;
3284 if (sequence_element_free_list)
3286 /* Reuse a previously-saved struct sequence_stack. */
3287 tem = sequence_element_free_list;
3288 sequence_element_free_list = tem->next;
3290 else
3291 tem = (struct sequence_stack *) permalloc (sizeof (struct sequence_stack));
3293 tem->next = sequence_stack;
3294 tem->first = first_insn;
3295 tem->last = last_insn;
3296 tem->sequence_rtl_expr = sequence_rtl_expr;
3298 sequence_stack = tem;
3300 first_insn = 0;
3301 last_insn = 0;
3304 /* Similarly, but indicate that this sequence will be placed in
3305 T, an RTL_EXPR. */
3307 void
3308 start_sequence_for_rtl_expr (t)
3309 tree t;
3311 start_sequence ();
3313 sequence_rtl_expr = t;
3316 /* Set up the insn chain starting with FIRST
3317 as the current sequence, saving the previously current one. */
3319 void
3320 push_to_sequence (first)
3321 rtx first;
3323 rtx last;
3325 start_sequence ();
3327 for (last = first; last && NEXT_INSN (last); last = NEXT_INSN (last));
3329 first_insn = first;
3330 last_insn = last;
3333 /* Set up the outer-level insn chain
3334 as the current sequence, saving the previously current one. */
3336 void
3337 push_topmost_sequence ()
3339 struct sequence_stack *stack, *top = NULL;
3341 start_sequence ();
3343 for (stack = sequence_stack; stack; stack = stack->next)
3344 top = stack;
3346 first_insn = top->first;
3347 last_insn = top->last;
3348 sequence_rtl_expr = top->sequence_rtl_expr;
3351 /* After emitting to the outer-level insn chain, update the outer-level
3352 insn chain, and restore the previous saved state. */
3354 void
3355 pop_topmost_sequence ()
3357 struct sequence_stack *stack, *top = NULL;
3359 for (stack = sequence_stack; stack; stack = stack->next)
3360 top = stack;
3362 top->first = first_insn;
3363 top->last = last_insn;
3364 /* ??? Why don't we save sequence_rtl_expr here? */
3366 end_sequence ();
3369 /* After emitting to a sequence, restore previous saved state.
3371 To get the contents of the sequence just made,
3372 you must call `gen_sequence' *before* calling here. */
3374 void
3375 end_sequence ()
3377 struct sequence_stack *tem = sequence_stack;
3379 first_insn = tem->first;
3380 last_insn = tem->last;
3381 sequence_rtl_expr = tem->sequence_rtl_expr;
3382 sequence_stack = tem->next;
3384 tem->next = sequence_element_free_list;
3385 sequence_element_free_list = tem;
3388 /* Return 1 if currently emitting into a sequence. */
3391 in_sequence_p ()
3393 return sequence_stack != 0;
3396 /* Generate a SEQUENCE rtx containing the insns already emitted
3397 to the current sequence.
3399 This is how the gen_... function from a DEFINE_EXPAND
3400 constructs the SEQUENCE that it returns. */
3403 gen_sequence ()
3405 rtx result;
3406 rtx tem;
3407 int i;
3408 int len;
3410 /* Count the insns in the chain. */
3411 len = 0;
3412 for (tem = first_insn; tem; tem = NEXT_INSN (tem))
3413 len++;
3415 /* If only one insn, return its pattern rather than a SEQUENCE.
3416 (Now that we cache SEQUENCE expressions, it isn't worth special-casing
3417 the case of an empty list.) */
3418 if (len == 1
3419 && ! RTX_FRAME_RELATED_P (first_insn)
3420 && (GET_CODE (first_insn) == INSN
3421 || GET_CODE (first_insn) == JUMP_INSN
3422 /* Don't discard the call usage field. */
3423 || (GET_CODE (first_insn) == CALL_INSN
3424 && CALL_INSN_FUNCTION_USAGE (first_insn) == NULL_RTX)))
3426 NEXT_INSN (first_insn) = free_insn;
3427 free_insn = first_insn;
3428 return PATTERN (first_insn);
3431 /* Put them in a vector. See if we already have a SEQUENCE of the
3432 appropriate length around. */
3433 if (len < SEQUENCE_RESULT_SIZE && (result = sequence_result[len]) != 0)
3434 sequence_result[len] = 0;
3435 else
3437 /* Ensure that this rtl goes in saveable_obstack, since we may
3438 cache it. */
3439 push_obstacks_nochange ();
3440 rtl_in_saveable_obstack ();
3441 result = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (len));
3442 pop_obstacks ();
3445 for (i = 0, tem = first_insn; tem; tem = NEXT_INSN (tem), i++)
3446 XVECEXP (result, 0, i) = tem;
3448 return result;
3451 /* Put the various virtual registers into REGNO_REG_RTX. */
3453 void
3454 init_virtual_regs ()
3456 regno_reg_rtx[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
3457 regno_reg_rtx[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
3458 regno_reg_rtx[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
3459 regno_reg_rtx[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
3460 regno_reg_rtx[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
3463 /* Initialize data structures and variables in this file
3464 before generating rtl for each function. */
3466 void
3467 init_emit ()
3469 int i;
3471 first_insn = NULL;
3472 last_insn = NULL;
3473 sequence_rtl_expr = NULL;
3474 cur_insn_uid = 1;
3475 reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
3476 last_linenum = 0;
3477 last_filename = 0;
3478 first_label_num = label_num;
3479 last_label_num = 0;
3480 sequence_stack = NULL;
3482 /* Clear the start_sequence/gen_sequence cache. */
3483 sequence_element_free_list = 0;
3484 for (i = 0; i < SEQUENCE_RESULT_SIZE; i++)
3485 sequence_result[i] = 0;
3486 free_insn = 0;
3488 /* Init the tables that describe all the pseudo regs. */
3490 regno_pointer_flag_length = LAST_VIRTUAL_REGISTER + 101;
3492 regno_pointer_flag
3493 = (char *) savealloc (regno_pointer_flag_length);
3494 bzero (regno_pointer_flag, regno_pointer_flag_length);
3496 regno_pointer_align
3497 = (char *) savealloc (regno_pointer_flag_length);
3498 bzero (regno_pointer_align, regno_pointer_flag_length);
3500 regno_reg_rtx
3501 = (rtx *) savealloc (regno_pointer_flag_length * sizeof (rtx));
3502 bzero ((char *) regno_reg_rtx, regno_pointer_flag_length * sizeof (rtx));
3504 /* Put copies of all the virtual register rtx into regno_reg_rtx. */
3505 init_virtual_regs ();
3507 /* Indicate that the virtual registers and stack locations are
3508 all pointers. */
3509 REGNO_POINTER_FLAG (STACK_POINTER_REGNUM) = 1;
3510 REGNO_POINTER_FLAG (FRAME_POINTER_REGNUM) = 1;
3511 REGNO_POINTER_FLAG (HARD_FRAME_POINTER_REGNUM) = 1;
3512 REGNO_POINTER_FLAG (ARG_POINTER_REGNUM) = 1;
3514 REGNO_POINTER_FLAG (VIRTUAL_INCOMING_ARGS_REGNUM) = 1;
3515 REGNO_POINTER_FLAG (VIRTUAL_STACK_VARS_REGNUM) = 1;
3516 REGNO_POINTER_FLAG (VIRTUAL_STACK_DYNAMIC_REGNUM) = 1;
3517 REGNO_POINTER_FLAG (VIRTUAL_OUTGOING_ARGS_REGNUM) = 1;
3518 REGNO_POINTER_FLAG (VIRTUAL_CFA_REGNUM) = 1;
3520 #ifdef STACK_BOUNDARY
3521 REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3522 REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3523 REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM)
3524 = STACK_BOUNDARY / BITS_PER_UNIT;
3525 REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3527 REGNO_POINTER_ALIGN (VIRTUAL_INCOMING_ARGS_REGNUM)
3528 = STACK_BOUNDARY / BITS_PER_UNIT;
3529 REGNO_POINTER_ALIGN (VIRTUAL_STACK_VARS_REGNUM)
3530 = STACK_BOUNDARY / BITS_PER_UNIT;
3531 REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM)
3532 = STACK_BOUNDARY / BITS_PER_UNIT;
3533 REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM)
3534 = STACK_BOUNDARY / BITS_PER_UNIT;
3535 REGNO_POINTER_ALIGN (VIRTUAL_CFA_REGNUM) = UNITS_PER_WORD;
3536 #endif
3538 #ifdef INIT_EXPANDERS
3539 INIT_EXPANDERS;
3540 #endif
3543 /* Create some permanent unique rtl objects shared between all functions.
3544 LINE_NUMBERS is nonzero if line numbers are to be generated. */
3546 void
3547 init_emit_once (line_numbers)
3548 int line_numbers;
3550 int i;
3551 enum machine_mode mode;
3552 enum machine_mode double_mode;
3554 no_line_numbers = ! line_numbers;
3556 sequence_stack = NULL;
3558 /* Compute the word and byte modes. */
3560 byte_mode = VOIDmode;
3561 word_mode = VOIDmode;
3562 double_mode = VOIDmode;
3564 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3565 mode = GET_MODE_WIDER_MODE (mode))
3567 if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
3568 && byte_mode == VOIDmode)
3569 byte_mode = mode;
3571 if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
3572 && word_mode == VOIDmode)
3573 word_mode = mode;
3576 #ifndef DOUBLE_TYPE_SIZE
3577 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
3578 #endif
3580 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3581 mode = GET_MODE_WIDER_MODE (mode))
3583 if (GET_MODE_BITSIZE (mode) == DOUBLE_TYPE_SIZE
3584 && double_mode == VOIDmode)
3585 double_mode = mode;
3588 ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0);
3590 /* Create the unique rtx's for certain rtx codes and operand values. */
3592 for (i = - MAX_SAVED_CONST_INT; i <= MAX_SAVED_CONST_INT; i++)
3594 PUT_CODE (&const_int_rtx[i + MAX_SAVED_CONST_INT], CONST_INT);
3595 PUT_MODE (&const_int_rtx[i + MAX_SAVED_CONST_INT], VOIDmode);
3596 INTVAL (&const_int_rtx[i + MAX_SAVED_CONST_INT]) = i;
3599 if (STORE_FLAG_VALUE >= - MAX_SAVED_CONST_INT
3600 && STORE_FLAG_VALUE <= MAX_SAVED_CONST_INT)
3601 const_true_rtx = &const_int_rtx[STORE_FLAG_VALUE + MAX_SAVED_CONST_INT];
3602 else
3603 const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
3605 dconst0 = REAL_VALUE_ATOF ("0", double_mode);
3606 dconst1 = REAL_VALUE_ATOF ("1", double_mode);
3607 dconst2 = REAL_VALUE_ATOF ("2", double_mode);
3608 dconstm1 = REAL_VALUE_ATOF ("-1", double_mode);
3610 for (i = 0; i <= 2; i++)
3612 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3613 mode = GET_MODE_WIDER_MODE (mode))
3615 rtx tem = rtx_alloc (CONST_DOUBLE);
3616 union real_extract u;
3618 bzero ((char *) &u, sizeof u); /* Zero any holes in a structure. */
3619 u.d = i == 0 ? dconst0 : i == 1 ? dconst1 : dconst2;
3621 bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (tem), sizeof u);
3622 CONST_DOUBLE_MEM (tem) = cc0_rtx;
3623 PUT_MODE (tem, mode);
3625 const_tiny_rtx[i][(int) mode] = tem;
3628 const_tiny_rtx[i][(int) VOIDmode] = GEN_INT (i);
3630 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3631 mode = GET_MODE_WIDER_MODE (mode))
3632 const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3634 for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT);
3635 mode != VOIDmode;
3636 mode = GET_MODE_WIDER_MODE (mode))
3637 const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3640 for (mode = GET_CLASS_NARROWEST_MODE (MODE_CC); mode != VOIDmode;
3641 mode = GET_MODE_WIDER_MODE (mode))
3642 const_tiny_rtx[0][(int) mode] = const0_rtx;
3645 /* Assign register numbers to the globally defined register rtx.
3646 This must be done at runtime because the register number field
3647 is in a union and some compilers can't initialize unions. */
3649 REGNO (stack_pointer_rtx) = STACK_POINTER_REGNUM;
3650 PUT_MODE (stack_pointer_rtx, Pmode);
3651 REGNO (frame_pointer_rtx) = FRAME_POINTER_REGNUM;
3652 PUT_MODE (frame_pointer_rtx, Pmode);
3653 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
3654 REGNO (hard_frame_pointer_rtx) = HARD_FRAME_POINTER_REGNUM;
3655 PUT_MODE (hard_frame_pointer_rtx, Pmode);
3656 #endif
3657 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3658 REGNO (arg_pointer_rtx) = ARG_POINTER_REGNUM;
3659 PUT_MODE (arg_pointer_rtx, Pmode);
3660 #endif
3662 REGNO (virtual_incoming_args_rtx) = VIRTUAL_INCOMING_ARGS_REGNUM;
3663 PUT_MODE (virtual_incoming_args_rtx, Pmode);
3664 REGNO (virtual_stack_vars_rtx) = VIRTUAL_STACK_VARS_REGNUM;
3665 PUT_MODE (virtual_stack_vars_rtx, Pmode);
3666 REGNO (virtual_stack_dynamic_rtx) = VIRTUAL_STACK_DYNAMIC_REGNUM;
3667 PUT_MODE (virtual_stack_dynamic_rtx, Pmode);
3668 REGNO (virtual_outgoing_args_rtx) = VIRTUAL_OUTGOING_ARGS_REGNUM;
3669 PUT_MODE (virtual_outgoing_args_rtx, Pmode);
3670 REGNO (virtual_cfa_rtx) = VIRTUAL_CFA_REGNUM;
3671 PUT_MODE (virtual_cfa_rtx, Pmode);
3673 #ifdef RETURN_ADDRESS_POINTER_REGNUM
3674 return_address_pointer_rtx
3675 = gen_rtx_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
3676 #endif
3678 #ifdef STRUCT_VALUE
3679 struct_value_rtx = STRUCT_VALUE;
3680 #else
3681 struct_value_rtx = gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM);
3682 #endif
3684 #ifdef STRUCT_VALUE_INCOMING
3685 struct_value_incoming_rtx = STRUCT_VALUE_INCOMING;
3686 #else
3687 #ifdef STRUCT_VALUE_INCOMING_REGNUM
3688 struct_value_incoming_rtx
3689 = gen_rtx_REG (Pmode, STRUCT_VALUE_INCOMING_REGNUM);
3690 #else
3691 struct_value_incoming_rtx = struct_value_rtx;
3692 #endif
3693 #endif
3695 #ifdef STATIC_CHAIN_REGNUM
3696 static_chain_rtx = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
3698 #ifdef STATIC_CHAIN_INCOMING_REGNUM
3699 if (STATIC_CHAIN_INCOMING_REGNUM != STATIC_CHAIN_REGNUM)
3700 static_chain_incoming_rtx = gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
3701 else
3702 #endif
3703 static_chain_incoming_rtx = static_chain_rtx;
3704 #endif
3706 #ifdef STATIC_CHAIN
3707 static_chain_rtx = STATIC_CHAIN;
3709 #ifdef STATIC_CHAIN_INCOMING
3710 static_chain_incoming_rtx = STATIC_CHAIN_INCOMING;
3711 #else
3712 static_chain_incoming_rtx = static_chain_rtx;
3713 #endif
3714 #endif
3716 #ifdef PIC_OFFSET_TABLE_REGNUM
3717 pic_offset_table_rtx = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
3718 #endif
3720 #ifdef INIT_EXPANDERS
3721 /* This is to initialize save_machine_status and restore_machine_status before
3722 the first call to push_function_context_to. This is needed by the Chill
3723 front end which calls push_function_context_to before the first cal to
3724 init_function_start. */
3725 INIT_EXPANDERS;
3726 #endif
3729 /* Query and clear/ restore no_line_numbers. This is used by the
3730 switch / case handling in stmt.c to give proper line numbers in
3731 warnings about unreachable code. */
3734 force_line_numbers ()
3736 int old = no_line_numbers;
3738 no_line_numbers = 0;
3739 if (old)
3740 force_next_line_note ();
3741 return old;
3744 void
3745 restore_line_number_status (old_value)
3746 int old_value;
3748 no_line_numbers = old_value;