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. */
47 #include "hard-reg-set.h"
48 #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. */
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__. */
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
];
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
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
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. */
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
;
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
;
265 return gen_rtx_raw_CONST_INT (mode
, arg
);
268 /* CONST_DOUBLEs needs special handling because its length is known
271 gen_rtx_CONST_DOUBLE (mode
, arg0
, arg1
, arg2
)
272 enum machine_mode mode
;
274 HOST_WIDE_INT arg1
, arg2
;
276 rtx r
= rtx_alloc (CONST_DOUBLE
);
281 XEXP (r
, 1) = NULL_RTX
;
285 for (i
= GET_RTX_LENGTH (CONST_DOUBLE
) - 1; i
> 3; --i
)
292 gen_rtx_REG (mode
, regno
)
293 enum machine_mode mode
;
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
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
;
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
;
322 #ifdef RETURN_ADDRESS_POINTER_REGNUM
323 if (regno
== RETURN_ADDRESS_POINTER_REGNUM
)
324 return return_address_pointer_rtx
;
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
;
338 rtx rt
= gen_rtx_raw_MEM (mode
, addr
);
340 /* This field is not cleared by the mere allocation of the rtx, so
342 MEM_ALIAS_SET (rt
) = 0;
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
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)))),
375 gen_rtx
VPROTO((enum rtx_code code
, enum machine_mode mode
, ...))
377 #ifndef ANSI_PROTOTYPES
379 enum machine_mode mode
;
382 register int i
; /* Array indices... */
383 register char *fmt
; /* Current rtx's format... */
384 register rtx rt_val
; /* RTX to return to caller... */
388 #ifndef ANSI_PROTOTYPES
389 code
= va_arg (p
, enum rtx_code
);
390 mode
= va_arg (p
, enum machine_mode
);
396 rt_val
= gen_rtx_CONST_INT (mode
, va_arg (p
, HOST_WIDE_INT
));
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
);
409 rt_val
= gen_rtx_REG (mode
, va_arg (p
, int));
413 rt_val
= gen_rtx_MEM (mode
, va_arg (p
, rtx
));
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
++)
425 case '0': /* Unused field. */
428 case 'i': /* An integer? */
429 XINT (rt_val
, i
) = va_arg (p
, int);
432 case 'w': /* A wide integer? */
433 XWINT (rt_val
, i
) = va_arg (p
, HOST_WIDE_INT
);
436 case 's': /* A string? */
437 XSTR (rt_val
, i
) = va_arg (p
, char *);
440 case 'e': /* An expression? */
441 case 'u': /* An insn? Same except when printing. */
442 XEXP (rt_val
, i
) = va_arg (p
, rtx
);
445 case 'E': /* An RTX vector? */
446 XVEC (rt_val
, i
) = va_arg (p
, rtvec
);
449 case 'b': /* A bitmap? */
450 XBITMAP (rt_val
, i
) = va_arg (p
, bitmap
);
453 case 't': /* A tree? */
454 XTREE (rt_val
, i
) = va_arg (p
, tree
);
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.
476 gen_rtvec
VPROTO((int n
, ...))
478 #ifndef ANSI_PROTOTYPES
487 #ifndef ANSI_PROTOTYPES
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
);
500 return gen_rtvec_v (n
, vector
);
504 gen_rtvec_v (n
, argp
)
509 register rtvec rt_val
;
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
++;
523 gen_rtvec_vv (n
, argp
)
528 register rtvec rt_val
;
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
;
541 /* Generate a REG rtx for a new pseudo register of mode MODE.
542 This pseudo is assigned the next sequential register number. */
546 enum machine_mode mode
;
550 /* Don't let anything called after initial flow analysis create new
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
)
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
;
608 /* Identify REG (which may be a CONCAT) as a user register. */
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;
625 /* Identify REG as a probable pointer register and show its alignment
626 as ALIGN, if nonzero. */
629 mark_reg_pointer (reg
, align
)
633 REGNO_POINTER_FLAG (REGNO (reg
)) = 1;
636 REGNO_POINTER_ALIGN (REGNO (reg
)) = align
;
639 /* Return 1 plus largest pseudo reg number used in the current function. */
647 /* Return 1 + the largest label number used so far in the current function. */
652 if (last_label_num
&& label_num
== base_label_num
)
653 return last_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
;
683 if (GET_MODE (x
) == mode
)
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))
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
))
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
708 This case is used mostly by combine and cse. */
710 if (GET_MODE (XEXP (x
, 0)) == mode
)
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
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
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
)))
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
],
758 /* We want to keep the stack, frame, and arg pointers
760 && x
!= frame_pointer_rtx
761 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
762 && x
!= arg_pointer_rtx
764 && x
!= stack_pointer_rtx
)
765 return gen_rtx_REG (mode
, REGNO (x
) + word
);
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
784 if (GET_MODE_BITSIZE (mode
) >= 2 * HOST_BITS_PER_WIDE_INT
)
786 else if (GET_MODE_BITSIZE (mode
) > HOST_BITS_PER_WIDE_INT
)
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
)));
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
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
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
825 r
= REAL_VALUE_FROM_TARGET_SINGLE (i
);
826 return CONST_DOUBLE_FROM_REAL_VALUE (r
, mode
);
830 union {HOST_WIDE_INT i
; float d
; } u
;
833 return CONST_DOUBLE_FROM_REAL_VALUE (u
.d
, mode
);
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
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);
854 low
= CONST_DOUBLE_LOW (x
), high
= CONST_DOUBLE_HIGH (x
);
856 /* REAL_VALUE_TARGET_DOUBLE takes the addressing order of the
858 if (WORDS_BIG_ENDIAN
)
859 i
[0] = high
, i
[1] = low
;
861 i
[0] = low
, i
[1] = high
;
863 r
= REAL_VALUE_FROM_TARGET_DOUBLE (i
);
864 return CONST_DOUBLE_FROM_REAL_VALUE (r
, mode
);
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);
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
;
879 u
.i
[0] = low
, u
.i
[1] = high
;
882 return CONST_DOUBLE_FROM_REAL_VALUE (u
.d
, mode
);
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
)
896 r
= REAL_VALUE_FROM_TARGET_SINGLE (i
);
897 return CONST_DOUBLE_FROM_REAL_VALUE (r
, mode
);
899 else if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
900 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
901 || flag_pretend_float
)
902 && GET_MODE_CLASS (mode
) == MODE_FLOAT
903 && GET_MODE_SIZE (mode
) == UNITS_PER_WORD
904 && GET_CODE (x
) == CONST_INT
905 && (sizeof (double) * HOST_BITS_PER_CHAR
906 == HOST_BITS_PER_WIDE_INT
))
912 r
= REAL_VALUE_FROM_TARGET_DOUBLE (&i
);
913 return CONST_DOUBLE_FROM_REAL_VALUE (r
, mode
);
917 /* Similarly, if this is converting a floating-point value into a
918 single-word integer. Only do this is the host and target parameters are
921 else if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
922 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
923 || flag_pretend_float
)
924 && (GET_MODE_CLASS (mode
) == MODE_INT
925 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
926 && GET_CODE (x
) == CONST_DOUBLE
927 && GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
928 && GET_MODE_BITSIZE (mode
) == BITS_PER_WORD
)
929 return operand_subword (x
, word
, 0, GET_MODE (x
));
931 /* Similarly, if this is converting a floating-point value into a
932 two-word integer, we can do this one word at a time and make an
933 integer. Only do this is the host and target parameters are
936 else if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
937 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
938 || flag_pretend_float
)
939 && (GET_MODE_CLASS (mode
) == MODE_INT
940 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
941 && GET_CODE (x
) == CONST_DOUBLE
942 && GET_MODE_CLASS (GET_MODE (x
)) == MODE_FLOAT
943 && GET_MODE_BITSIZE (mode
) == 2 * BITS_PER_WORD
)
946 = operand_subword (x
, word
+ WORDS_BIG_ENDIAN
, 0, GET_MODE (x
));
948 = operand_subword (x
, word
+ ! WORDS_BIG_ENDIAN
, 0, GET_MODE (x
));
950 if (lowpart
&& GET_CODE (lowpart
) == CONST_INT
951 && highpart
&& GET_CODE (highpart
) == CONST_INT
)
952 return immed_double_const (INTVAL (lowpart
), INTVAL (highpart
), mode
);
955 /* Otherwise, we can't do this. */
959 /* Return the real part (which has mode MODE) of a complex value X.
960 This always comes at the low address in memory. */
963 gen_realpart (mode
, x
)
964 enum machine_mode mode
;
967 if (GET_CODE (x
) == CONCAT
&& GET_MODE (XEXP (x
, 0)) == mode
)
969 else if (WORDS_BIG_ENDIAN
)
970 return gen_highpart (mode
, x
);
972 return gen_lowpart (mode
, x
);
975 /* Return the imaginary part (which has mode MODE) of a complex value X.
976 This always comes at the high address in memory. */
979 gen_imagpart (mode
, x
)
980 enum machine_mode mode
;
983 if (GET_CODE (x
) == CONCAT
&& GET_MODE (XEXP (x
, 0)) == mode
)
985 else if (WORDS_BIG_ENDIAN
)
986 return gen_lowpart (mode
, x
);
988 return gen_highpart (mode
, x
);
991 /* Return 1 iff X, assumed to be a SUBREG,
992 refers to the real part of the complex value in its containing reg.
993 Complex values are always stored with the real part in the first word,
994 regardless of WORDS_BIG_ENDIAN. */
997 subreg_realpart_p (x
)
1000 if (GET_CODE (x
) != SUBREG
)
1003 return SUBREG_WORD (x
) * UNITS_PER_WORD
< GET_MODE_UNIT_SIZE (GET_MODE (SUBREG_REG (x
)));
1006 /* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a value,
1007 return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
1008 least-significant part of X.
1009 MODE specifies how big a part of X to return;
1010 it usually should not be larger than a word.
1011 If X is a MEM whose address is a QUEUED, the value may be so also. */
1014 gen_lowpart (mode
, x
)
1015 enum machine_mode mode
;
1018 rtx result
= gen_lowpart_common (mode
, x
);
1022 else if (GET_CODE (x
) == REG
)
1024 /* Must be a hard reg that's not valid in MODE. */
1025 result
= gen_lowpart_common (mode
, copy_to_reg (x
));
1030 else if (GET_CODE (x
) == MEM
)
1032 /* The only additional case we can do is MEM. */
1033 register int offset
= 0;
1034 if (WORDS_BIG_ENDIAN
)
1035 offset
= (MAX (GET_MODE_SIZE (GET_MODE (x
)), UNITS_PER_WORD
)
1036 - MAX (GET_MODE_SIZE (mode
), UNITS_PER_WORD
));
1038 if (BYTES_BIG_ENDIAN
)
1039 /* Adjust the address so that the address-after-the-data
1041 offset
-= (MIN (UNITS_PER_WORD
, GET_MODE_SIZE (mode
))
1042 - MIN (UNITS_PER_WORD
, GET_MODE_SIZE (GET_MODE (x
))));
1044 return change_address (x
, mode
, plus_constant (XEXP (x
, 0), offset
));
1046 else if (GET_CODE (x
) == ADDRESSOF
)
1047 return gen_lowpart (mode
, force_reg (GET_MODE (x
), x
));
1052 /* Like `gen_lowpart', but refer to the most significant part.
1053 This is used to access the imaginary part of a complex number. */
1056 gen_highpart (mode
, x
)
1057 enum machine_mode mode
;
1060 /* This case loses if X is a subreg. To catch bugs early,
1061 complain if an invalid MODE is used even in other cases. */
1062 if (GET_MODE_SIZE (mode
) > UNITS_PER_WORD
1063 && GET_MODE_SIZE (mode
) != GET_MODE_UNIT_SIZE (GET_MODE (x
)))
1065 if (GET_CODE (x
) == CONST_DOUBLE
1066 #if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined (REAL_IS_NOT_DOUBLE))
1067 && GET_MODE_CLASS (GET_MODE (x
)) != MODE_FLOAT
1070 return GEN_INT (CONST_DOUBLE_HIGH (x
) & GET_MODE_MASK (mode
));
1071 else if (GET_CODE (x
) == CONST_INT
)
1073 if (HOST_BITS_PER_WIDE_INT
<= BITS_PER_WORD
)
1075 return GEN_INT (INTVAL (x
) >> (HOST_BITS_PER_WIDE_INT
- BITS_PER_WORD
));
1077 else if (GET_CODE (x
) == MEM
)
1079 register int offset
= 0;
1080 if (! WORDS_BIG_ENDIAN
)
1081 offset
= (MAX (GET_MODE_SIZE (GET_MODE (x
)), UNITS_PER_WORD
)
1082 - MAX (GET_MODE_SIZE (mode
), UNITS_PER_WORD
));
1084 if (! BYTES_BIG_ENDIAN
1085 && GET_MODE_SIZE (mode
) < UNITS_PER_WORD
)
1086 offset
-= (GET_MODE_SIZE (mode
)
1087 - MIN (UNITS_PER_WORD
,
1088 GET_MODE_SIZE (GET_MODE (x
))));
1090 return change_address (x
, mode
, plus_constant (XEXP (x
, 0), offset
));
1092 else if (GET_CODE (x
) == SUBREG
)
1094 /* The only time this should occur is when we are looking at a
1095 multi-word item with a SUBREG whose mode is the same as that of the
1096 item. It isn't clear what we would do if it wasn't. */
1097 if (SUBREG_WORD (x
) != 0)
1099 return gen_highpart (mode
, SUBREG_REG (x
));
1101 else if (GET_CODE (x
) == REG
)
1105 /* Let the backend decide how many registers to skip. This is needed
1106 in particular for sparc64 where fp regs are smaller than a word. */
1107 /* ??? Note that subregs are now ambiguous, in that those against
1108 pseudos are sized by the word size, while those against hard
1109 regs are sized by the underlying register size. Better would be
1110 to always interpret the subreg offset parameter as bytes or bits. */
1112 if (WORDS_BIG_ENDIAN
)
1114 else if (REGNO (x
) < FIRST_PSEUDO_REGISTER
)
1115 word
= (HARD_REGNO_NREGS (REGNO (x
), GET_MODE (x
))
1116 - HARD_REGNO_NREGS (REGNO (x
), mode
));
1118 word
= ((GET_MODE_SIZE (GET_MODE (x
))
1119 - MAX (GET_MODE_SIZE (mode
), UNITS_PER_WORD
))
1122 if (REGNO (x
) < FIRST_PSEUDO_REGISTER
1123 /* integrate.c can't handle parts of a return value register. */
1124 && (! REG_FUNCTION_VALUE_P (x
)
1125 || ! rtx_equal_function_value_matters
)
1126 /* We want to keep the stack, frame, and arg pointers special. */
1127 && x
!= frame_pointer_rtx
1128 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1129 && x
!= arg_pointer_rtx
1131 && x
!= stack_pointer_rtx
)
1132 return gen_rtx_REG (mode
, REGNO (x
) + word
);
1134 return gen_rtx_SUBREG (mode
, x
, word
);
1140 /* Return 1 iff X, assumed to be a SUBREG,
1141 refers to the least significant part of its containing reg.
1142 If X is not a SUBREG, always return 1 (it is its own low part!). */
1145 subreg_lowpart_p (x
)
1148 if (GET_CODE (x
) != SUBREG
)
1150 else if (GET_MODE (SUBREG_REG (x
)) == VOIDmode
)
1153 if (WORDS_BIG_ENDIAN
1154 && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
))) > UNITS_PER_WORD
)
1155 return (SUBREG_WORD (x
)
1156 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
)))
1157 - MAX (GET_MODE_SIZE (GET_MODE (x
)), UNITS_PER_WORD
))
1160 return SUBREG_WORD (x
) == 0;
1163 /* Return subword I of operand OP.
1164 The word number, I, is interpreted as the word number starting at the
1165 low-order address. Word 0 is the low-order word if not WORDS_BIG_ENDIAN,
1166 otherwise it is the high-order word.
1168 If we cannot extract the required word, we return zero. Otherwise, an
1169 rtx corresponding to the requested word will be returned.
1171 VALIDATE_ADDRESS is nonzero if the address should be validated. Before
1172 reload has completed, a valid address will always be returned. After
1173 reload, if a valid address cannot be returned, we return zero.
1175 If VALIDATE_ADDRESS is zero, we simply form the required address; validating
1176 it is the responsibility of the caller.
1178 MODE is the mode of OP in case it is a CONST_INT. */
1181 operand_subword (op
, i
, validate_address
, mode
)
1184 int validate_address
;
1185 enum machine_mode mode
;
1188 int size_ratio
= HOST_BITS_PER_WIDE_INT
/ BITS_PER_WORD
;
1189 int bits_per_word
= BITS_PER_WORD
;
1191 if (mode
== VOIDmode
)
1192 mode
= GET_MODE (op
);
1194 if (mode
== VOIDmode
)
1197 /* If OP is narrower than a word, fail. */
1199 && (GET_MODE_SIZE (mode
) < UNITS_PER_WORD
))
1202 /* If we want a word outside OP, return zero. */
1204 && (i
+ 1) * UNITS_PER_WORD
> GET_MODE_SIZE (mode
))
1207 /* If OP is already an integer word, return it. */
1208 if (GET_MODE_CLASS (mode
) == MODE_INT
1209 && GET_MODE_SIZE (mode
) == UNITS_PER_WORD
)
1212 /* If OP is a REG or SUBREG, we can handle it very simply. */
1213 if (GET_CODE (op
) == REG
)
1215 /* ??? There is a potential problem with this code. It does not
1216 properly handle extractions of a subword from a hard register
1217 that is larger than word_mode. Presumably the check for
1218 HARD_REGNO_MODE_OK catches these most of these cases. */
1220 /* If OP is a hard register, but OP + I is not a hard register,
1221 then extracting a subword is impossible.
1223 For example, consider if OP is the last hard register and it is
1224 larger than word_mode. If we wanted word N (for N > 0) because a
1225 part of that hard register was known to contain a useful value,
1226 then OP + I would refer to a pseudo, not the hard register we
1228 if (REGNO (op
) < FIRST_PSEUDO_REGISTER
1229 && REGNO (op
) + i
>= FIRST_PSEUDO_REGISTER
)
1232 /* If the register is not valid for MODE, return 0. Note we
1233 have to check both OP and OP + I since they may refer to
1234 different parts of the register file.
1236 Consider if OP refers to the last 96bit FP register and we want
1237 subword 3 because that subword is known to contain a value we
1239 if (REGNO (op
) < FIRST_PSEUDO_REGISTER
1240 && (! HARD_REGNO_MODE_OK (REGNO (op
), word_mode
)
1241 || ! HARD_REGNO_MODE_OK (REGNO (op
) + i
, word_mode
)))
1243 else if (REGNO (op
) >= FIRST_PSEUDO_REGISTER
1244 || (REG_FUNCTION_VALUE_P (op
)
1245 && rtx_equal_function_value_matters
)
1246 /* We want to keep the stack, frame, and arg pointers
1248 || op
== frame_pointer_rtx
1249 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1250 || op
== arg_pointer_rtx
1252 || op
== stack_pointer_rtx
)
1253 return gen_rtx_SUBREG (word_mode
, op
, i
);
1255 return gen_rtx_REG (word_mode
, REGNO (op
) + i
);
1257 else if (GET_CODE (op
) == SUBREG
)
1258 return gen_rtx_SUBREG (word_mode
, SUBREG_REG (op
), i
+ SUBREG_WORD (op
));
1259 else if (GET_CODE (op
) == CONCAT
)
1261 int partwords
= GET_MODE_UNIT_SIZE (GET_MODE (op
)) / UNITS_PER_WORD
;
1263 return operand_subword (XEXP (op
, 0), i
, validate_address
, mode
);
1264 return operand_subword (XEXP (op
, 1), i
- partwords
,
1265 validate_address
, mode
);
1268 /* Form a new MEM at the requested address. */
1269 if (GET_CODE (op
) == MEM
)
1271 rtx addr
= plus_constant (XEXP (op
, 0), i
* UNITS_PER_WORD
);
1274 if (validate_address
)
1276 if (reload_completed
)
1278 if (! strict_memory_address_p (word_mode
, addr
))
1282 addr
= memory_address (word_mode
, addr
);
1285 new = gen_rtx_MEM (word_mode
, addr
);
1287 MEM_COPY_ATTRIBUTES (new, op
);
1288 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (op
);
1293 /* The only remaining cases are when OP is a constant. If the host and
1294 target floating formats are the same, handling two-word floating
1295 constants are easy. Note that REAL_VALUE_TO_TARGET_{SINGLE,DOUBLE}
1296 are defined as returning one or two 32 bit values, respectively,
1297 and not values of BITS_PER_WORD bits. */
1298 #ifdef REAL_ARITHMETIC
1299 /* The output is some bits, the width of the target machine's word.
1300 A wider-word host can surely hold them in a CONST_INT. A narrower-word
1302 if (HOST_BITS_PER_WIDE_INT
>= BITS_PER_WORD
1303 && GET_MODE_CLASS (mode
) == MODE_FLOAT
1304 && GET_MODE_BITSIZE (mode
) == 64
1305 && GET_CODE (op
) == CONST_DOUBLE
)
1310 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
1311 REAL_VALUE_TO_TARGET_DOUBLE (rv
, k
);
1313 /* We handle 32-bit and >= 64-bit words here. Note that the order in
1314 which the words are written depends on the word endianness.
1315 ??? This is a potential portability problem and should
1316 be fixed at some point.
1318 We must excercise caution with the sign bit. By definition there
1319 are 32 significant bits in K; there may be more in a HOST_WIDE_INT.
1320 Consider a host with a 32-bit long and a 64-bit HOST_WIDE_INT.
1321 So we explicitly mask and sign-extend as necessary. */
1322 if (BITS_PER_WORD
== 32)
1325 val
= ((val
& 0xffffffff) ^ 0x80000000) - 0x80000000;
1326 return GEN_INT (val
);
1328 #if HOST_BITS_PER_WIDE_INT >= 64
1329 else if (BITS_PER_WORD
>= 64 && i
== 0)
1331 val
= k
[! WORDS_BIG_ENDIAN
];
1332 val
= (((val
& 0xffffffff) ^ 0x80000000) - 0x80000000) << 32;
1333 val
|= (HOST_WIDE_INT
) k
[WORDS_BIG_ENDIAN
] & 0xffffffff;
1334 return GEN_INT (val
);
1337 else if (BITS_PER_WORD
== 16)
1340 if ((i
& 1) == !WORDS_BIG_ENDIAN
)
1343 return GEN_INT (val
);
1348 else if (HOST_BITS_PER_WIDE_INT
>= BITS_PER_WORD
1349 && GET_MODE_CLASS (mode
) == MODE_FLOAT
1350 && GET_MODE_BITSIZE (mode
) > 64
1351 && GET_CODE (op
) == CONST_DOUBLE
)
1356 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
1357 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, k
);
1359 if (BITS_PER_WORD
== 32)
1362 val
= ((val
& 0xffffffff) ^ 0x80000000) - 0x80000000;
1363 return GEN_INT (val
);
1368 #else /* no REAL_ARITHMETIC */
1369 if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
1370 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
1371 || flag_pretend_float
)
1372 && GET_MODE_CLASS (mode
) == MODE_FLOAT
1373 && GET_MODE_SIZE (mode
) == 2 * UNITS_PER_WORD
1374 && GET_CODE (op
) == CONST_DOUBLE
)
1376 /* The constant is stored in the host's word-ordering,
1377 but we want to access it in the target's word-ordering. Some
1378 compilers don't like a conditional inside macro args, so we have two
1379 copies of the return. */
1380 #ifdef HOST_WORDS_BIG_ENDIAN
1381 return GEN_INT (i
== WORDS_BIG_ENDIAN
1382 ? CONST_DOUBLE_HIGH (op
) : CONST_DOUBLE_LOW (op
));
1384 return GEN_INT (i
!= WORDS_BIG_ENDIAN
1385 ? CONST_DOUBLE_HIGH (op
) : CONST_DOUBLE_LOW (op
));
1388 #endif /* no REAL_ARITHMETIC */
1390 /* Single word float is a little harder, since single- and double-word
1391 values often do not have the same high-order bits. We have already
1392 verified that we want the only defined word of the single-word value. */
1393 #ifdef REAL_ARITHMETIC
1394 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
1395 && GET_MODE_BITSIZE (mode
) == 32
1396 && GET_CODE (op
) == CONST_DOUBLE
)
1401 REAL_VALUE_FROM_CONST_DOUBLE (rv
, op
);
1402 REAL_VALUE_TO_TARGET_SINGLE (rv
, l
);
1404 /* Sign extend from known 32-bit value to HOST_WIDE_INT. */
1406 val
= ((val
& 0xffffffff) ^ 0x80000000) - 0x80000000;
1408 if (BITS_PER_WORD
== 16)
1410 if ((i
& 1) == !WORDS_BIG_ENDIAN
)
1415 return GEN_INT (val
);
1418 if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
1419 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
1420 || flag_pretend_float
)
1421 && sizeof (float) * 8 == HOST_BITS_PER_WIDE_INT
1422 && GET_MODE_CLASS (mode
) == MODE_FLOAT
1423 && GET_MODE_SIZE (mode
) == UNITS_PER_WORD
1424 && GET_CODE (op
) == CONST_DOUBLE
)
1427 union {float f
; HOST_WIDE_INT i
; } u
;
1429 REAL_VALUE_FROM_CONST_DOUBLE (d
, op
);
1432 return GEN_INT (u
.i
);
1434 if (((HOST_FLOAT_FORMAT
== TARGET_FLOAT_FORMAT
1435 && HOST_BITS_PER_WIDE_INT
== BITS_PER_WORD
)
1436 || flag_pretend_float
)
1437 && sizeof (double) * 8 == HOST_BITS_PER_WIDE_INT
1438 && GET_MODE_CLASS (mode
) == MODE_FLOAT
1439 && GET_MODE_SIZE (mode
) == UNITS_PER_WORD
1440 && GET_CODE (op
) == CONST_DOUBLE
)
1443 union {double d
; HOST_WIDE_INT i
; } u
;
1445 REAL_VALUE_FROM_CONST_DOUBLE (d
, op
);
1448 return GEN_INT (u
.i
);
1450 #endif /* no REAL_ARITHMETIC */
1452 /* The only remaining cases that we can handle are integers.
1453 Convert to proper endianness now since these cases need it.
1454 At this point, i == 0 means the low-order word.
1456 We do not want to handle the case when BITS_PER_WORD <= HOST_BITS_PER_INT
1457 in general. However, if OP is (const_int 0), we can just return
1460 if (op
== const0_rtx
)
1463 if (GET_MODE_CLASS (mode
) != MODE_INT
1464 || (GET_CODE (op
) != CONST_INT
&& GET_CODE (op
) != CONST_DOUBLE
)
1465 || BITS_PER_WORD
> HOST_BITS_PER_WIDE_INT
)
1468 if (WORDS_BIG_ENDIAN
)
1469 i
= GET_MODE_SIZE (mode
) / UNITS_PER_WORD
- 1 - i
;
1471 /* Find out which word on the host machine this value is in and get
1472 it from the constant. */
1473 val
= (i
/ size_ratio
== 0
1474 ? (GET_CODE (op
) == CONST_INT
? INTVAL (op
) : CONST_DOUBLE_LOW (op
))
1475 : (GET_CODE (op
) == CONST_INT
1476 ? (INTVAL (op
) < 0 ? ~0 : 0) : CONST_DOUBLE_HIGH (op
)));
1478 /* Get the value we want into the low bits of val. */
1479 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
)
1480 val
= ((val
>> ((i
% size_ratio
) * BITS_PER_WORD
)));
1482 /* Clear the bits that don't belong in our mode, unless they and our sign
1483 bit are all one. So we get either a reasonable negative value or a
1484 reasonable unsigned value for this mode. */
1485 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
1486 && ((val
& ((HOST_WIDE_INT
) (-1) << (bits_per_word
- 1)))
1487 != ((HOST_WIDE_INT
) (-1) << (bits_per_word
- 1))))
1488 val
&= ((HOST_WIDE_INT
) 1 << bits_per_word
) - 1;
1490 /* If this would be an entire word for the target, but is not for
1491 the host, then sign-extend on the host so that the number will look
1492 the same way on the host that it would on the target.
1494 For example, when building a 64 bit alpha hosted 32 bit sparc
1495 targeted compiler, then we want the 32 bit unsigned value -1 to be
1496 represented as a 64 bit value -1, and not as 0x00000000ffffffff.
1497 The later confuses the sparc backend. */
1499 if (BITS_PER_WORD
< HOST_BITS_PER_WIDE_INT
1500 && (val
& ((HOST_WIDE_INT
) 1 << (bits_per_word
- 1))))
1501 val
|= ((HOST_WIDE_INT
) (-1) << bits_per_word
);
1503 return GEN_INT (val
);
1506 /* Similar to `operand_subword', but never return 0. If we can't extract
1507 the required subword, put OP into a register and try again. If that fails,
1508 abort. We always validate the address in this case. It is not valid
1509 to call this function after reload; it is mostly meant for RTL
1512 MODE is the mode of OP, in case it is CONST_INT. */
1515 operand_subword_force (op
, i
, mode
)
1518 enum machine_mode mode
;
1520 rtx result
= operand_subword (op
, i
, 1, mode
);
1525 if (mode
!= BLKmode
&& mode
!= VOIDmode
)
1527 /* If this is a register which can not be accessed by words, copy it
1528 to a pseudo register. */
1529 if (GET_CODE (op
) == REG
)
1530 op
= copy_to_reg (op
);
1532 op
= force_reg (mode
, op
);
1535 result
= operand_subword (op
, i
, 1, mode
);
1542 /* Given a compare instruction, swap the operands.
1543 A test instruction is changed into a compare of 0 against the operand. */
1546 reverse_comparison (insn
)
1549 rtx body
= PATTERN (insn
);
1552 if (GET_CODE (body
) == SET
)
1553 comp
= SET_SRC (body
);
1555 comp
= SET_SRC (XVECEXP (body
, 0, 0));
1557 if (GET_CODE (comp
) == COMPARE
)
1559 rtx op0
= XEXP (comp
, 0);
1560 rtx op1
= XEXP (comp
, 1);
1561 XEXP (comp
, 0) = op1
;
1562 XEXP (comp
, 1) = op0
;
1566 rtx
new = gen_rtx_COMPARE (VOIDmode
, CONST0_RTX (GET_MODE (comp
)), comp
);
1567 if (GET_CODE (body
) == SET
)
1568 SET_SRC (body
) = new;
1570 SET_SRC (XVECEXP (body
, 0, 0)) = new;
1574 /* Return a memory reference like MEMREF, but with its mode changed
1575 to MODE and its address changed to ADDR.
1576 (VOIDmode means don't change the mode.
1577 NULL for ADDR means don't change the address.) */
1580 change_address (memref
, mode
, addr
)
1582 enum machine_mode mode
;
1587 if (GET_CODE (memref
) != MEM
)
1589 if (mode
== VOIDmode
)
1590 mode
= GET_MODE (memref
);
1592 addr
= XEXP (memref
, 0);
1594 /* If reload is in progress or has completed, ADDR must be valid.
1595 Otherwise, we can call memory_address to make it valid. */
1596 if (reload_completed
|| reload_in_progress
)
1598 if (! memory_address_p (mode
, addr
))
1602 addr
= memory_address (mode
, addr
);
1604 if (rtx_equal_p (addr
, XEXP (memref
, 0)) && mode
== GET_MODE (memref
))
1607 new = gen_rtx_MEM (mode
, addr
);
1608 RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (memref
);
1609 MEM_COPY_ATTRIBUTES (new, memref
);
1613 /* Return a newly created CODE_LABEL rtx with a unique label number. */
1620 label
= gen_rtx_CODE_LABEL (VOIDmode
, 0, NULL_RTX
,
1621 NULL_RTX
, label_num
++, NULL_PTR
);
1623 LABEL_NUSES (label
) = 0;
1627 /* For procedure integration. */
1629 /* Return a newly created INLINE_HEADER rtx. Should allocate this
1630 from a permanent obstack when the opportunity arises. */
1633 gen_inline_header_rtx (first_insn
, first_parm_insn
, first_labelno
,
1634 last_labelno
, max_parm_regnum
, max_regnum
, args_size
,
1635 pops_args
, stack_slots
, forced_labels
, function_flags
,
1636 outgoing_args_size
, original_arg_vector
,
1637 original_decl_initial
, regno_rtx
, regno_flag
,
1638 regno_align
, parm_reg_stack_loc
)
1639 rtx first_insn
, first_parm_insn
;
1640 int first_labelno
, last_labelno
, max_parm_regnum
, max_regnum
, args_size
;
1645 int outgoing_args_size
;
1646 rtvec original_arg_vector
;
1647 rtx original_decl_initial
;
1651 rtvec parm_reg_stack_loc
;
1653 rtx header
= gen_rtx_INLINE_HEADER (VOIDmode
,
1654 cur_insn_uid
++, NULL_RTX
,
1655 first_insn
, first_parm_insn
,
1656 first_labelno
, last_labelno
,
1657 max_parm_regnum
, max_regnum
, args_size
,
1658 pops_args
, stack_slots
, forced_labels
,
1659 function_flags
, outgoing_args_size
,
1660 original_arg_vector
,
1661 original_decl_initial
,
1662 regno_rtx
, regno_flag
, regno_align
,
1663 parm_reg_stack_loc
);
1667 /* Install new pointers to the first and last insns in the chain.
1668 Also, set cur_insn_uid to one higher than the last in use.
1669 Used for an inline-procedure after copying the insn chain. */
1672 set_new_first_and_last_insn (first
, last
)
1681 for (insn
= first
; insn
; insn
= NEXT_INSN (insn
))
1682 cur_insn_uid
= MAX (cur_insn_uid
, INSN_UID (insn
));
1687 /* Set the range of label numbers found in the current function.
1688 This is used when belatedly compiling an inline function. */
1691 set_new_first_and_last_label_num (first
, last
)
1694 base_label_num
= label_num
;
1695 first_label_num
= first
;
1696 last_label_num
= last
;
1699 /* Save all variables describing the current status into the structure *P.
1700 This is used before starting a nested function. */
1703 save_emit_status (p
)
1706 p
->reg_rtx_no
= reg_rtx_no
;
1707 p
->first_label_num
= first_label_num
;
1708 p
->first_insn
= first_insn
;
1709 p
->last_insn
= last_insn
;
1710 p
->sequence_rtl_expr
= sequence_rtl_expr
;
1711 p
->sequence_stack
= sequence_stack
;
1712 p
->cur_insn_uid
= cur_insn_uid
;
1713 p
->last_linenum
= last_linenum
;
1714 p
->last_filename
= last_filename
;
1715 p
->regno_pointer_flag
= regno_pointer_flag
;
1716 p
->regno_pointer_align
= regno_pointer_align
;
1717 p
->regno_pointer_flag_length
= regno_pointer_flag_length
;
1718 p
->regno_reg_rtx
= regno_reg_rtx
;
1721 /* Restore all variables describing the current status from the structure *P.
1722 This is used after a nested function. */
1725 restore_emit_status (p
)
1730 reg_rtx_no
= p
->reg_rtx_no
;
1731 first_label_num
= p
->first_label_num
;
1733 first_insn
= p
->first_insn
;
1734 last_insn
= p
->last_insn
;
1735 sequence_rtl_expr
= p
->sequence_rtl_expr
;
1736 sequence_stack
= p
->sequence_stack
;
1737 cur_insn_uid
= p
->cur_insn_uid
;
1738 last_linenum
= p
->last_linenum
;
1739 last_filename
= p
->last_filename
;
1740 regno_pointer_flag
= p
->regno_pointer_flag
;
1741 regno_pointer_align
= p
->regno_pointer_align
;
1742 regno_pointer_flag_length
= p
->regno_pointer_flag_length
;
1743 regno_reg_rtx
= p
->regno_reg_rtx
;
1745 /* Clear our cache of rtx expressions for start_sequence and
1747 sequence_element_free_list
= 0;
1748 for (i
= 0; i
< SEQUENCE_RESULT_SIZE
; i
++)
1749 sequence_result
[i
] = 0;
1754 /* Go through all the RTL insn bodies and copy any invalid shared structure.
1755 It does not work to do this twice, because the mark bits set here
1756 are not cleared afterwards. */
1759 unshare_all_rtl (insn
)
1762 for (; insn
; insn
= NEXT_INSN (insn
))
1763 if (GET_CODE (insn
) == INSN
|| GET_CODE (insn
) == JUMP_INSN
1764 || GET_CODE (insn
) == CALL_INSN
)
1766 PATTERN (insn
) = copy_rtx_if_shared (PATTERN (insn
));
1767 REG_NOTES (insn
) = copy_rtx_if_shared (REG_NOTES (insn
));
1768 LOG_LINKS (insn
) = copy_rtx_if_shared (LOG_LINKS (insn
));
1771 /* Make sure the addresses of stack slots found outside the insn chain
1772 (such as, in DECL_RTL of a variable) are not shared
1773 with the insn chain.
1775 This special care is necessary when the stack slot MEM does not
1776 actually appear in the insn chain. If it does appear, its address
1777 is unshared from all else at that point. */
1779 copy_rtx_if_shared (stack_slot_list
);
1782 /* Mark ORIG as in use, and return a copy of it if it was already in use.
1783 Recursively does the same for subexpressions. */
1786 copy_rtx_if_shared (orig
)
1789 register rtx x
= orig
;
1791 register enum rtx_code code
;
1792 register char *format_ptr
;
1798 code
= GET_CODE (x
);
1800 /* These types may be freely shared. */
1813 /* SCRATCH must be shared because they represent distinct values. */
1817 /* CONST can be shared if it contains a SYMBOL_REF. If it contains
1818 a LABEL_REF, it isn't sharable. */
1819 if (GET_CODE (XEXP (x
, 0)) == PLUS
1820 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == SYMBOL_REF
1821 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
)
1830 /* The chain of insns is not being copied. */
1834 /* A MEM is allowed to be shared if its address is constant
1835 or is a constant plus one of the special registers. */
1836 if (CONSTANT_ADDRESS_P (XEXP (x
, 0))
1837 || XEXP (x
, 0) == virtual_stack_vars_rtx
1838 || XEXP (x
, 0) == virtual_incoming_args_rtx
)
1841 if (GET_CODE (XEXP (x
, 0)) == PLUS
1842 && (XEXP (XEXP (x
, 0), 0) == virtual_stack_vars_rtx
1843 || XEXP (XEXP (x
, 0), 0) == virtual_incoming_args_rtx
)
1844 && CONSTANT_ADDRESS_P (XEXP (XEXP (x
, 0), 1)))
1846 /* This MEM can appear in more than one place,
1847 but its address better not be shared with anything else. */
1849 XEXP (x
, 0) = copy_rtx_if_shared (XEXP (x
, 0));
1859 /* This rtx may not be shared. If it has already been seen,
1860 replace it with a copy of itself. */
1866 copy
= rtx_alloc (code
);
1867 bcopy ((char *) x
, (char *) copy
,
1868 (sizeof (*copy
) - sizeof (copy
->fld
)
1869 + sizeof (copy
->fld
[0]) * GET_RTX_LENGTH (code
)));
1875 /* Now scan the subexpressions recursively.
1876 We can store any replaced subexpressions directly into X
1877 since we know X is not shared! Any vectors in X
1878 must be copied if X was copied. */
1880 format_ptr
= GET_RTX_FORMAT (code
);
1882 for (i
= 0; i
< GET_RTX_LENGTH (code
); i
++)
1884 switch (*format_ptr
++)
1887 XEXP (x
, i
) = copy_rtx_if_shared (XEXP (x
, i
));
1891 if (XVEC (x
, i
) != NULL
)
1894 int len
= XVECLEN (x
, i
);
1896 if (copied
&& len
> 0)
1897 XVEC (x
, i
) = gen_rtvec_vv (len
, XVEC (x
, i
)->elem
);
1898 for (j
= 0; j
< len
; j
++)
1899 XVECEXP (x
, i
, j
) = copy_rtx_if_shared (XVECEXP (x
, i
, j
));
1907 /* Clear all the USED bits in X to allow copy_rtx_if_shared to be used
1908 to look for shared sub-parts. */
1911 reset_used_flags (x
)
1915 register enum rtx_code code
;
1916 register char *format_ptr
;
1921 code
= GET_CODE (x
);
1923 /* These types may be freely shared so we needn't do any resetting
1944 /* The chain of insns is not being copied. */
1953 format_ptr
= GET_RTX_FORMAT (code
);
1954 for (i
= 0; i
< GET_RTX_LENGTH (code
); i
++)
1956 switch (*format_ptr
++)
1959 reset_used_flags (XEXP (x
, i
));
1963 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
1964 reset_used_flags (XVECEXP (x
, i
, j
));
1970 /* Copy X if necessary so that it won't be altered by changes in OTHER.
1971 Return X or the rtx for the pseudo reg the value of X was copied into.
1972 OTHER must be valid as a SET_DEST. */
1975 make_safe_from (x
, other
)
1979 switch (GET_CODE (other
))
1982 other
= SUBREG_REG (other
);
1984 case STRICT_LOW_PART
:
1987 other
= XEXP (other
, 0);
1993 if ((GET_CODE (other
) == MEM
1995 && GET_CODE (x
) != REG
1996 && GET_CODE (x
) != SUBREG
)
1997 || (GET_CODE (other
) == REG
1998 && (REGNO (other
) < FIRST_PSEUDO_REGISTER
1999 || reg_mentioned_p (other
, x
))))
2001 rtx temp
= gen_reg_rtx (GET_MODE (x
));
2002 emit_move_insn (temp
, x
);
2008 /* Emission of insns (adding them to the doubly-linked list). */
2010 /* Return the first insn of the current sequence or current function. */
2018 /* Return the last insn emitted in current sequence or current function. */
2026 /* Specify a new insn as the last in the chain. */
2029 set_last_insn (insn
)
2032 if (NEXT_INSN (insn
) != 0)
2037 /* Return the last insn emitted, even if it is in a sequence now pushed. */
2040 get_last_insn_anywhere ()
2042 struct sequence_stack
*stack
;
2045 for (stack
= sequence_stack
; stack
; stack
= stack
->next
)
2046 if (stack
->last
!= 0)
2051 /* Return a number larger than any instruction's uid in this function. */
2056 return cur_insn_uid
;
2059 /* Return the next insn. If it is a SEQUENCE, return the first insn
2068 insn
= NEXT_INSN (insn
);
2069 if (insn
&& GET_CODE (insn
) == INSN
2070 && GET_CODE (PATTERN (insn
)) == SEQUENCE
)
2071 insn
= XVECEXP (PATTERN (insn
), 0, 0);
2077 /* Return the previous insn. If it is a SEQUENCE, return the last insn
2081 previous_insn (insn
)
2086 insn
= PREV_INSN (insn
);
2087 if (insn
&& GET_CODE (insn
) == INSN
2088 && GET_CODE (PATTERN (insn
)) == SEQUENCE
)
2089 insn
= XVECEXP (PATTERN (insn
), 0, XVECLEN (PATTERN (insn
), 0) - 1);
2095 /* Return the next insn after INSN that is not a NOTE. This routine does not
2096 look inside SEQUENCEs. */
2099 next_nonnote_insn (insn
)
2104 insn
= NEXT_INSN (insn
);
2105 if (insn
== 0 || GET_CODE (insn
) != NOTE
)
2112 /* Return the previous insn before INSN that is not a NOTE. This routine does
2113 not look inside SEQUENCEs. */
2116 prev_nonnote_insn (insn
)
2121 insn
= PREV_INSN (insn
);
2122 if (insn
== 0 || GET_CODE (insn
) != NOTE
)
2129 /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
2130 or 0, if there is none. This routine does not look inside
2134 next_real_insn (insn
)
2139 insn
= NEXT_INSN (insn
);
2140 if (insn
== 0 || GET_CODE (insn
) == INSN
2141 || GET_CODE (insn
) == CALL_INSN
|| GET_CODE (insn
) == JUMP_INSN
)
2148 /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
2149 or 0, if there is none. This routine does not look inside
2153 prev_real_insn (insn
)
2158 insn
= PREV_INSN (insn
);
2159 if (insn
== 0 || GET_CODE (insn
) == INSN
|| GET_CODE (insn
) == CALL_INSN
2160 || GET_CODE (insn
) == JUMP_INSN
)
2167 /* Find the next insn after INSN that really does something. This routine
2168 does not look inside SEQUENCEs. Until reload has completed, this is the
2169 same as next_real_insn. */
2172 next_active_insn (insn
)
2177 insn
= NEXT_INSN (insn
);
2179 || GET_CODE (insn
) == CALL_INSN
|| GET_CODE (insn
) == JUMP_INSN
2180 || (GET_CODE (insn
) == INSN
2181 && (! reload_completed
2182 || (GET_CODE (PATTERN (insn
)) != USE
2183 && GET_CODE (PATTERN (insn
)) != CLOBBER
))))
2190 /* Find the last insn before INSN that really does something. This routine
2191 does not look inside SEQUENCEs. Until reload has completed, this is the
2192 same as prev_real_insn. */
2195 prev_active_insn (insn
)
2200 insn
= PREV_INSN (insn
);
2202 || GET_CODE (insn
) == CALL_INSN
|| GET_CODE (insn
) == JUMP_INSN
2203 || (GET_CODE (insn
) == INSN
2204 && (! reload_completed
2205 || (GET_CODE (PATTERN (insn
)) != USE
2206 && GET_CODE (PATTERN (insn
)) != CLOBBER
))))
2213 /* Return the next CODE_LABEL after the insn INSN, or 0 if there is none. */
2221 insn
= NEXT_INSN (insn
);
2222 if (insn
== 0 || GET_CODE (insn
) == CODE_LABEL
)
2229 /* Return the last CODE_LABEL before the insn INSN, or 0 if there is none. */
2237 insn
= PREV_INSN (insn
);
2238 if (insn
== 0 || GET_CODE (insn
) == CODE_LABEL
)
2246 /* INSN uses CC0 and is being moved into a delay slot. Set up REG_CC_SETTER
2247 and REG_CC_USER notes so we can find it. */
2250 link_cc0_insns (insn
)
2253 rtx user
= next_nonnote_insn (insn
);
2255 if (GET_CODE (user
) == INSN
&& GET_CODE (PATTERN (user
)) == SEQUENCE
)
2256 user
= XVECEXP (PATTERN (user
), 0, 0);
2258 REG_NOTES (user
) = gen_rtx_INSN_LIST (REG_CC_SETTER
, insn
, REG_NOTES (user
));
2259 REG_NOTES (insn
) = gen_rtx_INSN_LIST (REG_CC_USER
, user
, REG_NOTES (insn
));
2262 /* Return the next insn that uses CC0 after INSN, which is assumed to
2263 set it. This is the inverse of prev_cc0_setter (i.e., prev_cc0_setter
2264 applied to the result of this function should yield INSN).
2266 Normally, this is simply the next insn. However, if a REG_CC_USER note
2267 is present, it contains the insn that uses CC0.
2269 Return 0 if we can't find the insn. */
2272 next_cc0_user (insn
)
2275 rtx note
= find_reg_note (insn
, REG_CC_USER
, NULL_RTX
);
2278 return XEXP (note
, 0);
2280 insn
= next_nonnote_insn (insn
);
2281 if (insn
&& GET_CODE (insn
) == INSN
&& GET_CODE (PATTERN (insn
)) == SEQUENCE
)
2282 insn
= XVECEXP (PATTERN (insn
), 0, 0);
2284 if (insn
&& GET_RTX_CLASS (GET_CODE (insn
)) == 'i'
2285 && reg_mentioned_p (cc0_rtx
, PATTERN (insn
)))
2291 /* Find the insn that set CC0 for INSN. Unless INSN has a REG_CC_SETTER
2292 note, it is the previous insn. */
2295 prev_cc0_setter (insn
)
2298 rtx note
= find_reg_note (insn
, REG_CC_SETTER
, NULL_RTX
);
2301 return XEXP (note
, 0);
2303 insn
= prev_nonnote_insn (insn
);
2304 if (! sets_cc0_p (PATTERN (insn
)))
2311 /* Try splitting insns that can be split for better scheduling.
2312 PAT is the pattern which might split.
2313 TRIAL is the insn providing PAT.
2314 LAST is non-zero if we should return the last insn of the sequence produced.
2316 If this routine succeeds in splitting, it returns the first or last
2317 replacement insn depending on the value of LAST. Otherwise, it
2318 returns TRIAL. If the insn to be returned can be split, it will be. */
2321 try_split (pat
, trial
, last
)
2325 rtx before
= PREV_INSN (trial
);
2326 rtx after
= NEXT_INSN (trial
);
2327 rtx seq
= split_insns (pat
, trial
);
2328 int has_barrier
= 0;
2331 /* If we are splitting a JUMP_INSN, it might be followed by a BARRIER.
2332 We may need to handle this specially. */
2333 if (after
&& GET_CODE (after
) == BARRIER
)
2336 after
= NEXT_INSN (after
);
2341 /* SEQ can either be a SEQUENCE or the pattern of a single insn.
2342 The latter case will normally arise only when being done so that
2343 it, in turn, will be split (SFmode on the 29k is an example). */
2344 if (GET_CODE (seq
) == SEQUENCE
)
2346 /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in
2347 SEQ and copy our JUMP_LABEL to it. If JUMP_LABEL is non-zero,
2348 increment the usage count so we don't delete the label. */
2351 if (GET_CODE (trial
) == JUMP_INSN
)
2352 for (i
= XVECLEN (seq
, 0) - 1; i
>= 0; i
--)
2353 if (GET_CODE (XVECEXP (seq
, 0, i
)) == JUMP_INSN
)
2355 JUMP_LABEL (XVECEXP (seq
, 0, i
)) = JUMP_LABEL (trial
);
2357 if (JUMP_LABEL (trial
))
2358 LABEL_NUSES (JUMP_LABEL (trial
))++;
2361 tem
= emit_insn_after (seq
, before
);
2363 delete_insn (trial
);
2365 emit_barrier_after (tem
);
2367 /* Recursively call try_split for each new insn created; by the
2368 time control returns here that insn will be fully split, so
2369 set LAST and continue from the insn after the one returned.
2370 We can't use next_active_insn here since AFTER may be a note.
2371 Ignore deleted insns, which can be occur if not optimizing. */
2372 for (tem
= NEXT_INSN (before
); tem
!= after
;
2373 tem
= NEXT_INSN (tem
))
2374 if (! INSN_DELETED_P (tem
)
2375 && GET_RTX_CLASS (GET_CODE (tem
)) == 'i')
2376 tem
= try_split (PATTERN (tem
), tem
, 1);
2378 /* Avoid infinite loop if the result matches the original pattern. */
2379 else if (rtx_equal_p (seq
, pat
))
2383 PATTERN (trial
) = seq
;
2384 INSN_CODE (trial
) = -1;
2385 try_split (seq
, trial
, last
);
2388 /* Return either the first or the last insn, depending on which was
2390 return last
? prev_active_insn (after
) : next_active_insn (before
);
2396 /* Make and return an INSN rtx, initializing all its slots.
2397 Store PATTERN in the pattern slots. */
2400 make_insn_raw (pattern
)
2405 /* If in RTL generation phase, see if FREE_INSN can be used. */
2406 if (free_insn
!= 0 && rtx_equal_function_value_matters
)
2409 free_insn
= NEXT_INSN (free_insn
);
2410 PUT_CODE (insn
, INSN
);
2413 insn
= rtx_alloc (INSN
);
2415 INSN_UID (insn
) = cur_insn_uid
++;
2416 PATTERN (insn
) = pattern
;
2417 INSN_CODE (insn
) = -1;
2418 LOG_LINKS (insn
) = NULL
;
2419 REG_NOTES (insn
) = NULL
;
2424 /* Like `make_insn' but make a JUMP_INSN instead of an insn. */
2427 make_jump_insn_raw (pattern
)
2432 insn
= rtx_alloc (JUMP_INSN
);
2433 INSN_UID (insn
) = cur_insn_uid
++;
2435 PATTERN (insn
) = pattern
;
2436 INSN_CODE (insn
) = -1;
2437 LOG_LINKS (insn
) = NULL
;
2438 REG_NOTES (insn
) = NULL
;
2439 JUMP_LABEL (insn
) = NULL
;
2444 /* Like `make_insn' but make a CALL_INSN instead of an insn. */
2447 make_call_insn_raw (pattern
)
2452 insn
= rtx_alloc (CALL_INSN
);
2453 INSN_UID (insn
) = cur_insn_uid
++;
2455 PATTERN (insn
) = pattern
;
2456 INSN_CODE (insn
) = -1;
2457 LOG_LINKS (insn
) = NULL
;
2458 REG_NOTES (insn
) = NULL
;
2459 CALL_INSN_FUNCTION_USAGE (insn
) = NULL
;
2464 /* Add INSN to the end of the doubly-linked list.
2465 INSN may be an INSN, JUMP_INSN, CALL_INSN, CODE_LABEL, BARRIER or NOTE. */
2471 PREV_INSN (insn
) = last_insn
;
2472 NEXT_INSN (insn
) = 0;
2474 if (NULL
!= last_insn
)
2475 NEXT_INSN (last_insn
) = insn
;
2477 if (NULL
== first_insn
)
2483 /* Add INSN into the doubly-linked list after insn AFTER. This and
2484 the next should be the only functions called to insert an insn once
2485 delay slots have been filled since only they know how to update a
2489 add_insn_after (insn
, after
)
2492 rtx next
= NEXT_INSN (after
);
2494 if (optimize
&& INSN_DELETED_P (after
))
2497 NEXT_INSN (insn
) = next
;
2498 PREV_INSN (insn
) = after
;
2502 PREV_INSN (next
) = insn
;
2503 if (GET_CODE (next
) == INSN
&& GET_CODE (PATTERN (next
)) == SEQUENCE
)
2504 PREV_INSN (XVECEXP (PATTERN (next
), 0, 0)) = insn
;
2506 else if (last_insn
== after
)
2510 struct sequence_stack
*stack
= sequence_stack
;
2511 /* Scan all pending sequences too. */
2512 for (; stack
; stack
= stack
->next
)
2513 if (after
== stack
->last
)
2523 NEXT_INSN (after
) = insn
;
2524 if (GET_CODE (after
) == INSN
&& GET_CODE (PATTERN (after
)) == SEQUENCE
)
2526 rtx sequence
= PATTERN (after
);
2527 NEXT_INSN (XVECEXP (sequence
, 0, XVECLEN (sequence
, 0) - 1)) = insn
;
2531 /* Add INSN into the doubly-linked list before insn BEFORE. This and
2532 the previous should be the only functions called to insert an insn once
2533 delay slots have been filled since only they know how to update a
2537 add_insn_before (insn
, before
)
2540 rtx prev
= PREV_INSN (before
);
2542 if (optimize
&& INSN_DELETED_P (before
))
2545 PREV_INSN (insn
) = prev
;
2546 NEXT_INSN (insn
) = before
;
2550 NEXT_INSN (prev
) = insn
;
2551 if (GET_CODE (prev
) == INSN
&& GET_CODE (PATTERN (prev
)) == SEQUENCE
)
2553 rtx sequence
= PATTERN (prev
);
2554 NEXT_INSN (XVECEXP (sequence
, 0, XVECLEN (sequence
, 0) - 1)) = insn
;
2557 else if (first_insn
== before
)
2561 struct sequence_stack
*stack
= sequence_stack
;
2562 /* Scan all pending sequences too. */
2563 for (; stack
; stack
= stack
->next
)
2564 if (before
== stack
->first
)
2566 stack
->first
= insn
;
2574 PREV_INSN (before
) = insn
;
2575 if (GET_CODE (before
) == INSN
&& GET_CODE (PATTERN (before
)) == SEQUENCE
)
2576 PREV_INSN (XVECEXP (PATTERN (before
), 0, 0)) = insn
;
2579 /* Remove an insn from its doubly-linked list. This function knows how
2580 to handle sequences. */
2585 rtx next
= NEXT_INSN (insn
);
2586 rtx prev
= PREV_INSN (insn
);
2589 NEXT_INSN (prev
) = next
;
2590 if (GET_CODE (prev
) == INSN
&& GET_CODE (PATTERN (prev
)) == SEQUENCE
)
2592 rtx sequence
= PATTERN (prev
);
2593 NEXT_INSN (XVECEXP (sequence
, 0, XVECLEN (sequence
, 0) - 1)) = next
;
2596 else if (first_insn
== insn
)
2600 struct sequence_stack
*stack
= sequence_stack
;
2601 /* Scan all pending sequences too. */
2602 for (; stack
; stack
= stack
->next
)
2603 if (insn
== stack
->first
)
2605 stack
->first
= next
;
2615 PREV_INSN (next
) = prev
;
2616 if (GET_CODE (next
) == INSN
&& GET_CODE (PATTERN (next
)) == SEQUENCE
)
2617 PREV_INSN (XVECEXP (PATTERN (next
), 0, 0)) = prev
;
2619 else if (last_insn
== insn
)
2623 struct sequence_stack
*stack
= sequence_stack
;
2624 /* Scan all pending sequences too. */
2625 for (; stack
; stack
= stack
->next
)
2626 if (insn
== stack
->last
)
2637 /* Delete all insns made since FROM.
2638 FROM becomes the new last instruction. */
2641 delete_insns_since (from
)
2647 NEXT_INSN (from
) = 0;
2651 /* This function is deprecated, please use sequences instead.
2653 Move a consecutive bunch of insns to a different place in the chain.
2654 The insns to be moved are those between FROM and TO.
2655 They are moved to a new position after the insn AFTER.
2656 AFTER must not be FROM or TO or any insn in between.
2658 This function does not know about SEQUENCEs and hence should not be
2659 called after delay-slot filling has been done. */
2662 reorder_insns (from
, to
, after
)
2663 rtx from
, to
, after
;
2665 /* Splice this bunch out of where it is now. */
2666 if (PREV_INSN (from
))
2667 NEXT_INSN (PREV_INSN (from
)) = NEXT_INSN (to
);
2669 PREV_INSN (NEXT_INSN (to
)) = PREV_INSN (from
);
2670 if (last_insn
== to
)
2671 last_insn
= PREV_INSN (from
);
2672 if (first_insn
== from
)
2673 first_insn
= NEXT_INSN (to
);
2675 /* Make the new neighbors point to it and it to them. */
2676 if (NEXT_INSN (after
))
2677 PREV_INSN (NEXT_INSN (after
)) = to
;
2679 NEXT_INSN (to
) = NEXT_INSN (after
);
2680 PREV_INSN (from
) = after
;
2681 NEXT_INSN (after
) = from
;
2682 if (after
== last_insn
)
2686 /* Return the line note insn preceding INSN. */
2689 find_line_note (insn
)
2692 if (no_line_numbers
)
2695 for (; insn
; insn
= PREV_INSN (insn
))
2696 if (GET_CODE (insn
) == NOTE
2697 && NOTE_LINE_NUMBER (insn
) >= 0)
2703 /* Like reorder_insns, but inserts line notes to preserve the line numbers
2704 of the moved insns when debugging. This may insert a note between AFTER
2705 and FROM, and another one after TO. */
2708 reorder_insns_with_line_notes (from
, to
, after
)
2709 rtx from
, to
, after
;
2711 rtx from_line
= find_line_note (from
);
2712 rtx after_line
= find_line_note (after
);
2714 reorder_insns (from
, to
, after
);
2716 if (from_line
== after_line
)
2720 emit_line_note_after (NOTE_SOURCE_FILE (from_line
),
2721 NOTE_LINE_NUMBER (from_line
),
2724 emit_line_note_after (NOTE_SOURCE_FILE (after_line
),
2725 NOTE_LINE_NUMBER (after_line
),
2729 /* Emit an insn of given code and pattern
2730 at a specified place within the doubly-linked list. */
2732 /* Make an instruction with body PATTERN
2733 and output it before the instruction BEFORE. */
2736 emit_insn_before (pattern
, before
)
2737 register rtx pattern
, before
;
2739 register rtx insn
= before
;
2741 if (GET_CODE (pattern
) == SEQUENCE
)
2745 for (i
= 0; i
< XVECLEN (pattern
, 0); i
++)
2747 insn
= XVECEXP (pattern
, 0, i
);
2748 add_insn_before (insn
, before
);
2750 if (XVECLEN (pattern
, 0) < SEQUENCE_RESULT_SIZE
)
2751 sequence_result
[XVECLEN (pattern
, 0)] = pattern
;
2755 insn
= make_insn_raw (pattern
);
2756 add_insn_before (insn
, before
);
2762 /* Make an instruction with body PATTERN and code JUMP_INSN
2763 and output it before the instruction BEFORE. */
2766 emit_jump_insn_before (pattern
, before
)
2767 register rtx pattern
, before
;
2771 if (GET_CODE (pattern
) == SEQUENCE
)
2772 insn
= emit_insn_before (pattern
, before
);
2775 insn
= make_jump_insn_raw (pattern
);
2776 add_insn_before (insn
, before
);
2782 /* Make an instruction with body PATTERN and code CALL_INSN
2783 and output it before the instruction BEFORE. */
2786 emit_call_insn_before (pattern
, before
)
2787 register rtx pattern
, before
;
2791 if (GET_CODE (pattern
) == SEQUENCE
)
2792 insn
= emit_insn_before (pattern
, before
);
2795 insn
= make_call_insn_raw (pattern
);
2796 add_insn_before (insn
, before
);
2797 PUT_CODE (insn
, CALL_INSN
);
2803 /* Make an insn of code BARRIER
2804 and output it before the insn BEFORE. */
2807 emit_barrier_before (before
)
2808 register rtx before
;
2810 register rtx insn
= rtx_alloc (BARRIER
);
2812 INSN_UID (insn
) = cur_insn_uid
++;
2814 add_insn_before (insn
, before
);
2818 /* Emit the label LABEL before the insn BEFORE. */
2821 emit_label_before (label
, before
)
2824 /* This can be called twice for the same label as a result of the
2825 confusion that follows a syntax error! So make it harmless. */
2826 if (INSN_UID (label
) == 0)
2828 INSN_UID (label
) = cur_insn_uid
++;
2829 add_insn_before (label
, before
);
2835 /* Emit a note of subtype SUBTYPE before the insn BEFORE. */
2838 emit_note_before (subtype
, before
)
2842 register rtx note
= rtx_alloc (NOTE
);
2843 INSN_UID (note
) = cur_insn_uid
++;
2844 NOTE_SOURCE_FILE (note
) = 0;
2845 NOTE_LINE_NUMBER (note
) = subtype
;
2847 add_insn_before (note
, before
);
2851 /* Make an insn of code INSN with body PATTERN
2852 and output it after the insn AFTER. */
2855 emit_insn_after (pattern
, after
)
2856 register rtx pattern
, after
;
2858 register rtx insn
= after
;
2860 if (GET_CODE (pattern
) == SEQUENCE
)
2864 for (i
= 0; i
< XVECLEN (pattern
, 0); i
++)
2866 insn
= XVECEXP (pattern
, 0, i
);
2867 add_insn_after (insn
, after
);
2870 if (XVECLEN (pattern
, 0) < SEQUENCE_RESULT_SIZE
)
2871 sequence_result
[XVECLEN (pattern
, 0)] = pattern
;
2875 insn
= make_insn_raw (pattern
);
2876 add_insn_after (insn
, after
);
2882 /* Similar to emit_insn_after, except that line notes are to be inserted so
2883 as to act as if this insn were at FROM. */
2886 emit_insn_after_with_line_notes (pattern
, after
, from
)
2887 rtx pattern
, after
, from
;
2889 rtx from_line
= find_line_note (from
);
2890 rtx after_line
= find_line_note (after
);
2891 rtx insn
= emit_insn_after (pattern
, after
);
2894 emit_line_note_after (NOTE_SOURCE_FILE (from_line
),
2895 NOTE_LINE_NUMBER (from_line
),
2899 emit_line_note_after (NOTE_SOURCE_FILE (after_line
),
2900 NOTE_LINE_NUMBER (after_line
),
2904 /* Make an insn of code JUMP_INSN with body PATTERN
2905 and output it after the insn AFTER. */
2908 emit_jump_insn_after (pattern
, after
)
2909 register rtx pattern
, after
;
2913 if (GET_CODE (pattern
) == SEQUENCE
)
2914 insn
= emit_insn_after (pattern
, after
);
2917 insn
= make_jump_insn_raw (pattern
);
2918 add_insn_after (insn
, after
);
2924 /* Make an insn of code BARRIER
2925 and output it after the insn AFTER. */
2928 emit_barrier_after (after
)
2931 register rtx insn
= rtx_alloc (BARRIER
);
2933 INSN_UID (insn
) = cur_insn_uid
++;
2935 add_insn_after (insn
, after
);
2939 /* Emit the label LABEL after the insn AFTER. */
2942 emit_label_after (label
, after
)
2945 /* This can be called twice for the same label
2946 as a result of the confusion that follows a syntax error!
2947 So make it harmless. */
2948 if (INSN_UID (label
) == 0)
2950 INSN_UID (label
) = cur_insn_uid
++;
2951 add_insn_after (label
, after
);
2957 /* Emit a note of subtype SUBTYPE after the insn AFTER. */
2960 emit_note_after (subtype
, after
)
2964 register rtx note
= rtx_alloc (NOTE
);
2965 INSN_UID (note
) = cur_insn_uid
++;
2966 NOTE_SOURCE_FILE (note
) = 0;
2967 NOTE_LINE_NUMBER (note
) = subtype
;
2968 add_insn_after (note
, after
);
2972 /* Emit a line note for FILE and LINE after the insn AFTER. */
2975 emit_line_note_after (file
, line
, after
)
2982 if (no_line_numbers
&& line
> 0)
2988 note
= rtx_alloc (NOTE
);
2989 INSN_UID (note
) = cur_insn_uid
++;
2990 NOTE_SOURCE_FILE (note
) = file
;
2991 NOTE_LINE_NUMBER (note
) = line
;
2992 add_insn_after (note
, after
);
2996 /* Make an insn of code INSN with pattern PATTERN
2997 and add it to the end of the doubly-linked list.
2998 If PATTERN is a SEQUENCE, take the elements of it
2999 and emit an insn for each element.
3001 Returns the last insn emitted. */
3007 rtx insn
= last_insn
;
3009 if (GET_CODE (pattern
) == SEQUENCE
)
3013 for (i
= 0; i
< XVECLEN (pattern
, 0); i
++)
3015 insn
= XVECEXP (pattern
, 0, i
);
3018 if (XVECLEN (pattern
, 0) < SEQUENCE_RESULT_SIZE
)
3019 sequence_result
[XVECLEN (pattern
, 0)] = pattern
;
3023 insn
= make_insn_raw (pattern
);
3030 /* Emit the insns in a chain starting with INSN.
3031 Return the last insn emitted. */
3041 rtx next
= NEXT_INSN (insn
);
3050 /* Emit the insns in a chain starting with INSN and place them in front of
3051 the insn BEFORE. Return the last insn emitted. */
3054 emit_insns_before (insn
, before
)
3062 rtx next
= NEXT_INSN (insn
);
3063 add_insn_before (insn
, before
);
3071 /* Emit the insns in a chain starting with FIRST and place them in back of
3072 the insn AFTER. Return the last insn emitted. */
3075 emit_insns_after (first
, after
)
3080 register rtx after_after
;
3088 for (last
= first
; NEXT_INSN (last
); last
= NEXT_INSN (last
))
3091 after_after
= NEXT_INSN (after
);
3093 NEXT_INSN (after
) = first
;
3094 PREV_INSN (first
) = after
;
3095 NEXT_INSN (last
) = after_after
;
3097 PREV_INSN (after_after
) = last
;
3099 if (after
== last_insn
)
3104 /* Make an insn of code JUMP_INSN with pattern PATTERN
3105 and add it to the end of the doubly-linked list. */
3108 emit_jump_insn (pattern
)
3111 if (GET_CODE (pattern
) == SEQUENCE
)
3112 return emit_insn (pattern
);
3115 register rtx insn
= make_jump_insn_raw (pattern
);
3121 /* Make an insn of code CALL_INSN with pattern PATTERN
3122 and add it to the end of the doubly-linked list. */
3125 emit_call_insn (pattern
)
3128 if (GET_CODE (pattern
) == SEQUENCE
)
3129 return emit_insn (pattern
);
3132 register rtx insn
= make_call_insn_raw (pattern
);
3134 PUT_CODE (insn
, CALL_INSN
);
3139 /* Add the label LABEL to the end of the doubly-linked list. */
3145 /* This can be called twice for the same label
3146 as a result of the confusion that follows a syntax error!
3147 So make it harmless. */
3148 if (INSN_UID (label
) == 0)
3150 INSN_UID (label
) = cur_insn_uid
++;
3156 /* Make an insn of code BARRIER
3157 and add it to the end of the doubly-linked list. */
3162 register rtx barrier
= rtx_alloc (BARRIER
);
3163 INSN_UID (barrier
) = cur_insn_uid
++;
3168 /* Make an insn of code NOTE
3169 with data-fields specified by FILE and LINE
3170 and add it to the end of the doubly-linked list,
3171 but only if line-numbers are desired for debugging info. */
3174 emit_line_note (file
, line
)
3178 emit_filename
= file
;
3182 if (no_line_numbers
)
3186 return emit_note (file
, line
);
3189 /* Make an insn of code NOTE
3190 with data-fields specified by FILE and LINE
3191 and add it to the end of the doubly-linked list.
3192 If it is a line-number NOTE, omit it if it matches the previous one. */
3195 emit_note (file
, line
)
3203 if (file
&& last_filename
&& !strcmp (file
, last_filename
)
3204 && line
== last_linenum
)
3206 last_filename
= file
;
3207 last_linenum
= line
;
3210 if (no_line_numbers
&& line
> 0)
3216 note
= rtx_alloc (NOTE
);
3217 INSN_UID (note
) = cur_insn_uid
++;
3218 NOTE_SOURCE_FILE (note
) = file
;
3219 NOTE_LINE_NUMBER (note
) = line
;
3224 /* Emit a NOTE, and don't omit it even if LINE is the previous note. */
3227 emit_line_note_force (file
, line
)
3232 return emit_line_note (file
, line
);
3235 /* Cause next statement to emit a line note even if the line number
3236 has not changed. This is used at the beginning of a function. */
3239 force_next_line_note ()
3244 /* Place a note of KIND on insn INSN with DATUM as the datum. If a
3245 note of this type already exists, remove it first. */
3248 set_unique_reg_note (insn
, kind
, datum
)
3253 rtx note
= find_reg_note (insn
, kind
, NULL_RTX
);
3255 /* First remove the note if there already is one. */
3257 remove_note (insn
, note
);
3259 REG_NOTES (insn
) = gen_rtx_EXPR_LIST (kind
, datum
, REG_NOTES (insn
));
3262 /* Return an indication of which type of insn should have X as a body.
3263 The value is CODE_LABEL, INSN, CALL_INSN or JUMP_INSN. */
3269 if (GET_CODE (x
) == CODE_LABEL
)
3271 if (GET_CODE (x
) == CALL
)
3273 if (GET_CODE (x
) == RETURN
)
3275 if (GET_CODE (x
) == SET
)
3277 if (SET_DEST (x
) == pc_rtx
)
3279 else if (GET_CODE (SET_SRC (x
)) == CALL
)
3284 if (GET_CODE (x
) == PARALLEL
)
3287 for (j
= XVECLEN (x
, 0) - 1; j
>= 0; j
--)
3288 if (GET_CODE (XVECEXP (x
, 0, j
)) == CALL
)
3290 else if (GET_CODE (XVECEXP (x
, 0, j
)) == SET
3291 && SET_DEST (XVECEXP (x
, 0, j
)) == pc_rtx
)
3293 else if (GET_CODE (XVECEXP (x
, 0, j
)) == SET
3294 && GET_CODE (SET_SRC (XVECEXP (x
, 0, j
))) == CALL
)
3300 /* Emit the rtl pattern X as an appropriate kind of insn.
3301 If X is a label, it is simply added into the insn chain. */
3307 enum rtx_code code
= classify_insn (x
);
3309 if (code
== CODE_LABEL
)
3310 return emit_label (x
);
3311 else if (code
== INSN
)
3312 return emit_insn (x
);
3313 else if (code
== JUMP_INSN
)
3315 register rtx insn
= emit_jump_insn (x
);
3316 if (simplejump_p (insn
) || GET_CODE (x
) == RETURN
)
3317 return emit_barrier ();
3320 else if (code
== CALL_INSN
)
3321 return emit_call_insn (x
);
3326 /* Begin emitting insns to a sequence which can be packaged in an
3327 RTL_EXPR. If this sequence will contain something that might cause
3328 the compiler to pop arguments to function calls (because those
3329 pops have previously been deferred; see INHIBIT_DEFER_POP for more
3330 details), use do_pending_stack_adjust before calling this function.
3331 That will ensure that the deferred pops are not accidentally
3332 emitted in the middel of this sequence. */
3337 struct sequence_stack
*tem
;
3339 if (sequence_element_free_list
)
3341 /* Reuse a previously-saved struct sequence_stack. */
3342 tem
= sequence_element_free_list
;
3343 sequence_element_free_list
= tem
->next
;
3346 tem
= (struct sequence_stack
*) permalloc (sizeof (struct sequence_stack
));
3348 tem
->next
= sequence_stack
;
3349 tem
->first
= first_insn
;
3350 tem
->last
= last_insn
;
3351 tem
->sequence_rtl_expr
= sequence_rtl_expr
;
3353 sequence_stack
= tem
;
3359 /* Similarly, but indicate that this sequence will be placed in T, an
3360 RTL_EXPR. See the documentation for start_sequence for more
3361 information about how to use this function. */
3364 start_sequence_for_rtl_expr (t
)
3369 sequence_rtl_expr
= t
;
3372 /* Set up the insn chain starting with FIRST as the current sequence,
3373 saving the previously current one. See the documentation for
3374 start_sequence for more information about how to use this function. */
3377 push_to_sequence (first
)
3384 for (last
= first
; last
&& NEXT_INSN (last
); last
= NEXT_INSN (last
));
3390 /* Set up the outer-level insn chain
3391 as the current sequence, saving the previously current one. */
3394 push_topmost_sequence ()
3396 struct sequence_stack
*stack
, *top
= NULL
;
3400 for (stack
= sequence_stack
; stack
; stack
= stack
->next
)
3403 first_insn
= top
->first
;
3404 last_insn
= top
->last
;
3405 sequence_rtl_expr
= top
->sequence_rtl_expr
;
3408 /* After emitting to the outer-level insn chain, update the outer-level
3409 insn chain, and restore the previous saved state. */
3412 pop_topmost_sequence ()
3414 struct sequence_stack
*stack
, *top
= NULL
;
3416 for (stack
= sequence_stack
; stack
; stack
= stack
->next
)
3419 top
->first
= first_insn
;
3420 top
->last
= last_insn
;
3421 /* ??? Why don't we save sequence_rtl_expr here? */
3426 /* After emitting to a sequence, restore previous saved state.
3428 To get the contents of the sequence just made, you must call
3429 `gen_sequence' *before* calling here.
3431 If the compiler might have deferred popping arguments while
3432 generating this sequence, and this sequence will not be immediately
3433 inserted into the instruction stream, use do_pending_stack_adjust
3434 before calling gen_sequence. That will ensure that the deferred
3435 pops are inserted into this sequence, and not into some random
3436 location in the instruction stream. See INHIBIT_DEFER_POP for more
3437 information about deferred popping of arguments. */
3442 struct sequence_stack
*tem
= sequence_stack
;
3444 first_insn
= tem
->first
;
3445 last_insn
= tem
->last
;
3446 sequence_rtl_expr
= tem
->sequence_rtl_expr
;
3447 sequence_stack
= tem
->next
;
3449 tem
->next
= sequence_element_free_list
;
3450 sequence_element_free_list
= tem
;
3453 /* Return 1 if currently emitting into a sequence. */
3458 return sequence_stack
!= 0;
3461 /* Generate a SEQUENCE rtx containing the insns already emitted
3462 to the current sequence.
3464 This is how the gen_... function from a DEFINE_EXPAND
3465 constructs the SEQUENCE that it returns. */
3475 /* Count the insns in the chain. */
3477 for (tem
= first_insn
; tem
; tem
= NEXT_INSN (tem
))
3480 /* If only one insn, return its pattern rather than a SEQUENCE.
3481 (Now that we cache SEQUENCE expressions, it isn't worth special-casing
3482 the case of an empty list.) */
3484 && ! RTX_FRAME_RELATED_P (first_insn
)
3485 && (GET_CODE (first_insn
) == INSN
3486 || GET_CODE (first_insn
) == JUMP_INSN
3487 /* Don't discard the call usage field. */
3488 || (GET_CODE (first_insn
) == CALL_INSN
3489 && CALL_INSN_FUNCTION_USAGE (first_insn
) == NULL_RTX
)))
3491 NEXT_INSN (first_insn
) = free_insn
;
3492 free_insn
= first_insn
;
3493 return PATTERN (first_insn
);
3496 /* Put them in a vector. See if we already have a SEQUENCE of the
3497 appropriate length around. */
3498 if (len
< SEQUENCE_RESULT_SIZE
&& (result
= sequence_result
[len
]) != 0)
3499 sequence_result
[len
] = 0;
3502 /* Ensure that this rtl goes in saveable_obstack, since we may
3504 push_obstacks_nochange ();
3505 rtl_in_saveable_obstack ();
3506 result
= gen_rtx_SEQUENCE (VOIDmode
, rtvec_alloc (len
));
3510 for (i
= 0, tem
= first_insn
; tem
; tem
= NEXT_INSN (tem
), i
++)
3511 XVECEXP (result
, 0, i
) = tem
;
3516 /* Put the various virtual registers into REGNO_REG_RTX. */
3519 init_virtual_regs ()
3521 regno_reg_rtx
[VIRTUAL_INCOMING_ARGS_REGNUM
] = virtual_incoming_args_rtx
;
3522 regno_reg_rtx
[VIRTUAL_STACK_VARS_REGNUM
] = virtual_stack_vars_rtx
;
3523 regno_reg_rtx
[VIRTUAL_STACK_DYNAMIC_REGNUM
] = virtual_stack_dynamic_rtx
;
3524 regno_reg_rtx
[VIRTUAL_OUTGOING_ARGS_REGNUM
] = virtual_outgoing_args_rtx
;
3525 regno_reg_rtx
[VIRTUAL_CFA_REGNUM
] = virtual_cfa_rtx
;
3528 /* Initialize data structures and variables in this file
3529 before generating rtl for each function. */
3538 sequence_rtl_expr
= NULL
;
3540 reg_rtx_no
= LAST_VIRTUAL_REGISTER
+ 1;
3543 first_label_num
= label_num
;
3545 sequence_stack
= NULL
;
3547 /* Clear the start_sequence/gen_sequence cache. */
3548 sequence_element_free_list
= 0;
3549 for (i
= 0; i
< SEQUENCE_RESULT_SIZE
; i
++)
3550 sequence_result
[i
] = 0;
3553 /* Init the tables that describe all the pseudo regs. */
3555 regno_pointer_flag_length
= LAST_VIRTUAL_REGISTER
+ 101;
3558 = (char *) savealloc (regno_pointer_flag_length
);
3559 bzero (regno_pointer_flag
, regno_pointer_flag_length
);
3562 = (char *) savealloc (regno_pointer_flag_length
);
3563 bzero (regno_pointer_align
, regno_pointer_flag_length
);
3566 = (rtx
*) savealloc (regno_pointer_flag_length
* sizeof (rtx
));
3567 bzero ((char *) regno_reg_rtx
, regno_pointer_flag_length
* sizeof (rtx
));
3569 /* Put copies of all the virtual register rtx into regno_reg_rtx. */
3570 init_virtual_regs ();
3572 /* Indicate that the virtual registers and stack locations are
3574 REGNO_POINTER_FLAG (STACK_POINTER_REGNUM
) = 1;
3575 REGNO_POINTER_FLAG (FRAME_POINTER_REGNUM
) = 1;
3576 REGNO_POINTER_FLAG (HARD_FRAME_POINTER_REGNUM
) = 1;
3577 REGNO_POINTER_FLAG (ARG_POINTER_REGNUM
) = 1;
3579 REGNO_POINTER_FLAG (VIRTUAL_INCOMING_ARGS_REGNUM
) = 1;
3580 REGNO_POINTER_FLAG (VIRTUAL_STACK_VARS_REGNUM
) = 1;
3581 REGNO_POINTER_FLAG (VIRTUAL_STACK_DYNAMIC_REGNUM
) = 1;
3582 REGNO_POINTER_FLAG (VIRTUAL_OUTGOING_ARGS_REGNUM
) = 1;
3583 REGNO_POINTER_FLAG (VIRTUAL_CFA_REGNUM
) = 1;
3585 #ifdef STACK_BOUNDARY
3586 REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM
) = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3587 REGNO_POINTER_ALIGN (FRAME_POINTER_REGNUM
) = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3588 REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM
)
3589 = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3590 REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM
) = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3592 REGNO_POINTER_ALIGN (VIRTUAL_INCOMING_ARGS_REGNUM
)
3593 = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3594 REGNO_POINTER_ALIGN (VIRTUAL_STACK_VARS_REGNUM
)
3595 = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3596 REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM
)
3597 = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3598 REGNO_POINTER_ALIGN (VIRTUAL_OUTGOING_ARGS_REGNUM
)
3599 = STACK_BOUNDARY
/ BITS_PER_UNIT
;
3600 REGNO_POINTER_ALIGN (VIRTUAL_CFA_REGNUM
) = UNITS_PER_WORD
;
3603 #ifdef INIT_EXPANDERS
3608 /* Create some permanent unique rtl objects shared between all functions.
3609 LINE_NUMBERS is nonzero if line numbers are to be generated. */
3612 init_emit_once (line_numbers
)
3616 enum machine_mode mode
;
3617 enum machine_mode double_mode
;
3619 no_line_numbers
= ! line_numbers
;
3621 sequence_stack
= NULL
;
3623 /* Compute the word and byte modes. */
3625 byte_mode
= VOIDmode
;
3626 word_mode
= VOIDmode
;
3627 double_mode
= VOIDmode
;
3629 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_INT
); mode
!= VOIDmode
;
3630 mode
= GET_MODE_WIDER_MODE (mode
))
3632 if (GET_MODE_BITSIZE (mode
) == BITS_PER_UNIT
3633 && byte_mode
== VOIDmode
)
3636 if (GET_MODE_BITSIZE (mode
) == BITS_PER_WORD
3637 && word_mode
== VOIDmode
)
3641 #ifndef DOUBLE_TYPE_SIZE
3642 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
3645 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_FLOAT
); mode
!= VOIDmode
;
3646 mode
= GET_MODE_WIDER_MODE (mode
))
3648 if (GET_MODE_BITSIZE (mode
) == DOUBLE_TYPE_SIZE
3649 && double_mode
== VOIDmode
)
3653 ptr_mode
= mode_for_size (POINTER_SIZE
, GET_MODE_CLASS (Pmode
), 0);
3655 /* Create the unique rtx's for certain rtx codes and operand values. */
3657 for (i
= - MAX_SAVED_CONST_INT
; i
<= MAX_SAVED_CONST_INT
; i
++)
3659 PUT_CODE (&const_int_rtx
[i
+ MAX_SAVED_CONST_INT
], CONST_INT
);
3660 PUT_MODE (&const_int_rtx
[i
+ MAX_SAVED_CONST_INT
], VOIDmode
);
3661 INTVAL (&const_int_rtx
[i
+ MAX_SAVED_CONST_INT
]) = i
;
3664 if (STORE_FLAG_VALUE
>= - MAX_SAVED_CONST_INT
3665 && STORE_FLAG_VALUE
<= MAX_SAVED_CONST_INT
)
3666 const_true_rtx
= &const_int_rtx
[STORE_FLAG_VALUE
+ MAX_SAVED_CONST_INT
];
3668 const_true_rtx
= gen_rtx_CONST_INT (VOIDmode
, STORE_FLAG_VALUE
);
3670 dconst0
= REAL_VALUE_ATOF ("0", double_mode
);
3671 dconst1
= REAL_VALUE_ATOF ("1", double_mode
);
3672 dconst2
= REAL_VALUE_ATOF ("2", double_mode
);
3673 dconstm1
= REAL_VALUE_ATOF ("-1", double_mode
);
3675 for (i
= 0; i
<= 2; i
++)
3677 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_FLOAT
); mode
!= VOIDmode
;
3678 mode
= GET_MODE_WIDER_MODE (mode
))
3680 rtx tem
= rtx_alloc (CONST_DOUBLE
);
3681 union real_extract u
;
3683 bzero ((char *) &u
, sizeof u
); /* Zero any holes in a structure. */
3684 u
.d
= i
== 0 ? dconst0
: i
== 1 ? dconst1
: dconst2
;
3686 bcopy ((char *) &u
, (char *) &CONST_DOUBLE_LOW (tem
), sizeof u
);
3687 CONST_DOUBLE_MEM (tem
) = cc0_rtx
;
3688 PUT_MODE (tem
, mode
);
3690 const_tiny_rtx
[i
][(int) mode
] = tem
;
3693 const_tiny_rtx
[i
][(int) VOIDmode
] = GEN_INT (i
);
3695 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_INT
); mode
!= VOIDmode
;
3696 mode
= GET_MODE_WIDER_MODE (mode
))
3697 const_tiny_rtx
[i
][(int) mode
] = GEN_INT (i
);
3699 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT
);
3701 mode
= GET_MODE_WIDER_MODE (mode
))
3702 const_tiny_rtx
[i
][(int) mode
] = GEN_INT (i
);
3705 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_CC
); mode
!= VOIDmode
;
3706 mode
= GET_MODE_WIDER_MODE (mode
))
3707 const_tiny_rtx
[0][(int) mode
] = const0_rtx
;
3710 /* Assign register numbers to the globally defined register rtx.
3711 This must be done at runtime because the register number field
3712 is in a union and some compilers can't initialize unions. */
3714 REGNO (stack_pointer_rtx
) = STACK_POINTER_REGNUM
;
3715 PUT_MODE (stack_pointer_rtx
, Pmode
);
3716 REGNO (frame_pointer_rtx
) = FRAME_POINTER_REGNUM
;
3717 PUT_MODE (frame_pointer_rtx
, Pmode
);
3718 #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
3719 REGNO (hard_frame_pointer_rtx
) = HARD_FRAME_POINTER_REGNUM
;
3720 PUT_MODE (hard_frame_pointer_rtx
, Pmode
);
3722 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && HARD_FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
3723 REGNO (arg_pointer_rtx
) = ARG_POINTER_REGNUM
;
3724 PUT_MODE (arg_pointer_rtx
, Pmode
);
3727 REGNO (virtual_incoming_args_rtx
) = VIRTUAL_INCOMING_ARGS_REGNUM
;
3728 PUT_MODE (virtual_incoming_args_rtx
, Pmode
);
3729 REGNO (virtual_stack_vars_rtx
) = VIRTUAL_STACK_VARS_REGNUM
;
3730 PUT_MODE (virtual_stack_vars_rtx
, Pmode
);
3731 REGNO (virtual_stack_dynamic_rtx
) = VIRTUAL_STACK_DYNAMIC_REGNUM
;
3732 PUT_MODE (virtual_stack_dynamic_rtx
, Pmode
);
3733 REGNO (virtual_outgoing_args_rtx
) = VIRTUAL_OUTGOING_ARGS_REGNUM
;
3734 PUT_MODE (virtual_outgoing_args_rtx
, Pmode
);
3735 REGNO (virtual_cfa_rtx
) = VIRTUAL_CFA_REGNUM
;
3736 PUT_MODE (virtual_cfa_rtx
, Pmode
);
3738 #ifdef RETURN_ADDRESS_POINTER_REGNUM
3739 return_address_pointer_rtx
3740 = gen_rtx_raw_REG (Pmode
, RETURN_ADDRESS_POINTER_REGNUM
);
3744 struct_value_rtx
= STRUCT_VALUE
;
3746 struct_value_rtx
= gen_rtx_REG (Pmode
, STRUCT_VALUE_REGNUM
);
3749 #ifdef STRUCT_VALUE_INCOMING
3750 struct_value_incoming_rtx
= STRUCT_VALUE_INCOMING
;
3752 #ifdef STRUCT_VALUE_INCOMING_REGNUM
3753 struct_value_incoming_rtx
3754 = gen_rtx_REG (Pmode
, STRUCT_VALUE_INCOMING_REGNUM
);
3756 struct_value_incoming_rtx
= struct_value_rtx
;
3760 #ifdef STATIC_CHAIN_REGNUM
3761 static_chain_rtx
= gen_rtx_REG (Pmode
, STATIC_CHAIN_REGNUM
);
3763 #ifdef STATIC_CHAIN_INCOMING_REGNUM
3764 if (STATIC_CHAIN_INCOMING_REGNUM
!= STATIC_CHAIN_REGNUM
)
3765 static_chain_incoming_rtx
= gen_rtx_REG (Pmode
, STATIC_CHAIN_INCOMING_REGNUM
);
3768 static_chain_incoming_rtx
= static_chain_rtx
;
3772 static_chain_rtx
= STATIC_CHAIN
;
3774 #ifdef STATIC_CHAIN_INCOMING
3775 static_chain_incoming_rtx
= STATIC_CHAIN_INCOMING
;
3777 static_chain_incoming_rtx
= static_chain_rtx
;
3781 #ifdef PIC_OFFSET_TABLE_REGNUM
3782 pic_offset_table_rtx
= gen_rtx_REG (Pmode
, PIC_OFFSET_TABLE_REGNUM
);
3785 #ifdef INIT_EXPANDERS
3786 /* This is to initialize save_machine_status and restore_machine_status before
3787 the first call to push_function_context_to. This is needed by the Chill
3788 front end which calls push_function_context_to before the first cal to
3789 init_function_start. */
3794 /* Query and clear/ restore no_line_numbers. This is used by the
3795 switch / case handling in stmt.c to give proper line numbers in
3796 warnings about unreachable code. */
3799 force_line_numbers ()
3801 int old
= no_line_numbers
;
3803 no_line_numbers
= 0;
3805 force_next_line_note ();
3810 restore_line_number_status (old_value
)
3813 no_line_numbers
= old_value
;