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)
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. */
46 #include "hard-reg-set.h"
47 #include "insn-config.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. */
62 /* This is *not* reset after each function. It gives each CODE_LABEL
63 in the entire compilation a unique label number. */
65 static int label_num = 1;
67 /* Highest label number in current function.
68 Zero means use the value of label_num instead.
69 This is nonzero only when belatedly compiling an inline function. */
71 static int last_label_num;
73 /* Value label_num had when set_new_first_and_last_label_number was called.
74 If label_num has not changed since then, last_label_num is valid. */
76 static int base_label_num;
78 /* Nonzero means do not generate NOTEs for source line numbers. */
80 static int no_line_numbers;
82 /* Commonly used rtx's, so that we only need space for one copy.
83 These are initialized once for the entire compilation.
84 All of these except perhaps the floating-point CONST_DOUBLEs
85 are unique; no other rtx-object will be equal to any of these. */
87 /* Avoid warnings by initializing the `fld' field. Since its a union,
88 bypass problems with KNR compilers by only doing so when __GNUC__. */
95 struct _global_rtl global_rtl =
97 {PC, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* pc_rtx */
98 {CC0, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* cc0_rtx */
99 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* stack_pointer_rtx */
100 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* frame_pointer_rtx */
101 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* hard_frame_pointer_rtx */
102 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* arg_pointer_rtx */
103 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_incoming_args_rtx */
104 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_stack_vars_rtx */
105 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_stack_dynamic_rtx */
106 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_outgoing_args_rtx */
107 {REG, VOIDmode, 0, 0, 0, 0, 0, 0, 0, 0, 0 FLDI }, /* virtual_cfa_rtx */
110 /* We record floating-point CONST_DOUBLEs in each floating-point mode for
111 the values of 0, 1, and 2. For the integer entries and VOIDmode, we
112 record a copy of const[012]_rtx. */
114 rtx const_tiny_rtx[3][(int) MAX_MACHINE_MODE];
118 REAL_VALUE_TYPE dconst0;
119 REAL_VALUE_TYPE dconst1;
120 REAL_VALUE_TYPE dconst2;
121 REAL_VALUE_TYPE dconstm1;
123 /* All references to the following fixed hard registers go through
124 these unique rtl objects. On machines where the frame-pointer and
125 arg-pointer are the same register, they use the same unique object.
127 After register allocation, other rtl objects which used to be pseudo-regs
128 may be clobbered to refer to the frame-pointer register.
129 But references that were originally to the frame-pointer can be
130 distinguished from the others because they contain frame_pointer_rtx.
132 When to use frame_pointer_rtx and hard_frame_pointer_rtx is a little
133 tricky: until register elimination has taken place hard_frame_pointer_rtx
134 should be used if it is being set, and frame_pointer_rtx otherwise. After
135 register elimination hard_frame_pointer_rtx should always be used.
136 On machines where the two registers are same (most) then these are the
139 In an inline procedure, the stack and frame pointer rtxs may not be
140 used for anything else. */
141 rtx struct_value_rtx; /* (REG:Pmode STRUCT_VALUE_REGNUM) */
142 rtx struct_value_incoming_rtx; /* (REG:Pmode STRUCT_VALUE_INCOMING_REGNUM) */
143 rtx static_chain_rtx; /* (REG:Pmode STATIC_CHAIN_REGNUM) */
144 rtx static_chain_incoming_rtx; /* (REG:Pmode STATIC_CHAIN_INCOMING_REGNUM) */
145 rtx pic_offset_table_rtx; /* (REG:Pmode PIC_OFFSET_TABLE_REGNUM) */
147 /* This is used to implement __builtin_return_address for some machines.
148 See for instance the MIPS port. */
149 rtx return_address_pointer_rtx; /* (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM) */
151 /* We make one copy of (const_int C) where C is in
152 [- MAX_SAVED_CONST_INT, MAX_SAVED_CONST_INT]
153 to save space during the compilation and simplify comparisons of
156 struct rtx_def const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
158 /* start_sequence and gen_sequence can make a lot of rtx expressions which are
159 shortly thrown away. We use two mechanisms to prevent this waste:
161 For sizes up to 5 elements, we keep a SEQUENCE and its associated
162 rtvec for use by gen_sequence. One entry for each size is
163 sufficient because most cases are calls to gen_sequence followed by
164 immediately emitting the SEQUENCE. Reuse is safe since emitting a
165 sequence is destructive on the insn in it anyway and hence can't be
168 We do not bother to save this cached data over nested function calls.
169 Instead, we just reinitialize them. */
171 #define SEQUENCE_RESULT_SIZE 5
173 static rtx sequence_result[SEQUENCE_RESULT_SIZE];
175 /* During RTL generation, we also keep a list of free INSN rtl codes. */
176 static rtx free_insn;
178 #define first_insn (current_function->emit->x_first_insn)
179 #define last_insn (current_function->emit->x_last_insn)
180 #define cur_insn_uid (current_function->emit->x_cur_insn_uid)
181 #define last_linenum (current_function->emit->x_last_linenum)
182 #define last_filename (current_function->emit->x_last_filename)
183 #define first_label_num (current_function->emit->x_first_label_num)
185 static rtx make_jump_insn_raw PROTO((rtx));
186 static rtx make_call_insn_raw PROTO((rtx));
187 static rtx find_line_note PROTO((rtx));
188 static void mark_sequence_stack PROTO((struct sequence_stack *));
190 /* There are some RTL codes that require special attention; the generation
191 functions do the raw handling. If you add to this list, modify
192 special_rtx in gengenrtl.c as well. */
195 gen_rtx_CONST_INT (mode, arg)
196 enum machine_mode mode;
199 if (arg >= - MAX_SAVED_CONST_INT && arg <= MAX_SAVED_CONST_INT)
200 return &const_int_rtx[arg + MAX_SAVED_CONST_INT];
202 #if STORE_FLAG_VALUE != 1 && STORE_FLAG_VALUE != -1
203 if (const_true_rtx && arg == STORE_FLAG_VALUE)
204 return const_true_rtx;
207 return gen_rtx_raw_CONST_INT (mode, arg);
210 /* CONST_DOUBLEs needs special handling because its length is known
213 gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2)
214 enum machine_mode mode;
216 HOST_WIDE_INT arg1, arg2;
218 rtx r = rtx_alloc (CONST_DOUBLE);
223 X0EXP (r, 1) = NULL_RTX;
227 for (i = GET_RTX_LENGTH (CONST_DOUBLE) - 1; i > 3; --i)
234 gen_rtx_REG (mode, regno)
235 enum machine_mode mode;
238 /* In case the MD file explicitly references the frame pointer, have
239 all such references point to the same frame pointer. This is
240 used during frame pointer elimination to distinguish the explicit
241 references to these registers from pseudos that happened to be
244 If we have eliminated the frame pointer or arg pointer, we will
245 be using it as a normal register, for example as a spill
246 register. In such cases, we might be accessing it in a mode that
247 is not Pmode and therefore cannot use the pre-allocated rtx.
249 Also don't do this when we are making new REGs in reload, since
250 we don't want to get confused with the real pointers. */
252 if (mode == Pmode && !reload_in_progress)
254 if (frame_pointer_rtx != 0 && regno == FRAME_POINTER_REGNUM)
255 return frame_pointer_rtx;
256 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
257 if (hard_frame_pointer_rtx != 0 && regno == HARD_FRAME_POINTER_REGNUM)
258 return hard_frame_pointer_rtx;
260 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
261 if (arg_pointer_rtx != 0 && regno == ARG_POINTER_REGNUM)
262 return arg_pointer_rtx;
264 #ifdef RETURN_ADDRESS_POINTER_REGNUM
265 if (return_address_pointer_rtx != 0
266 && regno == RETURN_ADDRESS_POINTER_REGNUM)
267 return return_address_pointer_rtx;
269 if (stack_pointer_rtx != 0 && regno == STACK_POINTER_REGNUM)
270 return stack_pointer_rtx;
273 return gen_rtx_raw_REG (mode, regno);
277 gen_rtx_MEM (mode, addr)
278 enum machine_mode mode;
281 rtx rt = gen_rtx_raw_MEM (mode, addr);
283 /* This field is not cleared by the mere allocation of the rtx, so
285 MEM_ALIAS_SET (rt) = 0;
290 /* rtx gen_rtx (code, mode, [element1, ..., elementn])
292 ** This routine generates an RTX of the size specified by
293 ** <code>, which is an RTX code. The RTX structure is initialized
294 ** from the arguments <element1> through <elementn>, which are
295 ** interpreted according to the specific RTX type's format. The
296 ** special machine mode associated with the rtx (if any) is specified
299 ** gen_rtx can be invoked in a way which resembles the lisp-like
300 ** rtx it will generate. For example, the following rtx structure:
302 ** (plus:QI (mem:QI (reg:SI 1))
303 ** (mem:QI (plusw:SI (reg:SI 2) (reg:SI 3))))
305 ** ...would be generated by the following C code:
307 ** gen_rtx (PLUS, QImode,
308 ** gen_rtx (MEM, QImode,
309 ** gen_rtx (REG, SImode, 1)),
310 ** gen_rtx (MEM, QImode,
311 ** gen_rtx (PLUS, SImode,
312 ** gen_rtx (REG, SImode, 2),
313 ** gen_rtx (REG, SImode, 3)))),
318 gen_rtx VPROTO((enum rtx_code code, enum machine_mode mode, ...))
320 #ifndef ANSI_PROTOTYPES
322 enum machine_mode mode;
325 register int i; /* Array indices... */
326 register const char *fmt; /* Current rtx's format... */
327 register rtx rt_val; /* RTX to return to caller... */
331 #ifndef ANSI_PROTOTYPES
332 code = va_arg (p, enum rtx_code);
333 mode = va_arg (p, enum machine_mode);
339 rt_val = gen_rtx_CONST_INT (mode, va_arg (p, HOST_WIDE_INT));
344 rtx arg0 = va_arg (p, rtx);
345 HOST_WIDE_INT arg1 = va_arg (p, HOST_WIDE_INT);
346 HOST_WIDE_INT arg2 = va_arg (p, HOST_WIDE_INT);
347 rt_val = gen_rtx_CONST_DOUBLE (mode, arg0, arg1, arg2);
352 rt_val = gen_rtx_REG (mode, va_arg (p, int));
356 rt_val = gen_rtx_MEM (mode, va_arg (p, rtx));
360 rt_val = rtx_alloc (code); /* Allocate the storage space. */
361 rt_val->mode = mode; /* Store the machine mode... */
363 fmt = GET_RTX_FORMAT (code); /* Find the right format... */
364 for (i = 0; i < GET_RTX_LENGTH (code); i++)
368 case '0': /* Unused field. */
371 case 'i': /* An integer? */
372 XINT (rt_val, i) = va_arg (p, int);
375 case 'w': /* A wide integer? */
376 XWINT (rt_val, i) = va_arg (p, HOST_WIDE_INT);
379 case 's': /* A string? */
380 XSTR (rt_val, i) = va_arg (p, char *);
383 case 'e': /* An expression? */
384 case 'u': /* An insn? Same except when printing. */
385 XEXP (rt_val, i) = va_arg (p, rtx);
388 case 'E': /* An RTX vector? */
389 XVEC (rt_val, i) = va_arg (p, rtvec);
392 case 'b': /* A bitmap? */
393 XBITMAP (rt_val, i) = va_arg (p, bitmap);
396 case 't': /* A tree? */
397 XTREE (rt_val, i) = va_arg (p, tree);
411 /* gen_rtvec (n, [rt1, ..., rtn])
413 ** This routine creates an rtvec and stores within it the
414 ** pointers to rtx's which are its arguments.
419 gen_rtvec VPROTO((int n, ...))
421 #ifndef ANSI_PROTOTYPES
430 #ifndef ANSI_PROTOTYPES
435 return NULL_RTVEC; /* Don't allocate an empty rtvec... */
437 vector = (rtx *) alloca (n * sizeof (rtx));
439 for (i = 0; i < n; i++)
440 vector[i] = va_arg (p, rtx);
443 return gen_rtvec_v (n, vector);
447 gen_rtvec_v (n, argp)
452 register rtvec rt_val;
455 return NULL_RTVEC; /* Don't allocate an empty rtvec... */
457 rt_val = rtvec_alloc (n); /* Allocate an rtvec... */
459 for (i = 0; i < n; i++)
460 rt_val->elem[i] = *argp++;
466 /* Generate a REG rtx for a new pseudo register of mode MODE.
467 This pseudo is assigned the next sequential register number. */
471 enum machine_mode mode;
473 struct function *f = current_function;
476 /* Don't let anything called after initial flow analysis create new
481 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
482 || GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
484 /* For complex modes, don't make a single pseudo.
485 Instead, make a CONCAT of two pseudos.
486 This allows noncontiguous allocation of the real and imaginary parts,
487 which makes much better code. Besides, allocating DCmode
488 pseudos overstrains reload on some machines like the 386. */
489 rtx realpart, imagpart;
490 int size = GET_MODE_UNIT_SIZE (mode);
491 enum machine_mode partmode
492 = mode_for_size (size * BITS_PER_UNIT,
493 (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
494 ? MODE_FLOAT : MODE_INT),
497 realpart = gen_reg_rtx (partmode);
498 imagpart = gen_reg_rtx (partmode);
499 return gen_rtx_CONCAT (mode, realpart, imagpart);
502 /* Make sure regno_pointer_flag and regno_reg_rtx are large
503 enough to have an element for this pseudo reg number. */
505 if (reg_rtx_no == f->emit->regno_pointer_flag_length)
507 int old_size = f->emit->regno_pointer_flag_length;
510 new = xrealloc (f->emit->regno_pointer_flag, old_size * 2);
511 memset (new + old_size, 0, old_size);
512 f->emit->regno_pointer_flag = new;
514 new = xrealloc (f->emit->regno_pointer_align, old_size * 2);
515 memset (new + old_size, 0, old_size);
516 f->emit->regno_pointer_align = new;
518 new1 = (rtx *) xrealloc (f->emit->x_regno_reg_rtx,
519 old_size * 2 * sizeof (rtx));
520 memset (new1 + old_size, 0, old_size * sizeof (rtx));
521 regno_reg_rtx = new1;
523 f->emit->regno_pointer_flag_length = old_size * 2;
526 val = gen_rtx_raw_REG (mode, reg_rtx_no);
527 regno_reg_rtx[reg_rtx_no++] = val;
531 /* Identify REG (which may be a CONCAT) as a user register. */
537 if (GET_CODE (reg) == CONCAT)
539 REG_USERVAR_P (XEXP (reg, 0)) = 1;
540 REG_USERVAR_P (XEXP (reg, 1)) = 1;
542 else if (GET_CODE (reg) == REG)
543 REG_USERVAR_P (reg) = 1;
548 /* Identify REG as a probable pointer register and show its alignment
549 as ALIGN, if nonzero. */
552 mark_reg_pointer (reg, align)
556 if (! REGNO_POINTER_FLAG (REGNO (reg)))
558 REGNO_POINTER_FLAG (REGNO (reg)) = 1;
561 REGNO_POINTER_ALIGN (REGNO (reg)) = align;
563 else if (align && align < REGNO_POINTER_ALIGN (REGNO (reg)))
564 /* We can no-longer be sure just how aligned this pointer is */
565 REGNO_POINTER_ALIGN (REGNO (reg)) = align;
568 /* Return 1 plus largest pseudo reg number used in the current function. */
576 /* Return 1 + the largest label number used so far in the current function. */
581 if (last_label_num && label_num == base_label_num)
582 return last_label_num;
586 /* Return first label number used in this function (if any were used). */
589 get_first_label_num ()
591 return first_label_num;
594 /* Return a value representing some low-order bits of X, where the number
595 of low-order bits is given by MODE. Note that no conversion is done
596 between floating-point and fixed-point values, rather, the bit
597 representation is returned.
599 This function handles the cases in common between gen_lowpart, below,
600 and two variants in cse.c and combine.c. These are the cases that can
601 be safely handled at all points in the compilation.
603 If this is not a case we can handle, return 0. */
606 gen_lowpart_common (mode, x)
607 enum machine_mode mode;
612 if (GET_MODE (x) == mode)
615 /* MODE must occupy no more words than the mode of X. */
616 if (GET_MODE (x) != VOIDmode
617 && ((GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD
618 > ((GET_MODE_SIZE (GET_MODE (x)) + (UNITS_PER_WORD - 1))
622 if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
623 word = ((GET_MODE_SIZE (GET_MODE (x))
624 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
627 if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)
628 && (GET_MODE_CLASS (mode) == MODE_INT
629 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT))
631 /* If we are getting the low-order part of something that has been
632 sign- or zero-extended, we can either just use the object being
633 extended or make a narrower extension. If we want an even smaller
634 piece than the size of the object being extended, call ourselves
637 This case is used mostly by combine and cse. */
639 if (GET_MODE (XEXP (x, 0)) == mode)
641 else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (XEXP (x, 0))))
642 return gen_lowpart_common (mode, XEXP (x, 0));
643 else if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (x)))
644 return gen_rtx_fmt_e (GET_CODE (x), mode, XEXP (x, 0));
646 else if (GET_CODE (x) == SUBREG
647 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
648 || GET_MODE_SIZE (mode) == GET_MODE_UNIT_SIZE (GET_MODE (x))))
649 return (GET_MODE (SUBREG_REG (x)) == mode && SUBREG_WORD (x) == 0
651 : gen_rtx_SUBREG (mode, SUBREG_REG (x), SUBREG_WORD (x) + word));
652 else if (GET_CODE (x) == REG)
654 /* Let the backend decide how many registers to skip. This is needed
655 in particular for Sparc64 where fp regs are smaller than a word. */
656 /* ??? Note that subregs are now ambiguous, in that those against
657 pseudos are sized by the Word Size, while those against hard
658 regs are sized by the underlying register size. Better would be
659 to always interpret the subreg offset parameter as bytes or bits. */
661 if (WORDS_BIG_ENDIAN && REGNO (x) < FIRST_PSEUDO_REGISTER)
662 word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
663 - HARD_REGNO_NREGS (REGNO (x), mode));
665 /* If the register is not valid for MODE, return 0. If we don't
666 do this, there is no way to fix up the resulting REG later.
667 But we do do this if the current REG is not valid for its
668 mode. This latter is a kludge, but is required due to the
669 way that parameters are passed on some machines, most
671 if (REGNO (x) < FIRST_PSEUDO_REGISTER
672 && ! HARD_REGNO_MODE_OK (REGNO (x) + word, mode)
673 && HARD_REGNO_MODE_OK (REGNO (x), GET_MODE (x)))
675 else if (REGNO (x) < FIRST_PSEUDO_REGISTER
676 /* integrate.c can't handle parts of a return value register. */
677 && (! REG_FUNCTION_VALUE_P (x)
678 || ! rtx_equal_function_value_matters)
679 #ifdef CLASS_CANNOT_CHANGE_SIZE
680 && ! (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (x))
681 && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_INT
682 && GET_MODE_CLASS (GET_MODE (x)) != MODE_COMPLEX_FLOAT
683 && (TEST_HARD_REG_BIT
684 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
687 /* We want to keep the stack, frame, and arg pointers
689 && x != frame_pointer_rtx
690 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
691 && x != arg_pointer_rtx
693 && x != stack_pointer_rtx)
694 return gen_rtx_REG (mode, REGNO (x) + word);
696 return gen_rtx_SUBREG (mode, x, word);
698 /* If X is a CONST_INT or a CONST_DOUBLE, extract the appropriate bits
699 from the low-order part of the constant. */
700 else if ((GET_MODE_CLASS (mode) == MODE_INT
701 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
702 && GET_MODE (x) == VOIDmode
703 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE))
705 /* If MODE is twice the host word size, X is already the desired
706 representation. Otherwise, if MODE is wider than a word, we can't
707 do this. If MODE is exactly a word, return just one CONST_INT.
708 If MODE is smaller than a word, clear the bits that don't belong
709 in our mode, unless they and our sign bit are all one. So we get
710 either a reasonable negative value or a reasonable unsigned value
713 if (GET_MODE_BITSIZE (mode) >= 2 * HOST_BITS_PER_WIDE_INT)
715 else if (GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT)
717 else if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT)
718 return (GET_CODE (x) == CONST_INT ? x
719 : GEN_INT (CONST_DOUBLE_LOW (x)));
722 /* MODE must be narrower than HOST_BITS_PER_WIDE_INT. */
723 int width = GET_MODE_BITSIZE (mode);
724 HOST_WIDE_INT val = (GET_CODE (x) == CONST_INT ? INTVAL (x)
725 : CONST_DOUBLE_LOW (x));
727 /* Sign extend to HOST_WIDE_INT. */
728 val = val << (HOST_BITS_PER_WIDE_INT - width) >> (HOST_BITS_PER_WIDE_INT - width);
730 return (GET_CODE (x) == CONST_INT && INTVAL (x) == val ? x
735 /* If X is an integral constant but we want it in floating-point, it
736 must be the case that we have a union of an integer and a floating-point
737 value. If the machine-parameters allow it, simulate that union here
738 and return the result. The two-word and single-word cases are
741 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
742 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
743 || flag_pretend_float)
744 && GET_MODE_CLASS (mode) == MODE_FLOAT
745 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
746 && GET_CODE (x) == CONST_INT
747 && sizeof (float) * HOST_BITS_PER_CHAR == HOST_BITS_PER_WIDE_INT)
748 #ifdef REAL_ARITHMETIC
754 r = REAL_VALUE_FROM_TARGET_SINGLE (i);
755 /* Avoid changing the bit pattern of a NaN. */
756 if (REAL_VALUE_ISNAN (r))
758 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
762 union {HOST_WIDE_INT i; float d; } u;
765 return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
768 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
769 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
770 || flag_pretend_float)
771 && GET_MODE_CLASS (mode) == MODE_FLOAT
772 && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
773 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE)
774 && GET_MODE (x) == VOIDmode
775 && (sizeof (double) * HOST_BITS_PER_CHAR
776 == 2 * HOST_BITS_PER_WIDE_INT))
777 #ifdef REAL_ARITHMETIC
781 HOST_WIDE_INT low, high;
783 if (GET_CODE (x) == CONST_INT)
784 low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
786 low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
788 /* REAL_VALUE_TARGET_DOUBLE takes the addressing order of the
790 if (WORDS_BIG_ENDIAN)
791 i[0] = high, i[1] = low;
793 i[0] = low, i[1] = high;
795 r = REAL_VALUE_FROM_TARGET_DOUBLE (i);
796 if (REAL_VALUE_ISNAN (r))
798 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
802 union {HOST_WIDE_INT i[2]; double d; } u;
803 HOST_WIDE_INT low, high;
805 if (GET_CODE (x) == CONST_INT)
806 low = INTVAL (x), high = low >> (HOST_BITS_PER_WIDE_INT -1);
808 low = CONST_DOUBLE_LOW (x), high = CONST_DOUBLE_HIGH (x);
810 #ifdef HOST_WORDS_BIG_ENDIAN
811 u.i[0] = high, u.i[1] = low;
813 u.i[0] = low, u.i[1] = high;
816 return CONST_DOUBLE_FROM_REAL_VALUE (u.d, mode);
820 /* We need an extra case for machines where HOST_BITS_PER_WIDE_INT is the
821 same as sizeof (double) or when sizeof (float) is larger than the
822 size of a word on the target machine. */
823 #ifdef REAL_ARITHMETIC
824 else if (mode == SFmode && GET_CODE (x) == CONST_INT)
830 r = REAL_VALUE_FROM_TARGET_SINGLE (i);
831 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
833 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
834 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
835 || flag_pretend_float)
836 && GET_MODE_CLASS (mode) == MODE_FLOAT
837 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
838 && GET_CODE (x) == CONST_INT
839 && (sizeof (double) * HOST_BITS_PER_CHAR
840 == HOST_BITS_PER_WIDE_INT))
846 r = REAL_VALUE_FROM_TARGET_DOUBLE (&i);
847 return CONST_DOUBLE_FROM_REAL_VALUE (r, mode);
851 /* Similarly, if this is converting a floating-point value into a
852 single-word integer. Only do this is the host and target parameters are
855 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
856 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
857 || flag_pretend_float)
858 && (GET_MODE_CLASS (mode) == MODE_INT
859 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
860 && GET_CODE (x) == CONST_DOUBLE
861 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
862 && GET_MODE_BITSIZE (mode) == BITS_PER_WORD)
863 return operand_subword (x, word, 0, GET_MODE (x));
865 /* Similarly, if this is converting a floating-point value into a
866 two-word integer, we can do this one word at a time and make an
867 integer. Only do this is the host and target parameters are
870 else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
871 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
872 || flag_pretend_float)
873 && (GET_MODE_CLASS (mode) == MODE_INT
874 || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
875 && GET_CODE (x) == CONST_DOUBLE
876 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
877 && GET_MODE_BITSIZE (mode) == 2 * BITS_PER_WORD)
880 = operand_subword (x, word + WORDS_BIG_ENDIAN, 0, GET_MODE (x));
882 = operand_subword (x, word + ! WORDS_BIG_ENDIAN, 0, GET_MODE (x));
884 if (lowpart && GET_CODE (lowpart) == CONST_INT
885 && highpart && GET_CODE (highpart) == CONST_INT)
886 return immed_double_const (INTVAL (lowpart), INTVAL (highpart), mode);
889 /* Otherwise, we can't do this. */
893 /* Return the real part (which has mode MODE) of a complex value X.
894 This always comes at the low address in memory. */
897 gen_realpart (mode, x)
898 enum machine_mode mode;
901 if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
903 else if (WORDS_BIG_ENDIAN
904 && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
906 && REGNO (x) < FIRST_PSEUDO_REGISTER)
907 fatal ("Unable to access real part of complex value in a hard register on this target");
908 else if (WORDS_BIG_ENDIAN)
909 return gen_highpart (mode, x);
911 return gen_lowpart (mode, x);
914 /* Return the imaginary part (which has mode MODE) of a complex value X.
915 This always comes at the high address in memory. */
918 gen_imagpart (mode, x)
919 enum machine_mode mode;
922 if (GET_CODE (x) == CONCAT && GET_MODE (XEXP (x, 0)) == mode)
924 else if (WORDS_BIG_ENDIAN)
925 return gen_lowpart (mode, x);
926 else if (!WORDS_BIG_ENDIAN
927 && GET_MODE_BITSIZE (mode) < BITS_PER_WORD
929 && REGNO (x) < FIRST_PSEUDO_REGISTER)
930 fatal ("Unable to access imaginary part of complex value in a hard register on this target");
932 return gen_highpart (mode, x);
935 /* Return 1 iff X, assumed to be a SUBREG,
936 refers to the real part of the complex value in its containing reg.
937 Complex values are always stored with the real part in the first word,
938 regardless of WORDS_BIG_ENDIAN. */
941 subreg_realpart_p (x)
944 if (GET_CODE (x) != SUBREG)
947 return SUBREG_WORD (x) * UNITS_PER_WORD < GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (x)));
950 /* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a value,
951 return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
952 least-significant part of X.
953 MODE specifies how big a part of X to return;
954 it usually should not be larger than a word.
955 If X is a MEM whose address is a QUEUED, the value may be so also. */
958 gen_lowpart (mode, x)
959 enum machine_mode mode;
962 rtx result = gen_lowpart_common (mode, x);
966 else if (GET_CODE (x) == REG)
968 /* Must be a hard reg that's not valid in MODE. */
969 result = gen_lowpart_common (mode, copy_to_reg (x));
974 else if (GET_CODE (x) == MEM)
976 /* The only additional case we can do is MEM. */
977 register int offset = 0;
978 if (WORDS_BIG_ENDIAN)
979 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
980 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
982 if (BYTES_BIG_ENDIAN)
983 /* Adjust the address so that the address-after-the-data
985 offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
986 - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
988 return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
990 else if (GET_CODE (x) == ADDRESSOF)
991 return gen_lowpart (mode, force_reg (GET_MODE (x), x));
996 /* Like `gen_lowpart', but refer to the most significant part.
997 This is used to access the imaginary part of a complex number. */
1000 gen_highpart (mode, x)
1001 enum machine_mode mode;
1004 /* This case loses if X is a subreg. To catch bugs early,
1005 complain if an invalid MODE is used even in other cases. */
1006 if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
1007 && GET_MODE_SIZE (mode) != GET_MODE_UNIT_SIZE (GET_MODE (x)))
1009 if (GET_CODE (x) == CONST_DOUBLE
1010 #if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined (REAL_IS_NOT_DOUBLE))
1011 && GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT
1014 return GEN_INT (CONST_DOUBLE_HIGH (x) & GET_MODE_MASK (mode));
1015 else if (GET_CODE (x) == CONST_INT)
1017 if (HOST_BITS_PER_WIDE_INT <= BITS_PER_WORD)
1019 return GEN_INT (INTVAL (x) >> (HOST_BITS_PER_WIDE_INT - BITS_PER_WORD));
1021 else if (GET_CODE (x) == MEM)
1023 register int offset = 0;
1024 if (! WORDS_BIG_ENDIAN)
1025 offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
1026 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
1028 if (! BYTES_BIG_ENDIAN
1029 && GET_MODE_SIZE (mode) < UNITS_PER_WORD)
1030 offset -= (GET_MODE_SIZE (mode)
1031 - MIN (UNITS_PER_WORD,
1032 GET_MODE_SIZE (GET_MODE (x))));
1034 return change_address (x, mode, plus_constant (XEXP (x, 0), offset));
1036 else if (GET_CODE (x) == SUBREG)
1038 /* The only time this should occur is when we are looking at a
1039 multi-word item with a SUBREG whose mode is the same as that of the
1040 item. It isn't clear what we would do if it wasn't. */
1041 if (SUBREG_WORD (x) != 0)
1043 return gen_highpart (mode, SUBREG_REG (x));
1045 else if (GET_CODE (x) == REG)
1049 /* Let the backend decide how many registers to skip. This is needed
1050 in particular for sparc64 where fp regs are smaller than a word. */
1051 /* ??? Note that subregs are now ambiguous, in that those against
1052 pseudos are sized by the word size, while those against hard
1053 regs are sized by the underlying register size. Better would be
1054 to always interpret the subreg offset parameter as bytes or bits. */
1056 if (WORDS_BIG_ENDIAN)
1058 else if (REGNO (x) < FIRST_PSEUDO_REGISTER)
1059 word = (HARD_REGNO_NREGS (REGNO (x), GET_MODE (x))
1060 - HARD_REGNO_NREGS (REGNO (x), mode));
1062 word = ((GET_MODE_SIZE (GET_MODE (x))
1063 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
1066 if (REGNO (x) < FIRST_PSEUDO_REGISTER
1067 /* integrate.c can't handle parts of a return value register. */
1068 && (! REG_FUNCTION_VALUE_P (x)
1069 || ! rtx_equal_function_value_matters)
1070 /* We want to keep the stack, frame, and arg pointers special. */
1071 && x != frame_pointer_rtx
1072 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1073 && x != arg_pointer_rtx
1075 && x != stack_pointer_rtx)
1076 return gen_rtx_REG (mode, REGNO (x) + word);
1078 return gen_rtx_SUBREG (mode, x, word);
1084 /* Return 1 iff X, assumed to be a SUBREG,
1085 refers to the least significant part of its containing reg.
1086 If X is not a SUBREG, always return 1 (it is its own low part!). */
1089 subreg_lowpart_p (x)
1092 if (GET_CODE (x) != SUBREG)
1094 else if (GET_MODE (SUBREG_REG (x)) == VOIDmode)
1097 if (WORDS_BIG_ENDIAN
1098 && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) > UNITS_PER_WORD)
1099 return (SUBREG_WORD (x)
1100 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
1101 - MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD))
1104 return SUBREG_WORD (x) == 0;
1107 /* Return subword I of operand OP.
1108 The word number, I, is interpreted as the word number starting at the
1109 low-order address. Word 0 is the low-order word if not WORDS_BIG_ENDIAN,
1110 otherwise it is the high-order word.
1112 If we cannot extract the required word, we return zero. Otherwise, an
1113 rtx corresponding to the requested word will be returned.
1115 VALIDATE_ADDRESS is nonzero if the address should be validated. Before
1116 reload has completed, a valid address will always be returned. After
1117 reload, if a valid address cannot be returned, we return zero.
1119 If VALIDATE_ADDRESS is zero, we simply form the required address; validating
1120 it is the responsibility of the caller.
1122 MODE is the mode of OP in case it is a CONST_INT. */
1125 operand_subword (op, i, validate_address, mode)
1128 int validate_address;
1129 enum machine_mode mode;
1132 int size_ratio = HOST_BITS_PER_WIDE_INT / BITS_PER_WORD;
1134 if (mode == VOIDmode)
1135 mode = GET_MODE (op);
1137 if (mode == VOIDmode)
1140 /* If OP is narrower than a word, fail. */
1142 && (GET_MODE_SIZE (mode) < UNITS_PER_WORD))
1145 /* If we want a word outside OP, return zero. */
1147 && (i + 1) * UNITS_PER_WORD > GET_MODE_SIZE (mode))
1150 /* If OP is already an integer word, return it. */
1151 if (GET_MODE_CLASS (mode) == MODE_INT
1152 && GET_MODE_SIZE (mode) == UNITS_PER_WORD)
1155 /* If OP is a REG or SUBREG, we can handle it very simply. */
1156 if (GET_CODE (op) == REG)
1158 /* ??? There is a potential problem with this code. It does not
1159 properly handle extractions of a subword from a hard register
1160 that is larger than word_mode. Presumably the check for
1161 HARD_REGNO_MODE_OK catches these most of these cases. */
1163 /* If OP is a hard register, but OP + I is not a hard register,
1164 then extracting a subword is impossible.
1166 For example, consider if OP is the last hard register and it is
1167 larger than word_mode. If we wanted word N (for N > 0) because a
1168 part of that hard register was known to contain a useful value,
1169 then OP + I would refer to a pseudo, not the hard register we
1171 if (REGNO (op) < FIRST_PSEUDO_REGISTER
1172 && REGNO (op) + i >= FIRST_PSEUDO_REGISTER)
1175 /* If the register is not valid for MODE, return 0. Note we
1176 have to check both OP and OP + I since they may refer to
1177 different parts of the register file.
1179 Consider if OP refers to the last 96bit FP register and we want
1180 subword 3 because that subword is known to contain a value we
1182 if (REGNO (op) < FIRST_PSEUDO_REGISTER
1183 && (! HARD_REGNO_MODE_OK (REGNO (op), word_mode)
1184 || ! HARD_REGNO_MODE_OK (REGNO (op) + i, word_mode)))
1186 else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
1187 || (REG_FUNCTION_VALUE_P (op)
1188 && rtx_equal_function_value_matters)
1189 /* We want to keep the stack, frame, and arg pointers
1191 || op == frame_pointer_rtx
1192 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1193 || op == arg_pointer_rtx
1195 || op == stack_pointer_rtx)
1196 return gen_rtx_SUBREG (word_mode, op, i);
1198 return gen_rtx_REG (word_mode, REGNO (op) + i);
1200 else if (GET_CODE (op) == SUBREG)
1201 return gen_rtx_SUBREG (word_mode, SUBREG_REG (op), i + SUBREG_WORD (op));
1202 else if (GET_CODE (op) == CONCAT)
1204 int partwords = GET_MODE_UNIT_SIZE (GET_MODE (op)) / UNITS_PER_WORD;
1206 return operand_subword (XEXP (op, 0), i, validate_address, mode);
1207 return operand_subword (XEXP (op, 1), i - partwords,
1208 validate_address, mode);
1211 /* Form a new MEM at the requested address. */
1212 if (GET_CODE (op) == MEM)
1214 rtx addr = plus_constant (XEXP (op, 0), i * UNITS_PER_WORD);
1217 if (validate_address)
1219 if (reload_completed)
1221 if (! strict_memory_address_p (word_mode, addr))
1225 addr = memory_address (word_mode, addr);
1228 new = gen_rtx_MEM (word_mode, addr);
1230 MEM_COPY_ATTRIBUTES (new, op);
1231 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (op);
1232 MEM_ALIAS_SET (new) = MEM_ALIAS_SET (op);
1237 /* The only remaining cases are when OP is a constant. If the host and
1238 target floating formats are the same, handling two-word floating
1239 constants are easy. Note that REAL_VALUE_TO_TARGET_{SINGLE,DOUBLE}
1240 are defined as returning one or two 32 bit values, respectively,
1241 and not values of BITS_PER_WORD bits. */
1242 #ifdef REAL_ARITHMETIC
1243 /* The output is some bits, the width of the target machine's word.
1244 A wider-word host can surely hold them in a CONST_INT. A narrower-word
1246 if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1247 && GET_MODE_CLASS (mode) == MODE_FLOAT
1248 && GET_MODE_BITSIZE (mode) == 64
1249 && GET_CODE (op) == CONST_DOUBLE)
1254 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1255 REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
1257 /* We handle 32-bit and >= 64-bit words here. Note that the order in
1258 which the words are written depends on the word endianness.
1259 ??? This is a potential portability problem and should
1260 be fixed at some point.
1262 We must excercise caution with the sign bit. By definition there
1263 are 32 significant bits in K; there may be more in a HOST_WIDE_INT.
1264 Consider a host with a 32-bit long and a 64-bit HOST_WIDE_INT.
1265 So we explicitly mask and sign-extend as necessary. */
1266 if (BITS_PER_WORD == 32)
1269 val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1270 return GEN_INT (val);
1272 #if HOST_BITS_PER_WIDE_INT >= 64
1273 else if (BITS_PER_WORD >= 64 && i == 0)
1275 val = k[! WORDS_BIG_ENDIAN];
1276 val = (((val & 0xffffffff) ^ 0x80000000) - 0x80000000) << 32;
1277 val |= (HOST_WIDE_INT) k[WORDS_BIG_ENDIAN] & 0xffffffff;
1278 return GEN_INT (val);
1281 else if (BITS_PER_WORD == 16)
1284 if ((i & 1) == !WORDS_BIG_ENDIAN)
1287 return GEN_INT (val);
1292 else if (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
1293 && GET_MODE_CLASS (mode) == MODE_FLOAT
1294 && GET_MODE_BITSIZE (mode) > 64
1295 && GET_CODE (op) == CONST_DOUBLE)
1300 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1301 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv, k);
1303 if (BITS_PER_WORD == 32)
1306 val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1307 return GEN_INT (val);
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));
1328 return GEN_INT (i != WORDS_BIG_ENDIAN
1329 ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
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)
1345 REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
1346 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
1348 /* Sign extend from known 32-bit value to HOST_WIDE_INT. */
1350 val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
1352 if (BITS_PER_WORD == 16)
1354 if ((i & 1) == !WORDS_BIG_ENDIAN)
1359 return GEN_INT (val);
1362 if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1363 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1364 || flag_pretend_float)
1365 && sizeof (float) * 8 == HOST_BITS_PER_WIDE_INT
1366 && GET_MODE_CLASS (mode) == MODE_FLOAT
1367 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1368 && GET_CODE (op) == CONST_DOUBLE)
1371 union {float f; HOST_WIDE_INT i; } u;
1373 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1376 return GEN_INT (u.i);
1378 if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
1379 && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
1380 || flag_pretend_float)
1381 && sizeof (double) * 8 == HOST_BITS_PER_WIDE_INT
1382 && GET_MODE_CLASS (mode) == MODE_FLOAT
1383 && GET_MODE_SIZE (mode) == UNITS_PER_WORD
1384 && GET_CODE (op) == CONST_DOUBLE)
1387 union {double d; HOST_WIDE_INT i; } u;
1389 REAL_VALUE_FROM_CONST_DOUBLE (d, op);
1392 return GEN_INT (u.i);
1394 #endif /* no REAL_ARITHMETIC */
1396 /* The only remaining cases that we can handle are integers.
1397 Convert to proper endianness now since these cases need it.
1398 At this point, i == 0 means the low-order word.
1400 We do not want to handle the case when BITS_PER_WORD <= HOST_BITS_PER_INT
1401 in general. However, if OP is (const_int 0), we can just return
1404 if (op == const0_rtx)
1407 if (GET_MODE_CLASS (mode) != MODE_INT
1408 || (GET_CODE (op) != CONST_INT && GET_CODE (op) != CONST_DOUBLE)
1409 || BITS_PER_WORD > HOST_BITS_PER_WIDE_INT)
1412 if (WORDS_BIG_ENDIAN)
1413 i = GET_MODE_SIZE (mode) / UNITS_PER_WORD - 1 - i;
1415 /* Find out which word on the host machine this value is in and get
1416 it from the constant. */
1417 val = (i / size_ratio == 0
1418 ? (GET_CODE (op) == CONST_INT ? INTVAL (op) : CONST_DOUBLE_LOW (op))
1419 : (GET_CODE (op) == CONST_INT
1420 ? (INTVAL (op) < 0 ? ~0 : 0) : CONST_DOUBLE_HIGH (op)));
1422 /* Get the value we want into the low bits of val. */
1423 if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT)
1424 val = ((val >> ((i % size_ratio) * BITS_PER_WORD)));
1426 val = trunc_int_for_mode (val, word_mode);
1428 return GEN_INT (val);
1431 /* Similar to `operand_subword', but never return 0. If we can't extract
1432 the required subword, put OP into a register and try again. If that fails,
1433 abort. We always validate the address in this case. It is not valid
1434 to call this function after reload; it is mostly meant for RTL
1437 MODE is the mode of OP, in case it is CONST_INT. */
1440 operand_subword_force (op, i, mode)
1443 enum machine_mode mode;
1445 rtx result = operand_subword (op, i, 1, mode);
1450 if (mode != BLKmode && mode != VOIDmode)
1452 /* If this is a register which can not be accessed by words, copy it
1453 to a pseudo register. */
1454 if (GET_CODE (op) == REG)
1455 op = copy_to_reg (op);
1457 op = force_reg (mode, op);
1460 result = operand_subword (op, i, 1, mode);
1467 /* Given a compare instruction, swap the operands.
1468 A test instruction is changed into a compare of 0 against the operand. */
1471 reverse_comparison (insn)
1474 rtx body = PATTERN (insn);
1477 if (GET_CODE (body) == SET)
1478 comp = SET_SRC (body);
1480 comp = SET_SRC (XVECEXP (body, 0, 0));
1482 if (GET_CODE (comp) == COMPARE)
1484 rtx op0 = XEXP (comp, 0);
1485 rtx op1 = XEXP (comp, 1);
1486 XEXP (comp, 0) = op1;
1487 XEXP (comp, 1) = op0;
1491 rtx new = gen_rtx_COMPARE (VOIDmode,
1492 CONST0_RTX (GET_MODE (comp)), comp);
1493 if (GET_CODE (body) == SET)
1494 SET_SRC (body) = new;
1496 SET_SRC (XVECEXP (body, 0, 0)) = new;
1500 /* Return a memory reference like MEMREF, but with its mode changed
1501 to MODE and its address changed to ADDR.
1502 (VOIDmode means don't change the mode.
1503 NULL for ADDR means don't change the address.) */
1506 change_address (memref, mode, addr)
1508 enum machine_mode mode;
1513 if (GET_CODE (memref) != MEM)
1515 if (mode == VOIDmode)
1516 mode = GET_MODE (memref);
1518 addr = XEXP (memref, 0);
1520 /* If reload is in progress or has completed, ADDR must be valid.
1521 Otherwise, we can call memory_address to make it valid. */
1522 if (reload_completed || reload_in_progress)
1524 if (! memory_address_p (mode, addr))
1528 addr = memory_address (mode, addr);
1530 if (rtx_equal_p (addr, XEXP (memref, 0)) && mode == GET_MODE (memref))
1533 new = gen_rtx_MEM (mode, addr);
1534 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (memref);
1535 MEM_COPY_ATTRIBUTES (new, memref);
1536 MEM_ALIAS_SET (new) = MEM_ALIAS_SET (memref);
1540 /* Return a newly created CODE_LABEL rtx with a unique label number. */
1547 label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX,
1548 NULL_RTX, label_num++, NULL_PTR);
1550 LABEL_NUSES (label) = 0;
1554 /* For procedure integration. */
1556 /* Install new pointers to the first and last insns in the chain.
1557 Also, set cur_insn_uid to one higher than the last in use.
1558 Used for an inline-procedure after copying the insn chain. */
1561 set_new_first_and_last_insn (first, last)
1570 for (insn = first; insn; insn = NEXT_INSN (insn))
1571 cur_insn_uid = MAX (cur_insn_uid, INSN_UID (insn));
1576 /* Set the range of label numbers found in the current function.
1577 This is used when belatedly compiling an inline function. */
1580 set_new_first_and_last_label_num (first, last)
1583 base_label_num = label_num;
1584 first_label_num = first;
1585 last_label_num = last;
1588 /* Set the last label number found in the current function.
1589 This is used when belatedly compiling an inline function. */
1592 set_new_last_label_num (last)
1595 base_label_num = label_num;
1596 last_label_num = last;
1599 /* Restore all variables describing the current status from the structure *P.
1600 This is used after a nested function. */
1603 restore_emit_status (p)
1607 clear_emit_caches ();
1610 /* Clear out all parts of the state in F that can safely be discarded
1611 after the function has been compiled, to let garbage collection
1612 reclaim the memory. D is the declaration for the function just
1613 compiled. Its output may have been deferred. */
1616 free_emit_status (f, d)
1620 if (DECL_DEFER_OUTPUT (d))
1623 free (f->emit->x_regno_reg_rtx);
1624 free (f->emit->regno_pointer_flag);
1625 free (f->emit->regno_pointer_align);
1626 f->emit->x_regno_reg_rtx = 0;
1629 /* Go through all the RTL insn bodies and copy any invalid shared structure.
1630 It does not work to do this twice, because the mark bits set here
1631 are not cleared afterwards. */
1634 unshare_all_rtl (insn)
1637 for (; insn; insn = NEXT_INSN (insn))
1638 if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
1639 || GET_CODE (insn) == CALL_INSN)
1641 PATTERN (insn) = copy_rtx_if_shared (PATTERN (insn));
1642 REG_NOTES (insn) = copy_rtx_if_shared (REG_NOTES (insn));
1643 LOG_LINKS (insn) = copy_rtx_if_shared (LOG_LINKS (insn));
1646 /* Make sure the addresses of stack slots found outside the insn chain
1647 (such as, in DECL_RTL of a variable) are not shared
1648 with the insn chain.
1650 This special care is necessary when the stack slot MEM does not
1651 actually appear in the insn chain. If it does appear, its address
1652 is unshared from all else at that point. */
1654 copy_rtx_if_shared (stack_slot_list);
1657 /* Mark ORIG as in use, and return a copy of it if it was already in use.
1658 Recursively does the same for subexpressions. */
1661 copy_rtx_if_shared (orig)
1664 register rtx x = orig;
1666 register enum rtx_code code;
1667 register const char *format_ptr;
1673 code = GET_CODE (x);
1675 /* These types may be freely shared. */
1688 /* SCRATCH must be shared because they represent distinct values. */
1692 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
1693 a LABEL_REF, it isn't sharable. */
1694 if (GET_CODE (XEXP (x, 0)) == PLUS
1695 && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
1696 && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
1705 /* The chain of insns is not being copied. */
1709 /* A MEM is allowed to be shared if its address is constant.
1711 We used to allow sharing of MEMs which referenced
1712 virtual_stack_vars_rtx or virtual_incoming_args_rtx, but
1713 that can lose. instantiate_virtual_regs will not unshare
1714 the MEMs, and combine may change the structure of the address
1715 because it looks safe and profitable in one context, but
1716 in some other context it creates unrecognizable RTL. */
1717 if (CONSTANT_ADDRESS_P (XEXP (x, 0)))
1726 /* This rtx may not be shared. If it has already been seen,
1727 replace it with a copy of itself. */
1733 copy = rtx_alloc (code);
1734 bcopy ((char *) x, (char *) copy,
1735 (sizeof (*copy) - sizeof (copy->fld)
1736 + sizeof (copy->fld[0]) * GET_RTX_LENGTH (code)));
1742 /* Now scan the subexpressions recursively.
1743 We can store any replaced subexpressions directly into X
1744 since we know X is not shared! Any vectors in X
1745 must be copied if X was copied. */
1747 format_ptr = GET_RTX_FORMAT (code);
1749 for (i = 0; i < GET_RTX_LENGTH (code); i++)
1751 switch (*format_ptr++)
1754 XEXP (x, i) = copy_rtx_if_shared (XEXP (x, i));
1758 if (XVEC (x, i) != NULL)
1761 int len = XVECLEN (x, i);
1763 if (copied && len > 0)
1764 XVEC (x, i) = gen_rtvec_v (len, XVEC (x, i)->elem);
1765 for (j = 0; j < len; j++)
1766 XVECEXP (x, i, j) = copy_rtx_if_shared (XVECEXP (x, i, j));
1774 /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
1775 to look for shared sub-parts. */
1778 reset_used_flags (x)
1782 register enum rtx_code code;
1783 register const char *format_ptr;
1788 code = GET_CODE (x);
1790 /* These types may be freely shared so we needn't do any resetting
1811 /* The chain of insns is not being copied. */
1820 format_ptr = GET_RTX_FORMAT (code);
1821 for (i = 0; i < GET_RTX_LENGTH (code); i++)
1823 switch (*format_ptr++)
1826 reset_used_flags (XEXP (x, i));
1830 for (j = 0; j < XVECLEN (x, i); j++)
1831 reset_used_flags (XVECEXP (x, i, j));
1837 /* Copy X if necessary so that it won't be altered by changes in OTHER.
1838 Return X or the rtx for the pseudo reg the value of X was copied into.
1839 OTHER must be valid as a SET_DEST. */
1842 make_safe_from (x, other)
1846 switch (GET_CODE (other))
1849 other = SUBREG_REG (other);
1851 case STRICT_LOW_PART:
1854 other = XEXP (other, 0);
1860 if ((GET_CODE (other) == MEM
1862 && GET_CODE (x) != REG
1863 && GET_CODE (x) != SUBREG)
1864 || (GET_CODE (other) == REG
1865 && (REGNO (other) < FIRST_PSEUDO_REGISTER
1866 || reg_mentioned_p (other, x))))
1868 rtx temp = gen_reg_rtx (GET_MODE (x));
1869 emit_move_insn (temp, x);
1875 /* Emission of insns (adding them to the doubly-linked list). */
1877 /* Return the first insn of the current sequence or current function. */
1885 /* Return the last insn emitted in current sequence or current function. */
1893 /* Specify a new insn as the last in the chain. */
1896 set_last_insn (insn)
1899 if (NEXT_INSN (insn) != 0)
1904 /* Return the last insn emitted, even if it is in a sequence now pushed. */
1907 get_last_insn_anywhere ()
1909 struct sequence_stack *stack;
1912 for (stack = seq_stack; stack; stack = stack->next)
1913 if (stack->last != 0)
1918 /* Return a number larger than any instruction's uid in this function. */
1923 return cur_insn_uid;
1926 /* Return the next insn. If it is a SEQUENCE, return the first insn
1935 insn = NEXT_INSN (insn);
1936 if (insn && GET_CODE (insn) == INSN
1937 && GET_CODE (PATTERN (insn)) == SEQUENCE)
1938 insn = XVECEXP (PATTERN (insn), 0, 0);
1944 /* Return the previous insn. If it is a SEQUENCE, return the last insn
1948 previous_insn (insn)
1953 insn = PREV_INSN (insn);
1954 if (insn && GET_CODE (insn) == INSN
1955 && GET_CODE (PATTERN (insn)) == SEQUENCE)
1956 insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1);
1962 /* Return the next insn after INSN that is not a NOTE. This routine does not
1963 look inside SEQUENCEs. */
1966 next_nonnote_insn (insn)
1971 insn = NEXT_INSN (insn);
1972 if (insn == 0 || GET_CODE (insn) != NOTE)
1979 /* Return the previous insn before INSN that is not a NOTE. This routine does
1980 not look inside SEQUENCEs. */
1983 prev_nonnote_insn (insn)
1988 insn = PREV_INSN (insn);
1989 if (insn == 0 || GET_CODE (insn) != NOTE)
1996 /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
1997 or 0, if there is none. This routine does not look inside
2001 next_real_insn (insn)
2006 insn = NEXT_INSN (insn);
2007 if (insn == 0 || GET_CODE (insn) == INSN
2008 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN)
2015 /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
2016 or 0, if there is none. This routine does not look inside
2020 prev_real_insn (insn)
2025 insn = PREV_INSN (insn);
2026 if (insn == 0 || GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN
2027 || GET_CODE (insn) == JUMP_INSN)
2034 /* Find the next insn after INSN that really does something. This routine
2035 does not look inside SEQUENCEs. Until reload has completed, this is the
2036 same as next_real_insn. */
2039 next_active_insn (insn)
2044 insn = NEXT_INSN (insn);
2046 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN
2047 || (GET_CODE (insn) == INSN
2048 && (! reload_completed
2049 || (GET_CODE (PATTERN (insn)) != USE
2050 && GET_CODE (PATTERN (insn)) != CLOBBER))))
2057 /* Find the last insn before INSN that really does something. This routine
2058 does not look inside SEQUENCEs. Until reload has completed, this is the
2059 same as prev_real_insn. */
2062 prev_active_insn (insn)
2067 insn = PREV_INSN (insn);
2069 || GET_CODE (insn) == CALL_INSN || GET_CODE (insn) == JUMP_INSN
2070 || (GET_CODE (insn) == INSN
2071 && (! reload_completed
2072 || (GET_CODE (PATTERN (insn)) != USE
2073 && GET_CODE (PATTERN (insn)) != CLOBBER))))
2080 /* Return the next CODE_LABEL after the insn INSN, or 0 if there is none. */
2088 insn = NEXT_INSN (insn);
2089 if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2096 /* Return the last CODE_LABEL before the insn INSN, or 0 if there is none. */
2104 insn = PREV_INSN (insn);
2105 if (insn == 0 || GET_CODE (insn) == CODE_LABEL)
2113 /* INSN uses CC0 and is being moved into a delay slot. Set up REG_CC_SETTER
2114 and REG_CC_USER notes so we can find it. */
2117 link_cc0_insns (insn)
2120 rtx user = next_nonnote_insn (insn);
2122 if (GET_CODE (user) == INSN && GET_CODE (PATTERN (user)) == SEQUENCE)
2123 user = XVECEXP (PATTERN (user), 0, 0);
2125 REG_NOTES (user) = gen_rtx_INSN_LIST (REG_CC_SETTER, insn,
2127 REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_CC_USER, user, REG_NOTES (insn));
2130 /* Return the next insn that uses CC0 after INSN, which is assumed to
2131 set it. This is the inverse of prev_cc0_setter (i.e., prev_cc0_setter
2132 applied to the result of this function should yield INSN).
2134 Normally, this is simply the next insn. However, if a REG_CC_USER note
2135 is present, it contains the insn that uses CC0.
2137 Return 0 if we can't find the insn. */
2140 next_cc0_user (insn)
2143 rtx note = find_reg_note (insn, REG_CC_USER, NULL_RTX);
2146 return XEXP (note, 0);
2148 insn = next_nonnote_insn (insn);
2149 if (insn && GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
2150 insn = XVECEXP (PATTERN (insn), 0, 0);
2152 if (insn && GET_RTX_CLASS (GET_CODE (insn)) == 'i'
2153 && reg_mentioned_p (cc0_rtx, PATTERN (insn)))
2159 /* Find the insn that set CC0 for INSN. Unless INSN has a REG_CC_SETTER
2160 note, it is the previous insn. */
2163 prev_cc0_setter (insn)
2166 rtx note = find_reg_note (insn, REG_CC_SETTER, NULL_RTX);
2169 return XEXP (note, 0);
2171 insn = prev_nonnote_insn (insn);
2172 if (! sets_cc0_p (PATTERN (insn)))
2179 /* Try splitting insns that can be split for better scheduling.
2180 PAT is the pattern which might split.
2181 TRIAL is the insn providing PAT.
2182 LAST is non-zero if we should return the last insn of the sequence produced.
2184 If this routine succeeds in splitting, it returns the first or last
2185 replacement insn depending on the value of LAST. Otherwise, it
2186 returns TRIAL. If the insn to be returned can be split, it will be. */
2189 try_split (pat, trial, last)
2193 rtx before = PREV_INSN (trial);
2194 rtx after = NEXT_INSN (trial);
2195 rtx seq = split_insns (pat, trial);
2196 int has_barrier = 0;
2199 /* If we are splitting a JUMP_INSN, it might be followed by a BARRIER.
2200 We may need to handle this specially. */
2201 if (after && GET_CODE (after) == BARRIER)
2204 after = NEXT_INSN (after);
2209 /* SEQ can either be a SEQUENCE or the pattern of a single insn.
2210 The latter case will normally arise only when being done so that
2211 it, in turn, will be split (SFmode on the 29k is an example). */
2212 if (GET_CODE (seq) == SEQUENCE)
2214 /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
2215 SEQ and copy our JUMP_LABEL to it. If JUMP_LABEL is non-zero,
2216 increment the usage count so we don't delete the label. */
2219 if (GET_CODE (trial) == JUMP_INSN)
2220 for (i = XVECLEN (seq, 0) - 1; i >= 0; i--)
2221 if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN)
2223 JUMP_LABEL (XVECEXP (seq, 0, i)) = JUMP_LABEL (trial);
2225 if (JUMP_LABEL (trial))
2226 LABEL_NUSES (JUMP_LABEL (trial))++;
2229 tem = emit_insn_after (seq, before);
2231 delete_insn (trial);
2233 emit_barrier_after (tem);
2235 /* Recursively call try_split for each new insn created; by the
2236 time control returns here that insn will be fully split, so
2237 set LAST and continue from the insn after the one returned.
2238 We can't use next_active_insn here since AFTER may be a note.
2239 Ignore deleted insns, which can be occur if not optimizing. */
2240 for (tem = NEXT_INSN (before); tem != after;
2241 tem = NEXT_INSN (tem))
2242 if (! INSN_DELETED_P (tem)
2243 && GET_RTX_CLASS (GET_CODE (tem)) == 'i')
2244 tem = try_split (PATTERN (tem), tem, 1);
2246 /* Avoid infinite loop if the result matches the original pattern. */
2247 else if (rtx_equal_p (seq, pat))
2251 PATTERN (trial) = seq;
2252 INSN_CODE (trial) = -1;
2253 try_split (seq, trial, last);
2256 /* Return either the first or the last insn, depending on which was
2258 return last ? prev_active_insn (after) : next_active_insn (before);
2264 /* Make and return an INSN rtx, initializing all its slots.
2265 Store PATTERN in the pattern slots. */
2268 make_insn_raw (pattern)
2273 /* If in RTL generation phase, see if FREE_INSN can be used. */
2274 if (!ggc_p && free_insn != 0 && rtx_equal_function_value_matters)
2277 free_insn = NEXT_INSN (free_insn);
2278 PUT_CODE (insn, INSN);
2281 insn = rtx_alloc (INSN);
2283 INSN_UID (insn) = cur_insn_uid++;
2284 PATTERN (insn) = pattern;
2285 INSN_CODE (insn) = -1;
2286 LOG_LINKS (insn) = NULL;
2287 REG_NOTES (insn) = NULL;
2292 /* Like `make_insn' but make a JUMP_INSN instead of an insn. */
2295 make_jump_insn_raw (pattern)
2300 insn = rtx_alloc (JUMP_INSN);
2301 INSN_UID (insn) = cur_insn_uid++;
2303 PATTERN (insn) = pattern;
2304 INSN_CODE (insn) = -1;
2305 LOG_LINKS (insn) = NULL;
2306 REG_NOTES (insn) = NULL;
2307 JUMP_LABEL (insn) = NULL;
2312 /* Like `make_insn' but make a CALL_INSN instead of an insn. */
2315 make_call_insn_raw (pattern)
2320 insn = rtx_alloc (CALL_INSN);
2321 INSN_UID (insn) = cur_insn_uid++;
2323 PATTERN (insn) = pattern;
2324 INSN_CODE (insn) = -1;
2325 LOG_LINKS (insn) = NULL;
2326 REG_NOTES (insn) = NULL;
2327 CALL_INSN_FUNCTION_USAGE (insn) = NULL;
2332 /* Add INSN to the end of the doubly-linked list.
2333 INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE. */
2339 PREV_INSN (insn) = last_insn;
2340 NEXT_INSN (insn) = 0;
2342 if (NULL != last_insn)
2343 NEXT_INSN (last_insn) = insn;
2345 if (NULL == first_insn)
2351 /* Add INSN into the doubly-linked list after insn AFTER. This and
2352 the next should be the only functions called to insert an insn once
2353 delay slots have been filled since only they know how to update a
2357 add_insn_after (insn, after)
2360 rtx next = NEXT_INSN (after);
2362 if (optimize && INSN_DELETED_P (after))
2365 NEXT_INSN (insn) = next;
2366 PREV_INSN (insn) = after;
2370 PREV_INSN (next) = insn;
2371 if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2372 PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = insn;
2374 else if (last_insn == after)
2378 struct sequence_stack *stack = seq_stack;
2379 /* Scan all pending sequences too. */
2380 for (; stack; stack = stack->next)
2381 if (after == stack->last)
2391 NEXT_INSN (after) = insn;
2392 if (GET_CODE (after) == INSN && GET_CODE (PATTERN (after)) == SEQUENCE)
2394 rtx sequence = PATTERN (after);
2395 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2399 /* Add INSN into the doubly-linked list before insn BEFORE. This and
2400 the previous should be the only functions called to insert an insn once
2401 delay slots have been filled since only they know how to update a
2405 add_insn_before (insn, before)
2408 rtx prev = PREV_INSN (before);
2410 if (optimize && INSN_DELETED_P (before))
2413 PREV_INSN (insn) = prev;
2414 NEXT_INSN (insn) = before;
2418 NEXT_INSN (prev) = insn;
2419 if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2421 rtx sequence = PATTERN (prev);
2422 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = insn;
2425 else if (first_insn == before)
2429 struct sequence_stack *stack = seq_stack;
2430 /* Scan all pending sequences too. */
2431 for (; stack; stack = stack->next)
2432 if (before == stack->first)
2434 stack->first = insn;
2442 PREV_INSN (before) = insn;
2443 if (GET_CODE (before) == INSN && GET_CODE (PATTERN (before)) == SEQUENCE)
2444 PREV_INSN (XVECEXP (PATTERN (before), 0, 0)) = insn;
2447 /* Remove an insn from its doubly-linked list. This function knows how
2448 to handle sequences. */
2453 rtx next = NEXT_INSN (insn);
2454 rtx prev = PREV_INSN (insn);
2457 NEXT_INSN (prev) = next;
2458 if (GET_CODE (prev) == INSN && GET_CODE (PATTERN (prev)) == SEQUENCE)
2460 rtx sequence = PATTERN (prev);
2461 NEXT_INSN (XVECEXP (sequence, 0, XVECLEN (sequence, 0) - 1)) = next;
2464 else if (first_insn == insn)
2468 struct sequence_stack *stack = seq_stack;
2469 /* Scan all pending sequences too. */
2470 for (; stack; stack = stack->next)
2471 if (insn == stack->first)
2473 stack->first = next;
2483 PREV_INSN (next) = prev;
2484 if (GET_CODE (next) == INSN && GET_CODE (PATTERN (next)) == SEQUENCE)
2485 PREV_INSN (XVECEXP (PATTERN (next), 0, 0)) = prev;
2487 else if (last_insn == insn)
2491 struct sequence_stack *stack = seq_stack;
2492 /* Scan all pending sequences too. */
2493 for (; stack; stack = stack->next)
2494 if (insn == stack->last)
2505 /* Delete all insns made since FROM.
2506 FROM becomes the new last instruction. */
2509 delete_insns_since (from)
2515 NEXT_INSN (from) = 0;
2519 /* This function is deprecated, please use sequences instead.
2521 Move a consecutive bunch of insns to a different place in the chain.
2522 The insns to be moved are those between FROM and TO.
2523 They are moved to a new position after the insn AFTER.
2524 AFTER must not be FROM or TO or any insn in between.
2526 This function does not know about SEQUENCEs and hence should not be
2527 called after delay-slot filling has been done. */
2530 reorder_insns (from, to, after)
2531 rtx from, to, after;
2533 /* Splice this bunch out of where it is now. */
2534 if (PREV_INSN (from))
2535 NEXT_INSN (PREV_INSN (from)) = NEXT_INSN (to);
2537 PREV_INSN (NEXT_INSN (to)) = PREV_INSN (from);
2538 if (last_insn == to)
2539 last_insn = PREV_INSN (from);
2540 if (first_insn == from)
2541 first_insn = NEXT_INSN (to);
2543 /* Make the new neighbors point to it and it to them. */
2544 if (NEXT_INSN (after))
2545 PREV_INSN (NEXT_INSN (after)) = to;
2547 NEXT_INSN (to) = NEXT_INSN (after);
2548 PREV_INSN (from) = after;
2549 NEXT_INSN (after) = from;
2550 if (after == last_insn)
2554 /* Return the line note insn preceding INSN. */
2557 find_line_note (insn)
2560 if (no_line_numbers)
2563 for (; insn; insn = PREV_INSN (insn))
2564 if (GET_CODE (insn) == NOTE
2565 && NOTE_LINE_NUMBER (insn) >= 0)
2571 /* Like reorder_insns, but inserts line notes to preserve the line numbers
2572 of the moved insns when debugging. This may insert a note between AFTER
2573 and FROM, and another one after TO. */
2576 reorder_insns_with_line_notes (from, to, after)
2577 rtx from, to, after;
2579 rtx from_line = find_line_note (from);
2580 rtx after_line = find_line_note (after);
2582 reorder_insns (from, to, after);
2584 if (from_line == after_line)
2588 emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2589 NOTE_LINE_NUMBER (from_line),
2592 emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2593 NOTE_LINE_NUMBER (after_line),
2597 /* Emit an insn of given code and pattern
2598 at a specified place within the doubly-linked list. */
2600 /* Make an instruction with body PATTERN
2601 and output it before the instruction BEFORE. */
2604 emit_insn_before (pattern, before)
2605 register rtx pattern, before;
2607 register rtx insn = before;
2609 if (GET_CODE (pattern) == SEQUENCE)
2613 for (i = 0; i < XVECLEN (pattern, 0); i++)
2615 insn = XVECEXP (pattern, 0, i);
2616 add_insn_before (insn, before);
2618 if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2619 sequence_result[XVECLEN (pattern, 0)] = pattern;
2623 insn = make_insn_raw (pattern);
2624 add_insn_before (insn, before);
2630 /* Make an instruction with body PATTERN and code JUMP_INSN
2631 and output it before the instruction BEFORE. */
2634 emit_jump_insn_before (pattern, before)
2635 register rtx pattern, before;
2639 if (GET_CODE (pattern) == SEQUENCE)
2640 insn = emit_insn_before (pattern, before);
2643 insn = make_jump_insn_raw (pattern);
2644 add_insn_before (insn, before);
2650 /* Make an instruction with body PATTERN and code CALL_INSN
2651 and output it before the instruction BEFORE. */
2654 emit_call_insn_before (pattern, before)
2655 register rtx pattern, before;
2659 if (GET_CODE (pattern) == SEQUENCE)
2660 insn = emit_insn_before (pattern, before);
2663 insn = make_call_insn_raw (pattern);
2664 add_insn_before (insn, before);
2665 PUT_CODE (insn, CALL_INSN);
2671 /* Make an insn of code BARRIER
2672 and output it before the insn BEFORE. */
2675 emit_barrier_before (before)
2676 register rtx before;
2678 register rtx insn = rtx_alloc (BARRIER);
2680 INSN_UID (insn) = cur_insn_uid++;
2682 add_insn_before (insn, before);
2686 /* Emit the label LABEL before the insn BEFORE. */
2689 emit_label_before (label, before)
2692 /* This can be called twice for the same label as a result of the
2693 confusion that follows a syntax error! So make it harmless. */
2694 if (INSN_UID (label) == 0)
2696 INSN_UID (label) = cur_insn_uid++;
2697 add_insn_before (label, before);
2703 /* Emit a note of subtype SUBTYPE before the insn BEFORE. */
2706 emit_note_before (subtype, before)
2710 register rtx note = rtx_alloc (NOTE);
2711 INSN_UID (note) = cur_insn_uid++;
2712 NOTE_SOURCE_FILE (note) = 0;
2713 NOTE_LINE_NUMBER (note) = subtype;
2715 add_insn_before (note, before);
2719 /* Make an insn of code INSN with body PATTERN
2720 and output it after the insn AFTER. */
2723 emit_insn_after (pattern, after)
2724 register rtx pattern, after;
2726 register rtx insn = after;
2728 if (GET_CODE (pattern) == SEQUENCE)
2732 for (i = 0; i < XVECLEN (pattern, 0); i++)
2734 insn = XVECEXP (pattern, 0, i);
2735 add_insn_after (insn, after);
2738 if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2739 sequence_result[XVECLEN (pattern, 0)] = pattern;
2743 insn = make_insn_raw (pattern);
2744 add_insn_after (insn, after);
2750 /* Similar to emit_insn_after, except that line notes are to be inserted so
2751 as to act as if this insn were at FROM. */
2754 emit_insn_after_with_line_notes (pattern, after, from)
2755 rtx pattern, after, from;
2757 rtx from_line = find_line_note (from);
2758 rtx after_line = find_line_note (after);
2759 rtx insn = emit_insn_after (pattern, after);
2762 emit_line_note_after (NOTE_SOURCE_FILE (from_line),
2763 NOTE_LINE_NUMBER (from_line),
2767 emit_line_note_after (NOTE_SOURCE_FILE (after_line),
2768 NOTE_LINE_NUMBER (after_line),
2772 /* Make an insn of code JUMP_INSN with body PATTERN
2773 and output it after the insn AFTER. */
2776 emit_jump_insn_after (pattern, after)
2777 register rtx pattern, after;
2781 if (GET_CODE (pattern) == SEQUENCE)
2782 insn = emit_insn_after (pattern, after);
2785 insn = make_jump_insn_raw (pattern);
2786 add_insn_after (insn, after);
2792 /* Make an insn of code BARRIER
2793 and output it after the insn AFTER. */
2796 emit_barrier_after (after)
2799 register rtx insn = rtx_alloc (BARRIER);
2801 INSN_UID (insn) = cur_insn_uid++;
2803 add_insn_after (insn, after);
2807 /* Emit the label LABEL after the insn AFTER. */
2810 emit_label_after (label, after)
2813 /* This can be called twice for the same label
2814 as a result of the confusion that follows a syntax error!
2815 So make it harmless. */
2816 if (INSN_UID (label) == 0)
2818 INSN_UID (label) = cur_insn_uid++;
2819 add_insn_after (label, after);
2825 /* Emit a note of subtype SUBTYPE after the insn AFTER. */
2828 emit_note_after (subtype, after)
2832 register rtx note = rtx_alloc (NOTE);
2833 INSN_UID (note) = cur_insn_uid++;
2834 NOTE_SOURCE_FILE (note) = 0;
2835 NOTE_LINE_NUMBER (note) = subtype;
2836 add_insn_after (note, after);
2840 /* Emit a line note for FILE and LINE after the insn AFTER. */
2843 emit_line_note_after (file, line, after)
2850 if (no_line_numbers && line > 0)
2856 note = rtx_alloc (NOTE);
2857 INSN_UID (note) = cur_insn_uid++;
2858 NOTE_SOURCE_FILE (note) = file;
2859 NOTE_LINE_NUMBER (note) = line;
2860 add_insn_after (note, after);
2864 /* Make an insn of code INSN with pattern PATTERN
2865 and add it to the end of the doubly-linked list.
2866 If PATTERN is a SEQUENCE, take the elements of it
2867 and emit an insn for each element.
2869 Returns the last insn emitted. */
2875 rtx insn = last_insn;
2877 if (GET_CODE (pattern) == SEQUENCE)
2881 for (i = 0; i < XVECLEN (pattern, 0); i++)
2883 insn = XVECEXP (pattern, 0, i);
2886 if (!ggc_p && XVECLEN (pattern, 0) < SEQUENCE_RESULT_SIZE)
2887 sequence_result[XVECLEN (pattern, 0)] = pattern;
2891 insn = make_insn_raw (pattern);
2898 /* Emit the insns in a chain starting with INSN.
2899 Return the last insn emitted. */
2909 rtx next = NEXT_INSN (insn);
2918 /* Emit the insns in a chain starting with INSN and place them in front of
2919 the insn BEFORE. Return the last insn emitted. */
2922 emit_insns_before (insn, before)
2930 rtx next = NEXT_INSN (insn);
2931 add_insn_before (insn, before);
2939 /* Emit the insns in a chain starting with FIRST and place them in back of
2940 the insn AFTER. Return the last insn emitted. */
2943 emit_insns_after (first, after)
2948 register rtx after_after;
2956 for (last = first; NEXT_INSN (last); last = NEXT_INSN (last))
2959 after_after = NEXT_INSN (after);
2961 NEXT_INSN (after) = first;
2962 PREV_INSN (first) = after;
2963 NEXT_INSN (last) = after_after;
2965 PREV_INSN (after_after) = last;
2967 if (after == last_insn)
2972 /* Make an insn of code JUMP_INSN with pattern PATTERN
2973 and add it to the end of the doubly-linked list. */
2976 emit_jump_insn (pattern)
2979 if (GET_CODE (pattern) == SEQUENCE)
2980 return emit_insn (pattern);
2983 register rtx insn = make_jump_insn_raw (pattern);
2989 /* Make an insn of code CALL_INSN with pattern PATTERN
2990 and add it to the end of the doubly-linked list. */
2993 emit_call_insn (pattern)
2996 if (GET_CODE (pattern) == SEQUENCE)
2997 return emit_insn (pattern);
3000 register rtx insn = make_call_insn_raw (pattern);
3002 PUT_CODE (insn, CALL_INSN);
3007 /* Add the label LABEL to the end of the doubly-linked list. */
3013 /* This can be called twice for the same label
3014 as a result of the confusion that follows a syntax error!
3015 So make it harmless. */
3016 if (INSN_UID (label) == 0)
3018 INSN_UID (label) = cur_insn_uid++;
3024 /* Make an insn of code BARRIER
3025 and add it to the end of the doubly-linked list. */
3030 register rtx barrier = rtx_alloc (BARRIER);
3031 INSN_UID (barrier) = cur_insn_uid++;
3036 /* Make an insn of code NOTE
3037 with data-fields specified by FILE and LINE
3038 and add it to the end of the doubly-linked list,
3039 but only if line-numbers are desired for debugging info. */
3042 emit_line_note (file, line)
3046 set_file_and_line_for_stmt (file, line);
3049 if (no_line_numbers)
3053 return emit_note (file, line);
3056 /* Make an insn of code NOTE
3057 with data-fields specified by FILE and LINE
3058 and add it to the end of the doubly-linked list.
3059 If it is a line-number NOTE, omit it if it matches the previous one. */
3062 emit_note (file, line)
3070 if (file && last_filename && !strcmp (file, last_filename)
3071 && line == last_linenum)
3073 last_filename = file;
3074 last_linenum = line;
3077 if (no_line_numbers && line > 0)
3083 note = rtx_alloc (NOTE);
3084 INSN_UID (note) = cur_insn_uid++;
3085 NOTE_SOURCE_FILE (note) = file;
3086 NOTE_LINE_NUMBER (note) = line;
3091 /* Emit a NOTE, and don't omit it even if LINE is the previous note. */
3094 emit_line_note_force (file, line)
3099 return emit_line_note (file, line);
3102 /* Cause next statement to emit a line note even if the line number
3103 has not changed. This is used at the beginning of a function. */
3106 force_next_line_note ()
3111 /* Place a note of KIND on insn INSN with DATUM as the datum. If a
3112 note of this type already exists, remove it first. */
3115 set_unique_reg_note (insn, kind, datum)
3120 rtx note = find_reg_note (insn, kind, NULL_RTX);
3122 /* First remove the note if there already is one. */
3124 remove_note (insn, note);
3126 REG_NOTES (insn) = gen_rtx_EXPR_LIST (kind, datum, REG_NOTES (insn));
3129 /* Return an indication of which type of insn should have X as a body.
3130 The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN. */
3136 if (GET_CODE (x) == CODE_LABEL)
3138 if (GET_CODE (x) == CALL)
3140 if (GET_CODE (x) == RETURN)
3142 if (GET_CODE (x) == SET)
3144 if (SET_DEST (x) == pc_rtx)
3146 else if (GET_CODE (SET_SRC (x)) == CALL)
3151 if (GET_CODE (x) == PARALLEL)
3154 for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
3155 if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
3157 else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3158 && SET_DEST (XVECEXP (x, 0, j)) == pc_rtx)
3160 else if (GET_CODE (XVECEXP (x, 0, j)) == SET
3161 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
3167 /* Emit the rtl pattern X as an appropriate kind of insn.
3168 If X is a label, it is simply added into the insn chain. */
3174 enum rtx_code code = classify_insn (x);
3176 if (code == CODE_LABEL)
3177 return emit_label (x);
3178 else if (code == INSN)
3179 return emit_insn (x);
3180 else if (code == JUMP_INSN)
3182 register rtx insn = emit_jump_insn (x);
3183 if (simplejump_p (insn) || GET_CODE (x) == RETURN)
3184 return emit_barrier ();
3187 else if (code == CALL_INSN)
3188 return emit_call_insn (x);
3193 /* Begin emitting insns to a sequence which can be packaged in an
3194 RTL_EXPR. If this sequence will contain something that might cause
3195 the compiler to pop arguments to function calls (because those
3196 pops have previously been deferred; see INHIBIT_DEFER_POP for more
3197 details), use do_pending_stack_adjust before calling this function.
3198 That will ensure that the deferred pops are not accidentally
3199 emitted in the middel of this sequence. */
3204 struct sequence_stack *tem;
3206 tem = (struct sequence_stack *) xmalloc (sizeof (struct sequence_stack));
3208 tem->next = seq_stack;
3209 tem->first = first_insn;
3210 tem->last = last_insn;
3211 tem->sequence_rtl_expr = seq_rtl_expr;
3219 /* Similarly, but indicate that this sequence will be placed in T, an
3220 RTL_EXPR. See the documentation for start_sequence for more
3221 information about how to use this function. */
3224 start_sequence_for_rtl_expr (t)
3232 /* Set up the insn chain starting with FIRST as the current sequence,
3233 saving the previously current one. See the documentation for
3234 start_sequence for more information about how to use this function. */
3237 push_to_sequence (first)
3244 for (last = first; last && NEXT_INSN (last); last = NEXT_INSN (last));
3250 /* Set up the outer-level insn chain
3251 as the current sequence, saving the previously current one. */
3254 push_topmost_sequence ()
3256 struct sequence_stack *stack, *top = NULL;
3260 for (stack = seq_stack; stack; stack = stack->next)
3263 first_insn = top->first;
3264 last_insn = top->last;
3265 seq_rtl_expr = top->sequence_rtl_expr;
3268 /* After emitting to the outer-level insn chain, update the outer-level
3269 insn chain, and restore the previous saved state. */
3272 pop_topmost_sequence ()
3274 struct sequence_stack *stack, *top = NULL;
3276 for (stack = seq_stack; stack; stack = stack->next)
3279 top->first = first_insn;
3280 top->last = last_insn;
3281 /* ??? Why don't we save seq_rtl_expr here? */
3286 /* After emitting to a sequence, restore previous saved state.
3288 To get the contents of the sequence just made, you must call
3289 `gen_sequence' *before* calling here.
3291 If the compiler might have deferred popping arguments while
3292 generating this sequence, and this sequence will not be immediately
3293 inserted into the instruction stream, use do_pending_stack_adjust
3294 before calling gen_sequence. That will ensure that the deferred
3295 pops are inserted into this sequence, and not into some random
3296 location in the instruction stream. See INHIBIT_DEFER_POP for more
3297 information about deferred popping of arguments. */
3302 struct sequence_stack *tem = seq_stack;
3304 first_insn = tem->first;
3305 last_insn = tem->last;
3306 seq_rtl_expr = tem->sequence_rtl_expr;
3307 seq_stack = tem->next;
3312 /* Return 1 if currently emitting into a sequence. */
3317 return seq_stack != 0;
3320 /* Generate a SEQUENCE rtx containing the insns already emitted
3321 to the current sequence.
3323 This is how the gen_... function from a DEFINE_EXPAND
3324 constructs the SEQUENCE that it returns. */
3334 /* Count the insns in the chain. */
3336 for (tem = first_insn; tem; tem = NEXT_INSN (tem))
3339 /* If only one insn, return its pattern rather than a SEQUENCE.
3340 (Now that we cache SEQUENCE expressions, it isn't worth special-casing
3341 the case of an empty list.) */
3343 && ! RTX_FRAME_RELATED_P (first_insn)
3344 && (GET_CODE (first_insn) == INSN
3345 || GET_CODE (first_insn) == JUMP_INSN
3346 /* Don't discard the call usage field. */
3347 || (GET_CODE (first_insn) == CALL_INSN
3348 && CALL_INSN_FUNCTION_USAGE (first_insn) == NULL_RTX)))
3352 NEXT_INSN (first_insn) = free_insn;
3353 free_insn = first_insn;
3355 return PATTERN (first_insn);
3358 /* Put them in a vector. See if we already have a SEQUENCE of the
3359 appropriate length around. */
3360 if (!ggc_p && len < SEQUENCE_RESULT_SIZE
3361 && (result = sequence_result[len]) != 0)
3362 sequence_result[len] = 0;
3365 /* Ensure that this rtl goes in saveable_obstack, since we may
3367 push_obstacks_nochange ();
3368 rtl_in_saveable_obstack ();
3369 result = gen_rtx_SEQUENCE (VOIDmode, rtvec_alloc (len));
3373 for (i = 0, tem = first_insn; tem; tem = NEXT_INSN (tem), i++)
3374 XVECEXP (result, 0, i) = tem;
3379 /* Put the various virtual registers into REGNO_REG_RTX. */
3382 init_virtual_regs (es)
3383 struct emit_status *es;
3385 rtx *ptr = es->x_regno_reg_rtx;
3386 ptr[VIRTUAL_INCOMING_ARGS_REGNUM] = virtual_incoming_args_rtx;
3387 ptr[VIRTUAL_STACK_VARS_REGNUM] = virtual_stack_vars_rtx;
3388 ptr[VIRTUAL_STACK_DYNAMIC_REGNUM] = virtual_stack_dynamic_rtx;
3389 ptr[VIRTUAL_OUTGOING_ARGS_REGNUM] = virtual_outgoing_args_rtx;
3390 ptr[VIRTUAL_CFA_REGNUM] = virtual_cfa_rtx;
3394 clear_emit_caches ()
3398 /* Clear the start_sequence/gen_sequence cache. */
3399 for (i = 0; i < SEQUENCE_RESULT_SIZE; i++)
3400 sequence_result[i] = 0;
3404 /* Initialize data structures and variables in this file
3405 before generating rtl for each function. */
3410 struct function *f = current_function;
3412 f->emit = (struct emit_status *) xmalloc (sizeof (struct emit_status));
3415 seq_rtl_expr = NULL;
3417 reg_rtx_no = LAST_VIRTUAL_REGISTER + 1;
3420 first_label_num = label_num;
3424 clear_emit_caches ();
3426 /* Init the tables that describe all the pseudo regs. */
3428 f->emit->regno_pointer_flag_length = LAST_VIRTUAL_REGISTER + 101;
3430 f->emit->regno_pointer_flag
3431 = (char *) xcalloc (f->emit->regno_pointer_flag_length, sizeof (char));
3433 f->emit->regno_pointer_align
3434 = (char *) xcalloc (f->emit->regno_pointer_flag_length,
3438 = (rtx *) xcalloc (f->emit->regno_pointer_flag_length * sizeof (rtx),
3441 /* Put copies of all the virtual register rtx into regno_reg_rtx. */
3442 init_virtual_regs (f->emit);
3444 /* Indicate that the virtual registers and stack locations are
3446 REGNO_POINTER_FLAG (STACK_POINTER_REGNUM) = 1;
3447 REGNO_POINTER_FLAG (FRAME_POINTER_REGNUM) = 1;
3448 REGNO_POINTER_FLAG (HARD_FRAME_POINTER_REGNUM) = 1;
3449 REGNO_POINTER_FLAG (ARG_POINTER_REGNUM) = 1;
3451 REGNO_POINTER_FLAG (VIRTUAL_INCOMING_ARGS_REGNUM) = 1;
3452 REGNO_POINTER_FLAG (VIRTUAL_STACK_VARS_REGNUM) = 1;
3453 REGNO_POINTER_FLAG (VIRTUAL_STACK_DYNAMIC_REGNUM) = 1;
3454 REGNO_POINTER_FLAG (VIRTUAL_OUTGOING_ARGS_REGNUM) = 1;
3455 REGNO_POINTER_FLAG (VIRTUAL_CFA_REGNUM) = 1;
3457 #ifdef STACK_BOUNDARY
3458 REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3459 REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3460 REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM)
3461 = STACK_BOUNDARY / BITS_PER_UNIT;
3462 REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = STACK_BOUNDARY / BITS_PER_UNIT;
3464 REGNO_POINTER_ALIGN (VIRTUAL_INCOMING_ARGS_REGNUM)
3465 = STACK_BOUNDARY / BITS_PER_UNIT;
3466 REGNO_POINTER_ALIGN (VIRTUAL_STACK_VARS_REGNUM)
3467 = STACK_BOUNDARY / BITS_PER_UNIT;
3468 REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM)
3469 = STACK_BOUNDARY / BITS_PER_UNIT;
3470 REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM)
3471 = STACK_BOUNDARY / BITS_PER_UNIT;
3472 REGNO_POINTER_ALIGN (VIRTUAL_CFA_REGNUM) = UNITS_PER_WORD;
3475 #ifdef INIT_EXPANDERS
3480 /* Mark SS for GC. */
3483 mark_sequence_stack (ss)
3484 struct sequence_stack *ss;
3488 ggc_mark_rtx (ss->first);
3489 ggc_mark_tree (ss->sequence_rtl_expr);
3494 /* Mark ES for GC. */
3497 mark_emit_state (es)
3498 struct emit_status *es;
3506 for (i = es->regno_pointer_flag_length, r = es->x_regno_reg_rtx;
3510 mark_sequence_stack (es->sequence_stack);
3511 ggc_mark_tree (es->sequence_rtl_expr);
3512 ggc_mark_rtx (es->x_first_insn);
3515 /* Create some permanent unique rtl objects shared between all functions.
3516 LINE_NUMBERS is nonzero if line numbers are to be generated. */
3519 init_emit_once (line_numbers)
3523 enum machine_mode mode;
3524 enum machine_mode double_mode;
3526 no_line_numbers = ! line_numbers;
3528 /* Compute the word and byte modes. */
3530 byte_mode = VOIDmode;
3531 word_mode = VOIDmode;
3532 double_mode = VOIDmode;
3534 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3535 mode = GET_MODE_WIDER_MODE (mode))
3537 if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
3538 && byte_mode == VOIDmode)
3541 if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
3542 && word_mode == VOIDmode)
3546 #ifndef DOUBLE_TYPE_SIZE
3547 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
3550 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3551 mode = GET_MODE_WIDER_MODE (mode))
3553 if (GET_MODE_BITSIZE (mode) == DOUBLE_TYPE_SIZE
3554 && double_mode == VOIDmode)
3558 ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0);
3560 /* Create the unique rtx's for certain rtx codes and operand values. */
3562 /* Don't use gen_rtx here since gen_rtx in this case
3563 tries to use these variables. */
3564 for (i = - MAX_SAVED_CONST_INT; i <= MAX_SAVED_CONST_INT; i++)
3566 PUT_CODE (&const_int_rtx[i + MAX_SAVED_CONST_INT], CONST_INT);
3567 PUT_MODE (&const_int_rtx[i + MAX_SAVED_CONST_INT], VOIDmode);
3568 INTVAL (&const_int_rtx[i + MAX_SAVED_CONST_INT]) = i;
3571 if (STORE_FLAG_VALUE >= - MAX_SAVED_CONST_INT
3572 && STORE_FLAG_VALUE <= MAX_SAVED_CONST_INT)
3573 const_true_rtx = &const_int_rtx[STORE_FLAG_VALUE + MAX_SAVED_CONST_INT];
3575 const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
3577 dconst0 = REAL_VALUE_ATOF ("0", double_mode);
3578 dconst1 = REAL_VALUE_ATOF ("1", double_mode);
3579 dconst2 = REAL_VALUE_ATOF ("2", double_mode);
3580 dconstm1 = REAL_VALUE_ATOF ("-1", double_mode);
3582 for (i = 0; i <= 2; i++)
3584 for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode;
3585 mode = GET_MODE_WIDER_MODE (mode))
3587 rtx tem = rtx_alloc (CONST_DOUBLE);
3588 union real_extract u;
3590 bzero ((char *) &u, sizeof u); /* Zero any holes in a structure. */
3591 u.d = i == 0 ? dconst0 : i == 1 ? dconst1 : dconst2;
3593 bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (tem), sizeof u);
3594 CONST_DOUBLE_MEM (tem) = cc0_rtx;
3595 PUT_MODE (tem, mode);
3597 const_tiny_rtx[i][(int) mode] = tem;
3600 const_tiny_rtx[i][(int) VOIDmode] = GEN_INT (i);
3602 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
3603 mode = GET_MODE_WIDER_MODE (mode))
3604 const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3606 for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT);
3608 mode = GET_MODE_WIDER_MODE (mode))
3609 const_tiny_rtx[i][(int) mode] = GEN_INT (i);
3612 for (mode = CCmode; mode < MAX_MACHINE_MODE; ++mode)
3613 if (GET_MODE_CLASS (mode) == MODE_CC)
3614 const_tiny_rtx[0][(int) mode] = const0_rtx;
3616 /* Assign register numbers to the globally defined register rtx.
3617 This must be done at runtime because the register number field
3618 is in a union and some compilers can't initialize unions. */
3620 REGNO (stack_pointer_rtx) = STACK_POINTER_REGNUM;
3621 PUT_MODE (stack_pointer_rtx, Pmode);
3622 REGNO (frame_pointer_rtx) = FRAME_POINTER_REGNUM;
3623 PUT_MODE (frame_pointer_rtx, Pmode);
3624 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
3625 REGNO (hard_frame_pointer_rtx) = HARD_FRAME_POINTER_REGNUM;
3626 PUT_MODE (hard_frame_pointer_rtx, Pmode);
3628 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3629 REGNO (arg_pointer_rtx) = ARG_POINTER_REGNUM;
3630 PUT_MODE (arg_pointer_rtx, Pmode);
3633 REGNO (virtual_incoming_args_rtx) = VIRTUAL_INCOMING_ARGS_REGNUM;
3634 PUT_MODE (virtual_incoming_args_rtx, Pmode);
3635 REGNO (virtual_stack_vars_rtx) = VIRTUAL_STACK_VARS_REGNUM;
3636 PUT_MODE (virtual_stack_vars_rtx, Pmode);
3637 REGNO (virtual_stack_dynamic_rtx) = VIRTUAL_STACK_DYNAMIC_REGNUM;
3638 PUT_MODE (virtual_stack_dynamic_rtx, Pmode);
3639 REGNO (virtual_outgoing_args_rtx) = VIRTUAL_OUTGOING_ARGS_REGNUM;
3640 PUT_MODE (virtual_outgoing_args_rtx, Pmode);
3641 REGNO (virtual_cfa_rtx) = VIRTUAL_CFA_REGNUM;
3642 PUT_MODE (virtual_cfa_rtx, Pmode);
3644 #ifdef RETURN_ADDRESS_POINTER_REGNUM
3645 return_address_pointer_rtx
3646 = gen_rtx_raw_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM);
3650 struct_value_rtx = STRUCT_VALUE;
3652 struct_value_rtx = gen_rtx_REG (Pmode, STRUCT_VALUE_REGNUM);
3655 #ifdef STRUCT_VALUE_INCOMING
3656 struct_value_incoming_rtx = STRUCT_VALUE_INCOMING;
3658 #ifdef STRUCT_VALUE_INCOMING_REGNUM
3659 struct_value_incoming_rtx
3660 = gen_rtx_REG (Pmode, STRUCT_VALUE_INCOMING_REGNUM);
3662 struct_value_incoming_rtx = struct_value_rtx;
3666 #ifdef STATIC_CHAIN_REGNUM
3667 static_chain_rtx = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
3669 #ifdef STATIC_CHAIN_INCOMING_REGNUM
3670 if (STATIC_CHAIN_INCOMING_REGNUM != STATIC_CHAIN_REGNUM)
3671 static_chain_incoming_rtx
3672 = gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
3675 static_chain_incoming_rtx = static_chain_rtx;
3679 static_chain_rtx = STATIC_CHAIN;
3681 #ifdef STATIC_CHAIN_INCOMING
3682 static_chain_incoming_rtx = STATIC_CHAIN_INCOMING;
3684 static_chain_incoming_rtx = static_chain_rtx;
3688 #ifdef PIC_OFFSET_TABLE_REGNUM
3689 pic_offset_table_rtx = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
3692 #ifdef INIT_EXPANDERS
3693 /* This is to initialize save_machine_status and restore_machine_status before
3694 the first call to push_function_context_to. This is needed by the Chill
3695 front end which calls push_function_context_to before the first cal to
3696 init_function_start. */
3700 ggc_add_rtx_root (&const_tiny_rtx[0][0], sizeof(const_tiny_rtx)/sizeof(rtx));
3702 ggc_add_rtx_root (&const_true_rtx, 1);
3703 ggc_add_rtx_root (&pic_offset_table_rtx, 1);
3704 ggc_add_rtx_root (&struct_value_rtx, 1);
3705 ggc_add_rtx_root (&struct_value_incoming_rtx, 1);
3706 ggc_add_rtx_root (&static_chain_rtx, 1);
3707 ggc_add_rtx_root (&static_chain_incoming_rtx, 1);
3708 ggc_add_rtx_root (&return_address_pointer_rtx, 1);
3711 /* Query and clear/ restore no_line_numbers. This is used by the
3712 switch / case handling in stmt.c to give proper line numbers in
3713 warnings about unreachable code. */
3716 force_line_numbers ()
3718 int old = no_line_numbers;
3720 no_line_numbers = 0;
3722 force_next_line_note ();
3727 restore_line_number_status (old_value)
3730 no_line_numbers = old_value;