1 /* Convert tree expression to rtl instructions, for GNU compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "coretypes.h"
32 #include "hard-reg-set.h"
35 #include "insn-config.h"
36 #include "insn-attr.h"
37 /* Include expr.h after insn-config.h so we get HAVE_conditional_move. */
44 #include "typeclass.h"
47 #include "langhooks.h"
52 /* Decide whether a function's arguments should be processed
53 from first to last or from last to first.
55 They should if the stack and args grow in opposite directions, but
56 only if we have push insns. */
60 #ifndef PUSH_ARGS_REVERSED
61 #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
62 #define PUSH_ARGS_REVERSED /* If it's last to first. */
68 #ifndef STACK_PUSH_CODE
69 #ifdef STACK_GROWS_DOWNWARD
70 #define STACK_PUSH_CODE PRE_DEC
72 #define STACK_PUSH_CODE PRE_INC
76 /* Assume that case vectors are not pc-relative. */
77 #ifndef CASE_VECTOR_PC_RELATIVE
78 #define CASE_VECTOR_PC_RELATIVE 0
81 /* Convert defined/undefined to boolean. */
82 #ifdef TARGET_MEM_FUNCTIONS
83 #undef TARGET_MEM_FUNCTIONS
84 #define TARGET_MEM_FUNCTIONS 1
86 #define TARGET_MEM_FUNCTIONS 0
90 /* If this is nonzero, we do not bother generating VOLATILE
91 around volatile memory references, and we are willing to
92 output indirect addresses. If cse is to follow, we reject
93 indirect addresses so a useful potential cse is generated;
94 if it is used only once, instruction combination will produce
95 the same indirect address eventually. */
98 /* Chain of pending expressions for PLACEHOLDER_EXPR to replace. */
99 tree placeholder_list
= 0;
101 /* This structure is used by move_by_pieces to describe the move to
103 struct move_by_pieces
112 int explicit_inc_from
;
113 unsigned HOST_WIDE_INT len
;
114 HOST_WIDE_INT offset
;
118 /* This structure is used by store_by_pieces to describe the clear to
121 struct store_by_pieces
127 unsigned HOST_WIDE_INT len
;
128 HOST_WIDE_INT offset
;
129 rtx (*constfun
) (void *, HOST_WIDE_INT
, enum machine_mode
);
134 static rtx
enqueue_insn (rtx
, rtx
);
135 static unsigned HOST_WIDE_INT
move_by_pieces_ninsns (unsigned HOST_WIDE_INT
,
137 static void move_by_pieces_1 (rtx (*) (rtx
, ...), enum machine_mode
,
138 struct move_by_pieces
*);
139 static bool block_move_libcall_safe_for_call_parm (void);
140 static bool emit_block_move_via_movstr (rtx
, rtx
, rtx
, unsigned);
141 static rtx
emit_block_move_via_libcall (rtx
, rtx
, rtx
);
142 static tree
emit_block_move_libcall_fn (int);
143 static void emit_block_move_via_loop (rtx
, rtx
, rtx
, unsigned);
144 static rtx
clear_by_pieces_1 (void *, HOST_WIDE_INT
, enum machine_mode
);
145 static void clear_by_pieces (rtx
, unsigned HOST_WIDE_INT
, unsigned int);
146 static void store_by_pieces_1 (struct store_by_pieces
*, unsigned int);
147 static void store_by_pieces_2 (rtx (*) (rtx
, ...), enum machine_mode
,
148 struct store_by_pieces
*);
149 static bool clear_storage_via_clrstr (rtx
, rtx
, unsigned);
150 static rtx
clear_storage_via_libcall (rtx
, rtx
);
151 static tree
clear_storage_libcall_fn (int);
152 static rtx
compress_float_constant (rtx
, rtx
);
153 static rtx
get_subtarget (rtx
);
154 static int is_zeros_p (tree
);
155 static void store_constructor_field (rtx
, unsigned HOST_WIDE_INT
,
156 HOST_WIDE_INT
, enum machine_mode
,
157 tree
, tree
, int, int);
158 static void store_constructor (tree
, rtx
, int, HOST_WIDE_INT
);
159 static rtx
store_field (rtx
, HOST_WIDE_INT
, HOST_WIDE_INT
, enum machine_mode
,
160 tree
, enum machine_mode
, int, tree
, int);
161 static rtx
var_rtx (tree
);
163 static unsigned HOST_WIDE_INT
highest_pow2_factor (tree
);
164 static unsigned HOST_WIDE_INT
highest_pow2_factor_for_target (tree
, tree
);
166 static int is_aligning_offset (tree
, tree
);
167 static rtx
expand_increment (tree
, int, int);
168 static void expand_operands (tree
, tree
, rtx
, rtx
*, rtx
*,
169 enum expand_modifier
);
170 static rtx
do_store_flag (tree
, rtx
, enum machine_mode
, int);
172 static void emit_single_push_insn (enum machine_mode
, rtx
, tree
);
174 static void do_tablejump (rtx
, enum machine_mode
, rtx
, rtx
, rtx
);
175 static rtx
const_vector_from_tree (tree
);
177 /* Record for each mode whether we can move a register directly to or
178 from an object of that mode in memory. If we can't, we won't try
179 to use that mode directly when accessing a field of that mode. */
181 static char direct_load
[NUM_MACHINE_MODES
];
182 static char direct_store
[NUM_MACHINE_MODES
];
184 /* Record for each mode whether we can float-extend from memory. */
186 static bool float_extend_from_mem
[NUM_MACHINE_MODES
][NUM_MACHINE_MODES
];
188 /* This macro is used to determine whether move_by_pieces should be called
189 to perform a structure copy. */
190 #ifndef MOVE_BY_PIECES_P
191 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
192 (move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) MOVE_RATIO)
195 /* This macro is used to determine whether clear_by_pieces should be
196 called to clear storage. */
197 #ifndef CLEAR_BY_PIECES_P
198 #define CLEAR_BY_PIECES_P(SIZE, ALIGN) \
199 (move_by_pieces_ninsns (SIZE, ALIGN) < (unsigned int) CLEAR_RATIO)
202 /* This macro is used to determine whether store_by_pieces should be
203 called to "memset" storage with byte values other than zero, or
204 to "memcpy" storage when the source is a constant string. */
205 #ifndef STORE_BY_PIECES_P
206 #define STORE_BY_PIECES_P(SIZE, ALIGN) MOVE_BY_PIECES_P (SIZE, ALIGN)
209 /* This array records the insn_code of insns to perform block moves. */
210 enum insn_code movstr_optab
[NUM_MACHINE_MODES
];
212 /* This array records the insn_code of insns to perform block clears. */
213 enum insn_code clrstr_optab
[NUM_MACHINE_MODES
];
215 /* These arrays record the insn_code of two different kinds of insns
216 to perform block compares. */
217 enum insn_code cmpstr_optab
[NUM_MACHINE_MODES
];
218 enum insn_code cmpmem_optab
[NUM_MACHINE_MODES
];
220 /* Stack of EXPR_WITH_FILE_LOCATION nested expressions. */
221 struct file_stack
*expr_wfl_stack
;
223 /* SLOW_UNALIGNED_ACCESS is nonzero if unaligned accesses are very slow. */
225 #ifndef SLOW_UNALIGNED_ACCESS
226 #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
229 /* This is run once per compilation to set up which modes can be used
230 directly in memory and to initialize the block move optab. */
233 init_expr_once (void)
236 enum machine_mode mode
;
241 /* Try indexing by frame ptr and try by stack ptr.
242 It is known that on the Convex the stack ptr isn't a valid index.
243 With luck, one or the other is valid on any machine. */
244 mem
= gen_rtx_MEM (VOIDmode
, stack_pointer_rtx
);
245 mem1
= gen_rtx_MEM (VOIDmode
, frame_pointer_rtx
);
247 /* A scratch register we can modify in-place below to avoid
248 useless RTL allocations. */
249 reg
= gen_rtx_REG (VOIDmode
, -1);
251 insn
= rtx_alloc (INSN
);
252 pat
= gen_rtx_SET (0, NULL_RTX
, NULL_RTX
);
253 PATTERN (insn
) = pat
;
255 for (mode
= VOIDmode
; (int) mode
< NUM_MACHINE_MODES
;
256 mode
= (enum machine_mode
) ((int) mode
+ 1))
260 direct_load
[(int) mode
] = direct_store
[(int) mode
] = 0;
261 PUT_MODE (mem
, mode
);
262 PUT_MODE (mem1
, mode
);
263 PUT_MODE (reg
, mode
);
265 /* See if there is some register that can be used in this mode and
266 directly loaded or stored from memory. */
268 if (mode
!= VOIDmode
&& mode
!= BLKmode
)
269 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
270 && (direct_load
[(int) mode
] == 0 || direct_store
[(int) mode
] == 0);
273 if (! HARD_REGNO_MODE_OK (regno
, mode
))
279 SET_DEST (pat
) = reg
;
280 if (recog (pat
, insn
, &num_clobbers
) >= 0)
281 direct_load
[(int) mode
] = 1;
283 SET_SRC (pat
) = mem1
;
284 SET_DEST (pat
) = reg
;
285 if (recog (pat
, insn
, &num_clobbers
) >= 0)
286 direct_load
[(int) mode
] = 1;
289 SET_DEST (pat
) = mem
;
290 if (recog (pat
, insn
, &num_clobbers
) >= 0)
291 direct_store
[(int) mode
] = 1;
294 SET_DEST (pat
) = mem1
;
295 if (recog (pat
, insn
, &num_clobbers
) >= 0)
296 direct_store
[(int) mode
] = 1;
300 mem
= gen_rtx_MEM (VOIDmode
, gen_rtx_raw_REG (Pmode
, 10000));
302 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_FLOAT
); mode
!= VOIDmode
;
303 mode
= GET_MODE_WIDER_MODE (mode
))
305 enum machine_mode srcmode
;
306 for (srcmode
= GET_CLASS_NARROWEST_MODE (MODE_FLOAT
); srcmode
!= mode
;
307 srcmode
= GET_MODE_WIDER_MODE (srcmode
))
311 ic
= can_extend_p (mode
, srcmode
, 0);
312 if (ic
== CODE_FOR_nothing
)
315 PUT_MODE (mem
, srcmode
);
317 if ((*insn_data
[ic
].operand
[1].predicate
) (mem
, srcmode
))
318 float_extend_from_mem
[mode
][srcmode
] = true;
323 /* This is run at the start of compiling a function. */
328 cfun
->expr
= ggc_alloc_cleared (sizeof (struct expr_status
));
331 /* Small sanity check that the queue is empty at the end of a function. */
334 finish_expr_for_function (void)
340 /* Manage the queue of increment instructions to be output
341 for POSTINCREMENT_EXPR expressions, etc. */
343 /* Queue up to increment (or change) VAR later. BODY says how:
344 BODY should be the same thing you would pass to emit_insn
345 to increment right away. It will go to emit_insn later on.
347 The value is a QUEUED expression to be used in place of VAR
348 where you want to guarantee the pre-incrementation value of VAR. */
351 enqueue_insn (rtx var
, rtx body
)
353 pending_chain
= gen_rtx_QUEUED (GET_MODE (var
), var
, NULL_RTX
, NULL_RTX
,
354 body
, pending_chain
);
355 return pending_chain
;
358 /* Use protect_from_queue to convert a QUEUED expression
359 into something that you can put immediately into an instruction.
360 If the queued incrementation has not happened yet,
361 protect_from_queue returns the variable itself.
362 If the incrementation has happened, protect_from_queue returns a temp
363 that contains a copy of the old value of the variable.
365 Any time an rtx which might possibly be a QUEUED is to be put
366 into an instruction, it must be passed through protect_from_queue first.
367 QUEUED expressions are not meaningful in instructions.
369 Do not pass a value through protect_from_queue and then hold
370 on to it for a while before putting it in an instruction!
371 If the queue is flushed in between, incorrect code will result. */
374 protect_from_queue (rtx x
, int modify
)
376 RTX_CODE code
= GET_CODE (x
);
378 #if 0 /* A QUEUED can hang around after the queue is forced out. */
379 /* Shortcut for most common case. */
380 if (pending_chain
== 0)
386 /* A special hack for read access to (MEM (QUEUED ...)) to facilitate
387 use of autoincrement. Make a copy of the contents of the memory
388 location rather than a copy of the address, but not if the value is
389 of mode BLKmode. Don't modify X in place since it might be
391 if (code
== MEM
&& GET_MODE (x
) != BLKmode
392 && GET_CODE (XEXP (x
, 0)) == QUEUED
&& !modify
)
395 rtx
new = replace_equiv_address_nv (x
, QUEUED_VAR (y
));
399 rtx temp
= gen_reg_rtx (GET_MODE (x
));
401 emit_insn_before (gen_move_insn (temp
, new),
406 /* Copy the address into a pseudo, so that the returned value
407 remains correct across calls to emit_queue. */
408 return replace_equiv_address (new, copy_to_reg (XEXP (new, 0)));
411 /* Otherwise, recursively protect the subexpressions of all
412 the kinds of rtx's that can contain a QUEUED. */
415 rtx tem
= protect_from_queue (XEXP (x
, 0), 0);
416 if (tem
!= XEXP (x
, 0))
422 else if (code
== PLUS
|| code
== MULT
)
424 rtx new0
= protect_from_queue (XEXP (x
, 0), 0);
425 rtx new1
= protect_from_queue (XEXP (x
, 1), 0);
426 if (new0
!= XEXP (x
, 0) || new1
!= XEXP (x
, 1))
435 /* If the increment has not happened, use the variable itself. Copy it
436 into a new pseudo so that the value remains correct across calls to
438 if (QUEUED_INSN (x
) == 0)
439 return copy_to_reg (QUEUED_VAR (x
));
440 /* If the increment has happened and a pre-increment copy exists,
442 if (QUEUED_COPY (x
) != 0)
443 return QUEUED_COPY (x
);
444 /* The increment has happened but we haven't set up a pre-increment copy.
445 Set one up now, and use it. */
446 QUEUED_COPY (x
) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x
)));
447 emit_insn_before (gen_move_insn (QUEUED_COPY (x
), QUEUED_VAR (x
)),
449 return QUEUED_COPY (x
);
452 /* Return nonzero if X contains a QUEUED expression:
453 if it contains anything that will be altered by a queued increment.
454 We handle only combinations of MEM, PLUS, MINUS and MULT operators
455 since memory addresses generally contain only those. */
458 queued_subexp_p (rtx x
)
460 enum rtx_code code
= GET_CODE (x
);
466 return queued_subexp_p (XEXP (x
, 0));
470 return (queued_subexp_p (XEXP (x
, 0))
471 || queued_subexp_p (XEXP (x
, 1)));
477 /* Retrieve a mark on the queue. */
482 return pending_chain
;
485 /* Perform all the pending incrementations that have been enqueued
486 after MARK was retrieved. If MARK is null, perform all the
487 pending incrementations. */
490 emit_insns_enqueued_after_mark (rtx mark
)
494 /* The marked incrementation may have been emitted in the meantime
495 through a call to emit_queue. In this case, the mark is not valid
496 anymore so do nothing. */
497 if (mark
&& ! QUEUED_BODY (mark
))
500 while ((p
= pending_chain
) != mark
)
502 rtx body
= QUEUED_BODY (p
);
504 switch (GET_CODE (body
))
512 QUEUED_INSN (p
) = body
;
516 #ifdef ENABLE_CHECKING
523 QUEUED_INSN (p
) = emit_insn (body
);
528 pending_chain
= QUEUED_NEXT (p
);
532 /* Perform all the pending incrementations. */
537 emit_insns_enqueued_after_mark (NULL_RTX
);
540 /* Copy data from FROM to TO, where the machine modes are not the same.
541 Both modes may be integer, or both may be floating.
542 UNSIGNEDP should be nonzero if FROM is an unsigned type.
543 This causes zero-extension instead of sign-extension. */
546 convert_move (rtx to
, rtx from
, int unsignedp
)
548 enum machine_mode to_mode
= GET_MODE (to
);
549 enum machine_mode from_mode
= GET_MODE (from
);
550 int to_real
= GET_MODE_CLASS (to_mode
) == MODE_FLOAT
;
551 int from_real
= GET_MODE_CLASS (from_mode
) == MODE_FLOAT
;
555 /* rtx code for making an equivalent value. */
556 enum rtx_code equiv_code
= (unsignedp
< 0 ? UNKNOWN
557 : (unsignedp
? ZERO_EXTEND
: SIGN_EXTEND
));
559 to
= protect_from_queue (to
, 1);
560 from
= protect_from_queue (from
, 0);
562 if (to_real
!= from_real
)
565 /* If FROM is a SUBREG that indicates that we have already done at least
566 the required extension, strip it. We don't handle such SUBREGs as
569 if (GET_CODE (from
) == SUBREG
&& SUBREG_PROMOTED_VAR_P (from
)
570 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (from
)))
571 >= GET_MODE_SIZE (to_mode
))
572 && SUBREG_PROMOTED_UNSIGNED_P (from
) == unsignedp
)
573 from
= gen_lowpart (to_mode
, from
), from_mode
= to_mode
;
575 if (GET_CODE (to
) == SUBREG
&& SUBREG_PROMOTED_VAR_P (to
))
578 if (to_mode
== from_mode
579 || (from_mode
== VOIDmode
&& CONSTANT_P (from
)))
581 emit_move_insn (to
, from
);
585 if (VECTOR_MODE_P (to_mode
) || VECTOR_MODE_P (from_mode
))
587 if (GET_MODE_BITSIZE (from_mode
) != GET_MODE_BITSIZE (to_mode
))
590 if (VECTOR_MODE_P (to_mode
))
591 from
= simplify_gen_subreg (to_mode
, from
, GET_MODE (from
), 0);
593 to
= simplify_gen_subreg (from_mode
, to
, GET_MODE (to
), 0);
595 emit_move_insn (to
, from
);
599 if (GET_CODE (to
) == CONCAT
&& GET_CODE (from
) == CONCAT
)
601 convert_move (XEXP (to
, 0), XEXP (from
, 0), unsignedp
);
602 convert_move (XEXP (to
, 1), XEXP (from
, 1), unsignedp
);
611 if (GET_MODE_PRECISION (from_mode
) < GET_MODE_PRECISION (to_mode
))
613 else if (GET_MODE_PRECISION (from_mode
) > GET_MODE_PRECISION (to_mode
))
618 /* Try converting directly if the insn is supported. */
620 code
= tab
->handlers
[to_mode
][from_mode
].insn_code
;
621 if (code
!= CODE_FOR_nothing
)
623 emit_unop_insn (code
, to
, from
,
624 tab
== sext_optab
? FLOAT_EXTEND
: FLOAT_TRUNCATE
);
628 /* Otherwise use a libcall. */
629 libcall
= tab
->handlers
[to_mode
][from_mode
].libfunc
;
632 /* This conversion is not implemented yet. */
636 value
= emit_library_call_value (libcall
, NULL_RTX
, LCT_CONST
, to_mode
,
638 insns
= get_insns ();
640 emit_libcall_block (insns
, to
, value
,
641 tab
== trunc_optab
? gen_rtx_FLOAT_TRUNCATE (to_mode
,
643 : gen_rtx_FLOAT_EXTEND (to_mode
, from
));
647 /* Handle pointer conversion. */ /* SPEE 900220. */
648 /* Targets are expected to provide conversion insns between PxImode and
649 xImode for all MODE_PARTIAL_INT modes they use, but no others. */
650 if (GET_MODE_CLASS (to_mode
) == MODE_PARTIAL_INT
)
652 enum machine_mode full_mode
653 = smallest_mode_for_size (GET_MODE_BITSIZE (to_mode
), MODE_INT
);
655 if (trunc_optab
->handlers
[to_mode
][full_mode
].insn_code
659 if (full_mode
!= from_mode
)
660 from
= convert_to_mode (full_mode
, from
, unsignedp
);
661 emit_unop_insn (trunc_optab
->handlers
[to_mode
][full_mode
].insn_code
,
665 if (GET_MODE_CLASS (from_mode
) == MODE_PARTIAL_INT
)
667 enum machine_mode full_mode
668 = smallest_mode_for_size (GET_MODE_BITSIZE (from_mode
), MODE_INT
);
670 if (sext_optab
->handlers
[full_mode
][from_mode
].insn_code
674 emit_unop_insn (sext_optab
->handlers
[full_mode
][from_mode
].insn_code
,
676 if (to_mode
== full_mode
)
679 /* else proceed to integer conversions below */
680 from_mode
= full_mode
;
683 /* Now both modes are integers. */
685 /* Handle expanding beyond a word. */
686 if (GET_MODE_BITSIZE (from_mode
) < GET_MODE_BITSIZE (to_mode
)
687 && GET_MODE_BITSIZE (to_mode
) > BITS_PER_WORD
)
694 enum machine_mode lowpart_mode
;
695 int nwords
= CEIL (GET_MODE_SIZE (to_mode
), UNITS_PER_WORD
);
697 /* Try converting directly if the insn is supported. */
698 if ((code
= can_extend_p (to_mode
, from_mode
, unsignedp
))
701 /* If FROM is a SUBREG, put it into a register. Do this
702 so that we always generate the same set of insns for
703 better cse'ing; if an intermediate assignment occurred,
704 we won't be doing the operation directly on the SUBREG. */
705 if (optimize
> 0 && GET_CODE (from
) == SUBREG
)
706 from
= force_reg (from_mode
, from
);
707 emit_unop_insn (code
, to
, from
, equiv_code
);
710 /* Next, try converting via full word. */
711 else if (GET_MODE_BITSIZE (from_mode
) < BITS_PER_WORD
712 && ((code
= can_extend_p (to_mode
, word_mode
, unsignedp
))
713 != CODE_FOR_nothing
))
715 if (GET_CODE (to
) == REG
)
717 if (reg_overlap_mentioned_p (to
, from
))
718 from
= force_reg (from_mode
, from
);
719 emit_insn (gen_rtx_CLOBBER (VOIDmode
, to
));
721 convert_move (gen_lowpart (word_mode
, to
), from
, unsignedp
);
722 emit_unop_insn (code
, to
,
723 gen_lowpart (word_mode
, to
), equiv_code
);
727 /* No special multiword conversion insn; do it by hand. */
730 /* Since we will turn this into a no conflict block, we must ensure
731 that the source does not overlap the target. */
733 if (reg_overlap_mentioned_p (to
, from
))
734 from
= force_reg (from_mode
, from
);
736 /* Get a copy of FROM widened to a word, if necessary. */
737 if (GET_MODE_BITSIZE (from_mode
) < BITS_PER_WORD
)
738 lowpart_mode
= word_mode
;
740 lowpart_mode
= from_mode
;
742 lowfrom
= convert_to_mode (lowpart_mode
, from
, unsignedp
);
744 lowpart
= gen_lowpart (lowpart_mode
, to
);
745 emit_move_insn (lowpart
, lowfrom
);
747 /* Compute the value to put in each remaining word. */
749 fill_value
= const0_rtx
;
754 && insn_data
[(int) CODE_FOR_slt
].operand
[0].mode
== word_mode
755 && STORE_FLAG_VALUE
== -1)
757 emit_cmp_insn (lowfrom
, const0_rtx
, NE
, NULL_RTX
,
759 fill_value
= gen_reg_rtx (word_mode
);
760 emit_insn (gen_slt (fill_value
));
766 = expand_shift (RSHIFT_EXPR
, lowpart_mode
, lowfrom
,
767 size_int (GET_MODE_BITSIZE (lowpart_mode
) - 1),
769 fill_value
= convert_to_mode (word_mode
, fill_value
, 1);
773 /* Fill the remaining words. */
774 for (i
= GET_MODE_SIZE (lowpart_mode
) / UNITS_PER_WORD
; i
< nwords
; i
++)
776 int index
= (WORDS_BIG_ENDIAN
? nwords
- i
- 1 : i
);
777 rtx subword
= operand_subword (to
, index
, 1, to_mode
);
782 if (fill_value
!= subword
)
783 emit_move_insn (subword
, fill_value
);
786 insns
= get_insns ();
789 emit_no_conflict_block (insns
, to
, from
, NULL_RTX
,
790 gen_rtx_fmt_e (equiv_code
, to_mode
, copy_rtx (from
)));
794 /* Truncating multi-word to a word or less. */
795 if (GET_MODE_BITSIZE (from_mode
) > BITS_PER_WORD
796 && GET_MODE_BITSIZE (to_mode
) <= BITS_PER_WORD
)
798 if (!((GET_CODE (from
) == MEM
799 && ! MEM_VOLATILE_P (from
)
800 && direct_load
[(int) to_mode
]
801 && ! mode_dependent_address_p (XEXP (from
, 0)))
802 || GET_CODE (from
) == REG
803 || GET_CODE (from
) == SUBREG
))
804 from
= force_reg (from_mode
, from
);
805 convert_move (to
, gen_lowpart (word_mode
, from
), 0);
809 /* Now follow all the conversions between integers
810 no more than a word long. */
812 /* For truncation, usually we can just refer to FROM in a narrower mode. */
813 if (GET_MODE_BITSIZE (to_mode
) < GET_MODE_BITSIZE (from_mode
)
814 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode
),
815 GET_MODE_BITSIZE (from_mode
)))
817 if (!((GET_CODE (from
) == MEM
818 && ! MEM_VOLATILE_P (from
)
819 && direct_load
[(int) to_mode
]
820 && ! mode_dependent_address_p (XEXP (from
, 0)))
821 || GET_CODE (from
) == REG
822 || GET_CODE (from
) == SUBREG
))
823 from
= force_reg (from_mode
, from
);
824 if (GET_CODE (from
) == REG
&& REGNO (from
) < FIRST_PSEUDO_REGISTER
825 && ! HARD_REGNO_MODE_OK (REGNO (from
), to_mode
))
826 from
= copy_to_reg (from
);
827 emit_move_insn (to
, gen_lowpart (to_mode
, from
));
831 /* Handle extension. */
832 if (GET_MODE_BITSIZE (to_mode
) > GET_MODE_BITSIZE (from_mode
))
834 /* Convert directly if that works. */
835 if ((code
= can_extend_p (to_mode
, from_mode
, unsignedp
))
839 from
= force_not_mem (from
);
841 emit_unop_insn (code
, to
, from
, equiv_code
);
846 enum machine_mode intermediate
;
850 /* Search for a mode to convert via. */
851 for (intermediate
= from_mode
; intermediate
!= VOIDmode
;
852 intermediate
= GET_MODE_WIDER_MODE (intermediate
))
853 if (((can_extend_p (to_mode
, intermediate
, unsignedp
)
855 || (GET_MODE_SIZE (to_mode
) < GET_MODE_SIZE (intermediate
)
856 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode
),
857 GET_MODE_BITSIZE (intermediate
))))
858 && (can_extend_p (intermediate
, from_mode
, unsignedp
)
859 != CODE_FOR_nothing
))
861 convert_move (to
, convert_to_mode (intermediate
, from
,
862 unsignedp
), unsignedp
);
866 /* No suitable intermediate mode.
867 Generate what we need with shifts. */
868 shift_amount
= build_int_2 (GET_MODE_BITSIZE (to_mode
)
869 - GET_MODE_BITSIZE (from_mode
), 0);
870 from
= gen_lowpart (to_mode
, force_reg (from_mode
, from
));
871 tmp
= expand_shift (LSHIFT_EXPR
, to_mode
, from
, shift_amount
,
873 tmp
= expand_shift (RSHIFT_EXPR
, to_mode
, tmp
, shift_amount
,
876 emit_move_insn (to
, tmp
);
881 /* Support special truncate insns for certain modes. */
882 if (trunc_optab
->handlers
[to_mode
][from_mode
].insn_code
!= CODE_FOR_nothing
)
884 emit_unop_insn (trunc_optab
->handlers
[to_mode
][from_mode
].insn_code
,
889 /* Handle truncation of volatile memrefs, and so on;
890 the things that couldn't be truncated directly,
891 and for which there was no special instruction.
893 ??? Code above formerly short-circuited this, for most integer
894 mode pairs, with a force_reg in from_mode followed by a recursive
895 call to this routine. Appears always to have been wrong. */
896 if (GET_MODE_BITSIZE (to_mode
) < GET_MODE_BITSIZE (from_mode
))
898 rtx temp
= force_reg (to_mode
, gen_lowpart (to_mode
, from
));
899 emit_move_insn (to
, temp
);
903 /* Mode combination is not recognized. */
907 /* Return an rtx for a value that would result
908 from converting X to mode MODE.
909 Both X and MODE may be floating, or both integer.
910 UNSIGNEDP is nonzero if X is an unsigned value.
911 This can be done by referring to a part of X in place
912 or by copying to a new temporary with conversion.
914 This function *must not* call protect_from_queue
915 except when putting X into an insn (in which case convert_move does it). */
918 convert_to_mode (enum machine_mode mode
, rtx x
, int unsignedp
)
920 return convert_modes (mode
, VOIDmode
, x
, unsignedp
);
923 /* Return an rtx for a value that would result
924 from converting X from mode OLDMODE to mode MODE.
925 Both modes may be floating, or both integer.
926 UNSIGNEDP is nonzero if X is an unsigned value.
928 This can be done by referring to a part of X in place
929 or by copying to a new temporary with conversion.
931 You can give VOIDmode for OLDMODE, if you are sure X has a nonvoid mode.
933 This function *must not* call protect_from_queue
934 except when putting X into an insn (in which case convert_move does it). */
937 convert_modes (enum machine_mode mode
, enum machine_mode oldmode
, rtx x
, int unsignedp
)
941 /* If FROM is a SUBREG that indicates that we have already done at least
942 the required extension, strip it. */
944 if (GET_CODE (x
) == SUBREG
&& SUBREG_PROMOTED_VAR_P (x
)
945 && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x
))) >= GET_MODE_SIZE (mode
)
946 && SUBREG_PROMOTED_UNSIGNED_P (x
) == unsignedp
)
947 x
= gen_lowpart (mode
, x
);
949 if (GET_MODE (x
) != VOIDmode
)
950 oldmode
= GET_MODE (x
);
955 /* There is one case that we must handle specially: If we are converting
956 a CONST_INT into a mode whose size is twice HOST_BITS_PER_WIDE_INT and
957 we are to interpret the constant as unsigned, gen_lowpart will do
958 the wrong if the constant appears negative. What we want to do is
959 make the high-order word of the constant zero, not all ones. */
961 if (unsignedp
&& GET_MODE_CLASS (mode
) == MODE_INT
962 && GET_MODE_BITSIZE (mode
) == 2 * HOST_BITS_PER_WIDE_INT
963 && GET_CODE (x
) == CONST_INT
&& INTVAL (x
) < 0)
965 HOST_WIDE_INT val
= INTVAL (x
);
967 if (oldmode
!= VOIDmode
968 && HOST_BITS_PER_WIDE_INT
> GET_MODE_BITSIZE (oldmode
))
970 int width
= GET_MODE_BITSIZE (oldmode
);
972 /* We need to zero extend VAL. */
973 val
&= ((HOST_WIDE_INT
) 1 << width
) - 1;
976 return immed_double_const (val
, (HOST_WIDE_INT
) 0, mode
);
979 /* We can do this with a gen_lowpart if both desired and current modes
980 are integer, and this is either a constant integer, a register, or a
981 non-volatile MEM. Except for the constant case where MODE is no
982 wider than HOST_BITS_PER_WIDE_INT, we must be narrowing the operand. */
984 if ((GET_CODE (x
) == CONST_INT
985 && GET_MODE_BITSIZE (mode
) <= HOST_BITS_PER_WIDE_INT
)
986 || (GET_MODE_CLASS (mode
) == MODE_INT
987 && GET_MODE_CLASS (oldmode
) == MODE_INT
988 && (GET_CODE (x
) == CONST_DOUBLE
989 || (GET_MODE_SIZE (mode
) <= GET_MODE_SIZE (oldmode
)
990 && ((GET_CODE (x
) == MEM
&& ! MEM_VOLATILE_P (x
)
991 && direct_load
[(int) mode
])
992 || (GET_CODE (x
) == REG
993 && (! HARD_REGISTER_P (x
)
994 || HARD_REGNO_MODE_OK (REGNO (x
), mode
))
995 && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode
),
996 GET_MODE_BITSIZE (GET_MODE (x
)))))))))
998 /* ?? If we don't know OLDMODE, we have to assume here that
999 X does not need sign- or zero-extension. This may not be
1000 the case, but it's the best we can do. */
1001 if (GET_CODE (x
) == CONST_INT
&& oldmode
!= VOIDmode
1002 && GET_MODE_SIZE (mode
) > GET_MODE_SIZE (oldmode
))
1004 HOST_WIDE_INT val
= INTVAL (x
);
1005 int width
= GET_MODE_BITSIZE (oldmode
);
1007 /* We must sign or zero-extend in this case. Start by
1008 zero-extending, then sign extend if we need to. */
1009 val
&= ((HOST_WIDE_INT
) 1 << width
) - 1;
1011 && (val
& ((HOST_WIDE_INT
) 1 << (width
- 1))))
1012 val
|= (HOST_WIDE_INT
) (-1) << width
;
1014 return gen_int_mode (val
, mode
);
1017 return gen_lowpart (mode
, x
);
1020 /* Converting from integer constant into mode is always equivalent to an
1021 subreg operation. */
1022 if (VECTOR_MODE_P (mode
) && GET_MODE (x
) == VOIDmode
)
1024 if (GET_MODE_BITSIZE (mode
) != GET_MODE_BITSIZE (oldmode
))
1026 return simplify_gen_subreg (mode
, x
, oldmode
, 0);
1029 temp
= gen_reg_rtx (mode
);
1030 convert_move (temp
, x
, unsignedp
);
1034 /* STORE_MAX_PIECES is the number of bytes at a time that we can
1035 store efficiently. Due to internal GCC limitations, this is
1036 MOVE_MAX_PIECES limited by the number of bytes GCC can represent
1037 for an immediate constant. */
1039 #define STORE_MAX_PIECES MIN (MOVE_MAX_PIECES, 2 * sizeof (HOST_WIDE_INT))
1041 /* Determine whether the LEN bytes can be moved by using several move
1042 instructions. Return nonzero if a call to move_by_pieces should
1046 can_move_by_pieces (unsigned HOST_WIDE_INT len
,
1047 unsigned int align ATTRIBUTE_UNUSED
)
1049 return MOVE_BY_PIECES_P (len
, align
);
1052 /* Generate several move instructions to copy LEN bytes from block FROM to
1053 block TO. (These are MEM rtx's with BLKmode). The caller must pass FROM
1054 and TO through protect_from_queue before calling.
1056 If PUSH_ROUNDING is defined and TO is NULL, emit_single_push_insn is
1057 used to push FROM to the stack.
1059 ALIGN is maximum stack alignment we can assume.
1061 If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
1062 mempcpy, and if ENDP is 2 return memory the end minus one byte ala
1066 move_by_pieces (rtx to
, rtx from
, unsigned HOST_WIDE_INT len
,
1067 unsigned int align
, int endp
)
1069 struct move_by_pieces data
;
1070 rtx to_addr
, from_addr
= XEXP (from
, 0);
1071 unsigned int max_size
= MOVE_MAX_PIECES
+ 1;
1072 enum machine_mode mode
= VOIDmode
, tmode
;
1073 enum insn_code icode
;
1075 align
= MIN (to
? MEM_ALIGN (to
) : align
, MEM_ALIGN (from
));
1078 data
.from_addr
= from_addr
;
1081 to_addr
= XEXP (to
, 0);
1084 = (GET_CODE (to_addr
) == PRE_INC
|| GET_CODE (to_addr
) == PRE_DEC
1085 || GET_CODE (to_addr
) == POST_INC
|| GET_CODE (to_addr
) == POST_DEC
);
1087 = (GET_CODE (to_addr
) == PRE_DEC
|| GET_CODE (to_addr
) == POST_DEC
);
1094 #ifdef STACK_GROWS_DOWNWARD
1100 data
.to_addr
= to_addr
;
1103 = (GET_CODE (from_addr
) == PRE_INC
|| GET_CODE (from_addr
) == PRE_DEC
1104 || GET_CODE (from_addr
) == POST_INC
1105 || GET_CODE (from_addr
) == POST_DEC
);
1107 data
.explicit_inc_from
= 0;
1108 data
.explicit_inc_to
= 0;
1109 if (data
.reverse
) data
.offset
= len
;
1112 /* If copying requires more than two move insns,
1113 copy addresses to registers (to make displacements shorter)
1114 and use post-increment if available. */
1115 if (!(data
.autinc_from
&& data
.autinc_to
)
1116 && move_by_pieces_ninsns (len
, align
) > 2)
1118 /* Find the mode of the largest move... */
1119 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
1120 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
1121 if (GET_MODE_SIZE (tmode
) < max_size
)
1124 if (USE_LOAD_PRE_DECREMENT (mode
) && data
.reverse
&& ! data
.autinc_from
)
1126 data
.from_addr
= copy_addr_to_reg (plus_constant (from_addr
, len
));
1127 data
.autinc_from
= 1;
1128 data
.explicit_inc_from
= -1;
1130 if (USE_LOAD_POST_INCREMENT (mode
) && ! data
.autinc_from
)
1132 data
.from_addr
= copy_addr_to_reg (from_addr
);
1133 data
.autinc_from
= 1;
1134 data
.explicit_inc_from
= 1;
1136 if (!data
.autinc_from
&& CONSTANT_P (from_addr
))
1137 data
.from_addr
= copy_addr_to_reg (from_addr
);
1138 if (USE_STORE_PRE_DECREMENT (mode
) && data
.reverse
&& ! data
.autinc_to
)
1140 data
.to_addr
= copy_addr_to_reg (plus_constant (to_addr
, len
));
1142 data
.explicit_inc_to
= -1;
1144 if (USE_STORE_POST_INCREMENT (mode
) && ! data
.reverse
&& ! data
.autinc_to
)
1146 data
.to_addr
= copy_addr_to_reg (to_addr
);
1148 data
.explicit_inc_to
= 1;
1150 if (!data
.autinc_to
&& CONSTANT_P (to_addr
))
1151 data
.to_addr
= copy_addr_to_reg (to_addr
);
1154 if (! SLOW_UNALIGNED_ACCESS (word_mode
, align
)
1155 || align
> MOVE_MAX
* BITS_PER_UNIT
|| align
>= BIGGEST_ALIGNMENT
)
1156 align
= MOVE_MAX
* BITS_PER_UNIT
;
1158 /* First move what we can in the largest integer mode, then go to
1159 successively smaller modes. */
1161 while (max_size
> 1)
1163 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
1164 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
1165 if (GET_MODE_SIZE (tmode
) < max_size
)
1168 if (mode
== VOIDmode
)
1171 icode
= mov_optab
->handlers
[(int) mode
].insn_code
;
1172 if (icode
!= CODE_FOR_nothing
&& align
>= GET_MODE_ALIGNMENT (mode
))
1173 move_by_pieces_1 (GEN_FCN (icode
), mode
, &data
);
1175 max_size
= GET_MODE_SIZE (mode
);
1178 /* The code above should have handled everything. */
1192 if (HAVE_POST_INCREMENT
&& data
.explicit_inc_to
> 0)
1193 emit_insn (gen_add2_insn (data
.to_addr
, constm1_rtx
));
1195 data
.to_addr
= copy_addr_to_reg (plus_constant (data
.to_addr
,
1198 to1
= adjust_automodify_address (data
.to
, QImode
, data
.to_addr
,
1205 to1
= adjust_address (data
.to
, QImode
, data
.offset
);
1213 /* Return number of insns required to move L bytes by pieces.
1214 ALIGN (in bits) is maximum alignment we can assume. */
1216 static unsigned HOST_WIDE_INT
1217 move_by_pieces_ninsns (unsigned HOST_WIDE_INT l
, unsigned int align
)
1219 unsigned HOST_WIDE_INT n_insns
= 0;
1220 unsigned HOST_WIDE_INT max_size
= MOVE_MAX
+ 1;
1222 if (! SLOW_UNALIGNED_ACCESS (word_mode
, align
)
1223 || align
> MOVE_MAX
* BITS_PER_UNIT
|| align
>= BIGGEST_ALIGNMENT
)
1224 align
= MOVE_MAX
* BITS_PER_UNIT
;
1226 while (max_size
> 1)
1228 enum machine_mode mode
= VOIDmode
, tmode
;
1229 enum insn_code icode
;
1231 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
1232 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
1233 if (GET_MODE_SIZE (tmode
) < max_size
)
1236 if (mode
== VOIDmode
)
1239 icode
= mov_optab
->handlers
[(int) mode
].insn_code
;
1240 if (icode
!= CODE_FOR_nothing
&& align
>= GET_MODE_ALIGNMENT (mode
))
1241 n_insns
+= l
/ GET_MODE_SIZE (mode
), l
%= GET_MODE_SIZE (mode
);
1243 max_size
= GET_MODE_SIZE (mode
);
1251 /* Subroutine of move_by_pieces. Move as many bytes as appropriate
1252 with move instructions for mode MODE. GENFUN is the gen_... function
1253 to make a move insn for that mode. DATA has all the other info. */
1256 move_by_pieces_1 (rtx (*genfun
) (rtx
, ...), enum machine_mode mode
,
1257 struct move_by_pieces
*data
)
1259 unsigned int size
= GET_MODE_SIZE (mode
);
1260 rtx to1
= NULL_RTX
, from1
;
1262 while (data
->len
>= size
)
1265 data
->offset
-= size
;
1269 if (data
->autinc_to
)
1270 to1
= adjust_automodify_address (data
->to
, mode
, data
->to_addr
,
1273 to1
= adjust_address (data
->to
, mode
, data
->offset
);
1276 if (data
->autinc_from
)
1277 from1
= adjust_automodify_address (data
->from
, mode
, data
->from_addr
,
1280 from1
= adjust_address (data
->from
, mode
, data
->offset
);
1282 if (HAVE_PRE_DECREMENT
&& data
->explicit_inc_to
< 0)
1283 emit_insn (gen_add2_insn (data
->to_addr
,
1284 GEN_INT (-(HOST_WIDE_INT
)size
)));
1285 if (HAVE_PRE_DECREMENT
&& data
->explicit_inc_from
< 0)
1286 emit_insn (gen_add2_insn (data
->from_addr
,
1287 GEN_INT (-(HOST_WIDE_INT
)size
)));
1290 emit_insn ((*genfun
) (to1
, from1
));
1293 #ifdef PUSH_ROUNDING
1294 emit_single_push_insn (mode
, from1
, NULL
);
1300 if (HAVE_POST_INCREMENT
&& data
->explicit_inc_to
> 0)
1301 emit_insn (gen_add2_insn (data
->to_addr
, GEN_INT (size
)));
1302 if (HAVE_POST_INCREMENT
&& data
->explicit_inc_from
> 0)
1303 emit_insn (gen_add2_insn (data
->from_addr
, GEN_INT (size
)));
1305 if (! data
->reverse
)
1306 data
->offset
+= size
;
1312 /* Emit code to move a block Y to a block X. This may be done with
1313 string-move instructions, with multiple scalar move instructions,
1314 or with a library call.
1316 Both X and Y must be MEM rtx's (perhaps inside VOLATILE) with mode BLKmode.
1317 SIZE is an rtx that says how long they are.
1318 ALIGN is the maximum alignment we can assume they have.
1319 METHOD describes what kind of copy this is, and what mechanisms may be used.
1321 Return the address of the new block, if memcpy is called and returns it,
1325 emit_block_move (rtx x
, rtx y
, rtx size
, enum block_op_methods method
)
1333 case BLOCK_OP_NORMAL
:
1334 may_use_call
= true;
1337 case BLOCK_OP_CALL_PARM
:
1338 may_use_call
= block_move_libcall_safe_for_call_parm ();
1340 /* Make inhibit_defer_pop nonzero around the library call
1341 to force it to pop the arguments right away. */
1345 case BLOCK_OP_NO_LIBCALL
:
1346 may_use_call
= false;
1353 align
= MIN (MEM_ALIGN (x
), MEM_ALIGN (y
));
1355 if (GET_MODE (x
) != BLKmode
)
1357 if (GET_MODE (y
) != BLKmode
)
1360 x
= protect_from_queue (x
, 1);
1361 y
= protect_from_queue (y
, 0);
1362 size
= protect_from_queue (size
, 0);
1364 if (GET_CODE (x
) != MEM
)
1366 if (GET_CODE (y
) != MEM
)
1371 /* Set MEM_SIZE as appropriate for this block copy. The main place this
1372 can be incorrect is coming from __builtin_memcpy. */
1373 if (GET_CODE (size
) == CONST_INT
)
1375 if (INTVAL (size
) == 0)
1378 x
= shallow_copy_rtx (x
);
1379 y
= shallow_copy_rtx (y
);
1380 set_mem_size (x
, size
);
1381 set_mem_size (y
, size
);
1384 if (GET_CODE (size
) == CONST_INT
&& MOVE_BY_PIECES_P (INTVAL (size
), align
))
1385 move_by_pieces (x
, y
, INTVAL (size
), align
, 0);
1386 else if (emit_block_move_via_movstr (x
, y
, size
, align
))
1388 else if (may_use_call
)
1389 retval
= emit_block_move_via_libcall (x
, y
, size
);
1391 emit_block_move_via_loop (x
, y
, size
, align
);
1393 if (method
== BLOCK_OP_CALL_PARM
)
1399 /* A subroutine of emit_block_move. Returns true if calling the
1400 block move libcall will not clobber any parameters which may have
1401 already been placed on the stack. */
1404 block_move_libcall_safe_for_call_parm (void)
1406 /* If arguments are pushed on the stack, then they're safe. */
1410 /* If registers go on the stack anyway, any argument is sure to clobber
1411 an outgoing argument. */
1412 #if defined (REG_PARM_STACK_SPACE) && defined (OUTGOING_REG_PARM_STACK_SPACE)
1414 tree fn
= emit_block_move_libcall_fn (false);
1416 if (REG_PARM_STACK_SPACE (fn
) != 0)
1421 /* If any argument goes in memory, then it might clobber an outgoing
1424 CUMULATIVE_ARGS args_so_far
;
1427 fn
= emit_block_move_libcall_fn (false);
1428 INIT_CUMULATIVE_ARGS (args_so_far
, TREE_TYPE (fn
), NULL_RTX
, 0, 3);
1430 arg
= TYPE_ARG_TYPES (TREE_TYPE (fn
));
1431 for ( ; arg
!= void_list_node
; arg
= TREE_CHAIN (arg
))
1433 enum machine_mode mode
= TYPE_MODE (TREE_VALUE (arg
));
1434 rtx tmp
= FUNCTION_ARG (args_so_far
, mode
, NULL_TREE
, 1);
1435 if (!tmp
|| !REG_P (tmp
))
1437 #ifdef FUNCTION_ARG_PARTIAL_NREGS
1438 if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far
, mode
,
1442 FUNCTION_ARG_ADVANCE (args_so_far
, mode
, NULL_TREE
, 1);
1448 /* A subroutine of emit_block_move. Expand a movstr pattern;
1449 return true if successful. */
1452 emit_block_move_via_movstr (rtx x
, rtx y
, rtx size
, unsigned int align
)
1454 rtx opalign
= GEN_INT (align
/ BITS_PER_UNIT
);
1455 enum machine_mode mode
;
1457 /* Since this is a move insn, we don't care about volatility. */
1460 /* Try the most limited insn first, because there's no point
1461 including more than one in the machine description unless
1462 the more limited one has some advantage. */
1464 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_INT
); mode
!= VOIDmode
;
1465 mode
= GET_MODE_WIDER_MODE (mode
))
1467 enum insn_code code
= movstr_optab
[(int) mode
];
1468 insn_operand_predicate_fn pred
;
1470 if (code
!= CODE_FOR_nothing
1471 /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
1472 here because if SIZE is less than the mode mask, as it is
1473 returned by the macro, it will definitely be less than the
1474 actual mode mask. */
1475 && ((GET_CODE (size
) == CONST_INT
1476 && ((unsigned HOST_WIDE_INT
) INTVAL (size
)
1477 <= (GET_MODE_MASK (mode
) >> 1)))
1478 || GET_MODE_BITSIZE (mode
) >= BITS_PER_WORD
)
1479 && ((pred
= insn_data
[(int) code
].operand
[0].predicate
) == 0
1480 || (*pred
) (x
, BLKmode
))
1481 && ((pred
= insn_data
[(int) code
].operand
[1].predicate
) == 0
1482 || (*pred
) (y
, BLKmode
))
1483 && ((pred
= insn_data
[(int) code
].operand
[3].predicate
) == 0
1484 || (*pred
) (opalign
, VOIDmode
)))
1487 rtx last
= get_last_insn ();
1490 op2
= convert_to_mode (mode
, size
, 1);
1491 pred
= insn_data
[(int) code
].operand
[2].predicate
;
1492 if (pred
!= 0 && ! (*pred
) (op2
, mode
))
1493 op2
= copy_to_mode_reg (mode
, op2
);
1495 /* ??? When called via emit_block_move_for_call, it'd be
1496 nice if there were some way to inform the backend, so
1497 that it doesn't fail the expansion because it thinks
1498 emitting the libcall would be more efficient. */
1500 pat
= GEN_FCN ((int) code
) (x
, y
, op2
, opalign
);
1508 delete_insns_since (last
);
1516 /* A subroutine of emit_block_move. Expand a call to memcpy or bcopy.
1517 Return the return value from memcpy, 0 otherwise. */
1520 emit_block_move_via_libcall (rtx dst
, rtx src
, rtx size
)
1522 rtx dst_addr
, src_addr
;
1523 tree call_expr
, arg_list
, fn
, src_tree
, dst_tree
, size_tree
;
1524 enum machine_mode size_mode
;
1527 /* DST, SRC, or SIZE may have been passed through protect_from_queue.
1529 It is unsafe to save the value generated by protect_from_queue and reuse
1530 it later. Consider what happens if emit_queue is called before the
1531 return value from protect_from_queue is used.
1533 Expansion of the CALL_EXPR below will call emit_queue before we are
1534 finished emitting RTL for argument setup. So if we are not careful we
1535 could get the wrong value for an argument.
1537 To avoid this problem we go ahead and emit code to copy the addresses of
1538 DST and SRC and SIZE into new pseudos. We can then place those new
1539 pseudos into an RTL_EXPR and use them later, even after a call to
1542 Note this is not strictly needed for library calls since they do not call
1543 emit_queue before loading their arguments. However, we may need to have
1544 library calls call emit_queue in the future since failing to do so could
1545 cause problems for targets which define SMALL_REGISTER_CLASSES and pass
1546 arguments in registers. */
1548 dst_addr
= copy_to_mode_reg (Pmode
, XEXP (dst
, 0));
1549 src_addr
= copy_to_mode_reg (Pmode
, XEXP (src
, 0));
1551 dst_addr
= convert_memory_address (ptr_mode
, dst_addr
);
1552 src_addr
= convert_memory_address (ptr_mode
, src_addr
);
1554 dst_tree
= make_tree (ptr_type_node
, dst_addr
);
1555 src_tree
= make_tree (ptr_type_node
, src_addr
);
1557 if (TARGET_MEM_FUNCTIONS
)
1558 size_mode
= TYPE_MODE (sizetype
);
1560 size_mode
= TYPE_MODE (unsigned_type_node
);
1562 size
= convert_to_mode (size_mode
, size
, 1);
1563 size
= copy_to_mode_reg (size_mode
, size
);
1565 /* It is incorrect to use the libcall calling conventions to call
1566 memcpy in this context. This could be a user call to memcpy and
1567 the user may wish to examine the return value from memcpy. For
1568 targets where libcalls and normal calls have different conventions
1569 for returning pointers, we could end up generating incorrect code.
1571 For convenience, we generate the call to bcopy this way as well. */
1573 if (TARGET_MEM_FUNCTIONS
)
1574 size_tree
= make_tree (sizetype
, size
);
1576 size_tree
= make_tree (unsigned_type_node
, size
);
1578 fn
= emit_block_move_libcall_fn (true);
1579 arg_list
= tree_cons (NULL_TREE
, size_tree
, NULL_TREE
);
1580 if (TARGET_MEM_FUNCTIONS
)
1582 arg_list
= tree_cons (NULL_TREE
, src_tree
, arg_list
);
1583 arg_list
= tree_cons (NULL_TREE
, dst_tree
, arg_list
);
1587 arg_list
= tree_cons (NULL_TREE
, dst_tree
, arg_list
);
1588 arg_list
= tree_cons (NULL_TREE
, src_tree
, arg_list
);
1591 /* Now we have to build up the CALL_EXPR itself. */
1592 call_expr
= build1 (ADDR_EXPR
, build_pointer_type (TREE_TYPE (fn
)), fn
);
1593 call_expr
= build (CALL_EXPR
, TREE_TYPE (TREE_TYPE (fn
)),
1594 call_expr
, arg_list
, NULL_TREE
);
1596 retval
= expand_expr (call_expr
, NULL_RTX
, VOIDmode
, 0);
1598 /* If we are initializing a readonly value, show the above call clobbered
1599 it. Otherwise, a load from it may erroneously be hoisted from a loop, or
1600 the delay slot scheduler might overlook conflicts and take nasty
1602 if (RTX_UNCHANGING_P (dst
))
1603 add_function_usage_to
1604 (last_call_insn (), gen_rtx_EXPR_LIST (VOIDmode
,
1605 gen_rtx_CLOBBER (VOIDmode
, dst
),
1608 return TARGET_MEM_FUNCTIONS
? retval
: NULL_RTX
;
1611 /* A subroutine of emit_block_move_via_libcall. Create the tree node
1612 for the function we use for block copies. The first time FOR_CALL
1613 is true, we call assemble_external. */
1615 static GTY(()) tree block_move_fn
;
1618 init_block_move_fn (const char *asmspec
)
1624 if (TARGET_MEM_FUNCTIONS
)
1626 fn
= get_identifier ("memcpy");
1627 args
= build_function_type_list (ptr_type_node
, ptr_type_node
,
1628 const_ptr_type_node
, sizetype
,
1633 fn
= get_identifier ("bcopy");
1634 args
= build_function_type_list (void_type_node
, const_ptr_type_node
,
1635 ptr_type_node
, unsigned_type_node
,
1639 fn
= build_decl (FUNCTION_DECL
, fn
, args
);
1640 DECL_EXTERNAL (fn
) = 1;
1641 TREE_PUBLIC (fn
) = 1;
1642 DECL_ARTIFICIAL (fn
) = 1;
1643 TREE_NOTHROW (fn
) = 1;
1650 SET_DECL_RTL (block_move_fn
, NULL_RTX
);
1651 SET_DECL_ASSEMBLER_NAME (block_move_fn
, get_identifier (asmspec
));
1656 emit_block_move_libcall_fn (int for_call
)
1658 static bool emitted_extern
;
1661 init_block_move_fn (NULL
);
1663 if (for_call
&& !emitted_extern
)
1665 emitted_extern
= true;
1666 make_decl_rtl (block_move_fn
, NULL
);
1667 assemble_external (block_move_fn
);
1670 return block_move_fn
;
1673 /* A subroutine of emit_block_move. Copy the data via an explicit
1674 loop. This is used only when libcalls are forbidden. */
1675 /* ??? It'd be nice to copy in hunks larger than QImode. */
1678 emit_block_move_via_loop (rtx x
, rtx y
, rtx size
,
1679 unsigned int align ATTRIBUTE_UNUSED
)
1681 rtx cmp_label
, top_label
, iter
, x_addr
, y_addr
, tmp
;
1682 enum machine_mode iter_mode
;
1684 iter_mode
= GET_MODE (size
);
1685 if (iter_mode
== VOIDmode
)
1686 iter_mode
= word_mode
;
1688 top_label
= gen_label_rtx ();
1689 cmp_label
= gen_label_rtx ();
1690 iter
= gen_reg_rtx (iter_mode
);
1692 emit_move_insn (iter
, const0_rtx
);
1694 x_addr
= force_operand (XEXP (x
, 0), NULL_RTX
);
1695 y_addr
= force_operand (XEXP (y
, 0), NULL_RTX
);
1696 do_pending_stack_adjust ();
1698 emit_note (NOTE_INSN_LOOP_BEG
);
1700 emit_jump (cmp_label
);
1701 emit_label (top_label
);
1703 tmp
= convert_modes (Pmode
, iter_mode
, iter
, true);
1704 x_addr
= gen_rtx_PLUS (Pmode
, x_addr
, tmp
);
1705 y_addr
= gen_rtx_PLUS (Pmode
, y_addr
, tmp
);
1706 x
= change_address (x
, QImode
, x_addr
);
1707 y
= change_address (y
, QImode
, y_addr
);
1709 emit_move_insn (x
, y
);
1711 tmp
= expand_simple_binop (iter_mode
, PLUS
, iter
, const1_rtx
, iter
,
1712 true, OPTAB_LIB_WIDEN
);
1714 emit_move_insn (iter
, tmp
);
1716 emit_note (NOTE_INSN_LOOP_CONT
);
1717 emit_label (cmp_label
);
1719 emit_cmp_and_jump_insns (iter
, size
, LT
, NULL_RTX
, iter_mode
,
1722 emit_note (NOTE_INSN_LOOP_END
);
1725 /* Copy all or part of a value X into registers starting at REGNO.
1726 The number of registers to be filled is NREGS. */
1729 move_block_to_reg (int regno
, rtx x
, int nregs
, enum machine_mode mode
)
1732 #ifdef HAVE_load_multiple
1740 if (CONSTANT_P (x
) && ! LEGITIMATE_CONSTANT_P (x
))
1741 x
= validize_mem (force_const_mem (mode
, x
));
1743 /* See if the machine can do this with a load multiple insn. */
1744 #ifdef HAVE_load_multiple
1745 if (HAVE_load_multiple
)
1747 last
= get_last_insn ();
1748 pat
= gen_load_multiple (gen_rtx_REG (word_mode
, regno
), x
,
1756 delete_insns_since (last
);
1760 for (i
= 0; i
< nregs
; i
++)
1761 emit_move_insn (gen_rtx_REG (word_mode
, regno
+ i
),
1762 operand_subword_force (x
, i
, mode
));
1765 /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
1766 The number of registers to be filled is NREGS. */
1769 move_block_from_reg (int regno
, rtx x
, int nregs
)
1776 /* See if the machine can do this with a store multiple insn. */
1777 #ifdef HAVE_store_multiple
1778 if (HAVE_store_multiple
)
1780 rtx last
= get_last_insn ();
1781 rtx pat
= gen_store_multiple (x
, gen_rtx_REG (word_mode
, regno
),
1789 delete_insns_since (last
);
1793 for (i
= 0; i
< nregs
; i
++)
1795 rtx tem
= operand_subword (x
, i
, 1, BLKmode
);
1800 emit_move_insn (tem
, gen_rtx_REG (word_mode
, regno
+ i
));
1804 /* Generate a PARALLEL rtx for a new non-consecutive group of registers from
1805 ORIG, where ORIG is a non-consecutive group of registers represented by
1806 a PARALLEL. The clone is identical to the original except in that the
1807 original set of registers is replaced by a new set of pseudo registers.
1808 The new set has the same modes as the original set. */
1811 gen_group_rtx (rtx orig
)
1816 if (GET_CODE (orig
) != PARALLEL
)
1819 length
= XVECLEN (orig
, 0);
1820 tmps
= alloca (sizeof (rtx
) * length
);
1822 /* Skip a NULL entry in first slot. */
1823 i
= XEXP (XVECEXP (orig
, 0, 0), 0) ? 0 : 1;
1828 for (; i
< length
; i
++)
1830 enum machine_mode mode
= GET_MODE (XEXP (XVECEXP (orig
, 0, i
), 0));
1831 rtx offset
= XEXP (XVECEXP (orig
, 0, i
), 1);
1833 tmps
[i
] = gen_rtx_EXPR_LIST (VOIDmode
, gen_reg_rtx (mode
), offset
);
1836 return gen_rtx_PARALLEL (GET_MODE (orig
), gen_rtvec_v (length
, tmps
));
1839 /* Emit code to move a block ORIG_SRC of type TYPE to a block DST,
1840 where DST is non-consecutive registers represented by a PARALLEL.
1841 SSIZE represents the total size of block ORIG_SRC in bytes, or -1
1845 emit_group_load (rtx dst
, rtx orig_src
, tree type ATTRIBUTE_UNUSED
, int ssize
)
1850 if (GET_CODE (dst
) != PARALLEL
)
1853 /* Check for a NULL entry, used to indicate that the parameter goes
1854 both on the stack and in registers. */
1855 if (XEXP (XVECEXP (dst
, 0, 0), 0))
1860 tmps
= alloca (sizeof (rtx
) * XVECLEN (dst
, 0));
1862 /* Process the pieces. */
1863 for (i
= start
; i
< XVECLEN (dst
, 0); i
++)
1865 enum machine_mode mode
= GET_MODE (XEXP (XVECEXP (dst
, 0, i
), 0));
1866 HOST_WIDE_INT bytepos
= INTVAL (XEXP (XVECEXP (dst
, 0, i
), 1));
1867 unsigned int bytelen
= GET_MODE_SIZE (mode
);
1870 /* Handle trailing fragments that run over the size of the struct. */
1871 if (ssize
>= 0 && bytepos
+ (HOST_WIDE_INT
) bytelen
> ssize
)
1873 /* Arrange to shift the fragment to where it belongs.
1874 extract_bit_field loads to the lsb of the reg. */
1876 #ifdef BLOCK_REG_PADDING
1877 BLOCK_REG_PADDING (GET_MODE (orig_src
), type
, i
== start
)
1878 == (BYTES_BIG_ENDIAN
? upward
: downward
)
1883 shift
= (bytelen
- (ssize
- bytepos
)) * BITS_PER_UNIT
;
1884 bytelen
= ssize
- bytepos
;
1889 /* If we won't be loading directly from memory, protect the real source
1890 from strange tricks we might play; but make sure that the source can
1891 be loaded directly into the destination. */
1893 if (GET_CODE (orig_src
) != MEM
1894 && (!CONSTANT_P (orig_src
)
1895 || (GET_MODE (orig_src
) != mode
1896 && GET_MODE (orig_src
) != VOIDmode
)))
1898 if (GET_MODE (orig_src
) == VOIDmode
)
1899 src
= gen_reg_rtx (mode
);
1901 src
= gen_reg_rtx (GET_MODE (orig_src
));
1903 emit_move_insn (src
, orig_src
);
1906 /* Optimize the access just a bit. */
1907 if (GET_CODE (src
) == MEM
1908 && (! SLOW_UNALIGNED_ACCESS (mode
, MEM_ALIGN (src
))
1909 || MEM_ALIGN (src
) >= GET_MODE_ALIGNMENT (mode
))
1910 && bytepos
* BITS_PER_UNIT
% GET_MODE_ALIGNMENT (mode
) == 0
1911 && bytelen
== GET_MODE_SIZE (mode
))
1913 tmps
[i
] = gen_reg_rtx (mode
);
1914 emit_move_insn (tmps
[i
], adjust_address (src
, mode
, bytepos
));
1916 else if (GET_CODE (src
) == CONCAT
)
1918 unsigned int slen
= GET_MODE_SIZE (GET_MODE (src
));
1919 unsigned int slen0
= GET_MODE_SIZE (GET_MODE (XEXP (src
, 0)));
1921 if ((bytepos
== 0 && bytelen
== slen0
)
1922 || (bytepos
!= 0 && bytepos
+ bytelen
<= slen
))
1924 /* The following assumes that the concatenated objects all
1925 have the same size. In this case, a simple calculation
1926 can be used to determine the object and the bit field
1928 tmps
[i
] = XEXP (src
, bytepos
/ slen0
);
1929 if (! CONSTANT_P (tmps
[i
])
1930 && (GET_CODE (tmps
[i
]) != REG
|| GET_MODE (tmps
[i
]) != mode
))
1931 tmps
[i
] = extract_bit_field (tmps
[i
], bytelen
* BITS_PER_UNIT
,
1932 (bytepos
% slen0
) * BITS_PER_UNIT
,
1933 1, NULL_RTX
, mode
, mode
, ssize
);
1935 else if (bytepos
== 0)
1937 rtx mem
= assign_stack_temp (GET_MODE (src
), slen
, 0);
1938 emit_move_insn (mem
, src
);
1939 tmps
[i
] = adjust_address (mem
, mode
, 0);
1944 /* FIXME: A SIMD parallel will eventually lead to a subreg of a
1945 SIMD register, which is currently broken. While we get GCC
1946 to emit proper RTL for these cases, let's dump to memory. */
1947 else if (VECTOR_MODE_P (GET_MODE (dst
))
1948 && GET_CODE (src
) == REG
)
1950 int slen
= GET_MODE_SIZE (GET_MODE (src
));
1953 mem
= assign_stack_temp (GET_MODE (src
), slen
, 0);
1954 emit_move_insn (mem
, src
);
1955 tmps
[i
] = adjust_address (mem
, mode
, (int) bytepos
);
1957 else if (CONSTANT_P (src
) && GET_MODE (dst
) != BLKmode
1958 && XVECLEN (dst
, 0) > 1)
1959 tmps
[i
] = simplify_gen_subreg (mode
, src
, GET_MODE(dst
), bytepos
);
1960 else if (CONSTANT_P (src
)
1961 || (GET_CODE (src
) == REG
&& GET_MODE (src
) == mode
))
1964 tmps
[i
] = extract_bit_field (src
, bytelen
* BITS_PER_UNIT
,
1965 bytepos
* BITS_PER_UNIT
, 1, NULL_RTX
,
1969 expand_binop (mode
, ashl_optab
, tmps
[i
], GEN_INT (shift
),
1970 tmps
[i
], 0, OPTAB_WIDEN
);
1975 /* Copy the extracted pieces into the proper (probable) hard regs. */
1976 for (i
= start
; i
< XVECLEN (dst
, 0); i
++)
1977 emit_move_insn (XEXP (XVECEXP (dst
, 0, i
), 0), tmps
[i
]);
1980 /* Emit code to move a block SRC to block DST, where SRC and DST are
1981 non-consecutive groups of registers, each represented by a PARALLEL. */
1984 emit_group_move (rtx dst
, rtx src
)
1988 if (GET_CODE (src
) != PARALLEL
1989 || GET_CODE (dst
) != PARALLEL
1990 || XVECLEN (src
, 0) != XVECLEN (dst
, 0))
1993 /* Skip first entry if NULL. */
1994 for (i
= XEXP (XVECEXP (src
, 0, 0), 0) ? 0 : 1; i
< XVECLEN (src
, 0); i
++)
1995 emit_move_insn (XEXP (XVECEXP (dst
, 0, i
), 0),
1996 XEXP (XVECEXP (src
, 0, i
), 0));
1999 /* Emit code to move a block SRC to a block ORIG_DST of type TYPE,
2000 where SRC is non-consecutive registers represented by a PARALLEL.
2001 SSIZE represents the total size of block ORIG_DST, or -1 if not
2005 emit_group_store (rtx orig_dst
, rtx src
, tree type ATTRIBUTE_UNUSED
, int ssize
)
2010 if (GET_CODE (src
) != PARALLEL
)
2013 /* Check for a NULL entry, used to indicate that the parameter goes
2014 both on the stack and in registers. */
2015 if (XEXP (XVECEXP (src
, 0, 0), 0))
2020 tmps
= alloca (sizeof (rtx
) * XVECLEN (src
, 0));
2022 /* Copy the (probable) hard regs into pseudos. */
2023 for (i
= start
; i
< XVECLEN (src
, 0); i
++)
2025 rtx reg
= XEXP (XVECEXP (src
, 0, i
), 0);
2026 tmps
[i
] = gen_reg_rtx (GET_MODE (reg
));
2027 emit_move_insn (tmps
[i
], reg
);
2031 /* If we won't be storing directly into memory, protect the real destination
2032 from strange tricks we might play. */
2034 if (GET_CODE (dst
) == PARALLEL
)
2038 /* We can get a PARALLEL dst if there is a conditional expression in
2039 a return statement. In that case, the dst and src are the same,
2040 so no action is necessary. */
2041 if (rtx_equal_p (dst
, src
))
2044 /* It is unclear if we can ever reach here, but we may as well handle
2045 it. Allocate a temporary, and split this into a store/load to/from
2048 temp
= assign_stack_temp (GET_MODE (dst
), ssize
, 0);
2049 emit_group_store (temp
, src
, type
, ssize
);
2050 emit_group_load (dst
, temp
, type
, ssize
);
2053 else if (GET_CODE (dst
) != MEM
&& GET_CODE (dst
) != CONCAT
)
2055 dst
= gen_reg_rtx (GET_MODE (orig_dst
));
2056 /* Make life a bit easier for combine. */
2057 emit_move_insn (dst
, CONST0_RTX (GET_MODE (orig_dst
)));
2060 /* Process the pieces. */
2061 for (i
= start
; i
< XVECLEN (src
, 0); i
++)
2063 HOST_WIDE_INT bytepos
= INTVAL (XEXP (XVECEXP (src
, 0, i
), 1));
2064 enum machine_mode mode
= GET_MODE (tmps
[i
]);
2065 unsigned int bytelen
= GET_MODE_SIZE (mode
);
2068 /* Handle trailing fragments that run over the size of the struct. */
2069 if (ssize
>= 0 && bytepos
+ (HOST_WIDE_INT
) bytelen
> ssize
)
2071 /* store_bit_field always takes its value from the lsb.
2072 Move the fragment to the lsb if it's not already there. */
2074 #ifdef BLOCK_REG_PADDING
2075 BLOCK_REG_PADDING (GET_MODE (orig_dst
), type
, i
== start
)
2076 == (BYTES_BIG_ENDIAN
? upward
: downward
)
2082 int shift
= (bytelen
- (ssize
- bytepos
)) * BITS_PER_UNIT
;
2083 expand_binop (mode
, ashr_optab
, tmps
[i
], GEN_INT (shift
),
2084 tmps
[i
], 0, OPTAB_WIDEN
);
2086 bytelen
= ssize
- bytepos
;
2089 if (GET_CODE (dst
) == CONCAT
)
2091 if (bytepos
+ bytelen
<= GET_MODE_SIZE (GET_MODE (XEXP (dst
, 0))))
2092 dest
= XEXP (dst
, 0);
2093 else if (bytepos
>= GET_MODE_SIZE (GET_MODE (XEXP (dst
, 0))))
2095 bytepos
-= GET_MODE_SIZE (GET_MODE (XEXP (dst
, 0)));
2096 dest
= XEXP (dst
, 1);
2098 else if (bytepos
== 0 && XVECLEN (src
, 0))
2100 dest
= assign_stack_temp (GET_MODE (dest
),
2101 GET_MODE_SIZE (GET_MODE (dest
)), 0);
2102 emit_move_insn (adjust_address (dest
, GET_MODE (tmps
[i
]), bytepos
),
2111 /* Optimize the access just a bit. */
2112 if (GET_CODE (dest
) == MEM
2113 && (! SLOW_UNALIGNED_ACCESS (mode
, MEM_ALIGN (dest
))
2114 || MEM_ALIGN (dest
) >= GET_MODE_ALIGNMENT (mode
))
2115 && bytepos
* BITS_PER_UNIT
% GET_MODE_ALIGNMENT (mode
) == 0
2116 && bytelen
== GET_MODE_SIZE (mode
))
2117 emit_move_insn (adjust_address (dest
, mode
, bytepos
), tmps
[i
]);
2119 store_bit_field (dest
, bytelen
* BITS_PER_UNIT
, bytepos
* BITS_PER_UNIT
,
2120 mode
, tmps
[i
], ssize
);
2125 /* Copy from the pseudo into the (probable) hard reg. */
2126 if (orig_dst
!= dst
)
2127 emit_move_insn (orig_dst
, dst
);
2130 /* Generate code to copy a BLKmode object of TYPE out of a
2131 set of registers starting with SRCREG into TGTBLK. If TGTBLK
2132 is null, a stack temporary is created. TGTBLK is returned.
2134 The purpose of this routine is to handle functions that return
2135 BLKmode structures in registers. Some machines (the PA for example)
2136 want to return all small structures in registers regardless of the
2137 structure's alignment. */
2140 copy_blkmode_from_reg (rtx tgtblk
, rtx srcreg
, tree type
)
2142 unsigned HOST_WIDE_INT bytes
= int_size_in_bytes (type
);
2143 rtx src
= NULL
, dst
= NULL
;
2144 unsigned HOST_WIDE_INT bitsize
= MIN (TYPE_ALIGN (type
), BITS_PER_WORD
);
2145 unsigned HOST_WIDE_INT bitpos
, xbitpos
, padding_correction
= 0;
2149 tgtblk
= assign_temp (build_qualified_type (type
,
2151 | TYPE_QUAL_CONST
)),
2153 preserve_temp_slots (tgtblk
);
2156 /* This code assumes srcreg is at least a full word. If it isn't, copy it
2157 into a new pseudo which is a full word. */
2159 if (GET_MODE (srcreg
) != BLKmode
2160 && GET_MODE_SIZE (GET_MODE (srcreg
)) < UNITS_PER_WORD
)
2161 srcreg
= convert_to_mode (word_mode
, srcreg
, TREE_UNSIGNED (type
));
2163 /* If the structure doesn't take up a whole number of words, see whether
2164 SRCREG is padded on the left or on the right. If it's on the left,
2165 set PADDING_CORRECTION to the number of bits to skip.
2167 In most ABIs, the structure will be returned at the least end of
2168 the register, which translates to right padding on little-endian
2169 targets and left padding on big-endian targets. The opposite
2170 holds if the structure is returned at the most significant
2171 end of the register. */
2172 if (bytes
% UNITS_PER_WORD
!= 0
2173 && (targetm
.calls
.return_in_msb (type
)
2175 : BYTES_BIG_ENDIAN
))
2177 = (BITS_PER_WORD
- ((bytes
% UNITS_PER_WORD
) * BITS_PER_UNIT
));
2179 /* Copy the structure BITSIZE bites at a time.
2181 We could probably emit more efficient code for machines which do not use
2182 strict alignment, but it doesn't seem worth the effort at the current
2184 for (bitpos
= 0, xbitpos
= padding_correction
;
2185 bitpos
< bytes
* BITS_PER_UNIT
;
2186 bitpos
+= bitsize
, xbitpos
+= bitsize
)
2188 /* We need a new source operand each time xbitpos is on a
2189 word boundary and when xbitpos == padding_correction
2190 (the first time through). */
2191 if (xbitpos
% BITS_PER_WORD
== 0
2192 || xbitpos
== padding_correction
)
2193 src
= operand_subword_force (srcreg
, xbitpos
/ BITS_PER_WORD
,
2196 /* We need a new destination operand each time bitpos is on
2198 if (bitpos
% BITS_PER_WORD
== 0)
2199 dst
= operand_subword (tgtblk
, bitpos
/ BITS_PER_WORD
, 1, BLKmode
);
2201 /* Use xbitpos for the source extraction (right justified) and
2202 xbitpos for the destination store (left justified). */
2203 store_bit_field (dst
, bitsize
, bitpos
% BITS_PER_WORD
, word_mode
,
2204 extract_bit_field (src
, bitsize
,
2205 xbitpos
% BITS_PER_WORD
, 1,
2206 NULL_RTX
, word_mode
, word_mode
,
2214 /* Add a USE expression for REG to the (possibly empty) list pointed
2215 to by CALL_FUSAGE. REG must denote a hard register. */
2218 use_reg (rtx
*call_fusage
, rtx reg
)
2220 if (GET_CODE (reg
) != REG
2221 || REGNO (reg
) >= FIRST_PSEUDO_REGISTER
)
2225 = gen_rtx_EXPR_LIST (VOIDmode
,
2226 gen_rtx_USE (VOIDmode
, reg
), *call_fusage
);
2229 /* Add USE expressions to *CALL_FUSAGE for each of NREGS consecutive regs,
2230 starting at REGNO. All of these registers must be hard registers. */
2233 use_regs (rtx
*call_fusage
, int regno
, int nregs
)
2237 if (regno
+ nregs
> FIRST_PSEUDO_REGISTER
)
2240 for (i
= 0; i
< nregs
; i
++)
2241 use_reg (call_fusage
, regno_reg_rtx
[regno
+ i
]);
2244 /* Add USE expressions to *CALL_FUSAGE for each REG contained in the
2245 PARALLEL REGS. This is for calls that pass values in multiple
2246 non-contiguous locations. The Irix 6 ABI has examples of this. */
2249 use_group_regs (rtx
*call_fusage
, rtx regs
)
2253 for (i
= 0; i
< XVECLEN (regs
, 0); i
++)
2255 rtx reg
= XEXP (XVECEXP (regs
, 0, i
), 0);
2257 /* A NULL entry means the parameter goes both on the stack and in
2258 registers. This can also be a MEM for targets that pass values
2259 partially on the stack and partially in registers. */
2260 if (reg
!= 0 && GET_CODE (reg
) == REG
)
2261 use_reg (call_fusage
, reg
);
2266 /* Determine whether the LEN bytes generated by CONSTFUN can be
2267 stored to memory using several move instructions. CONSTFUNDATA is
2268 a pointer which will be passed as argument in every CONSTFUN call.
2269 ALIGN is maximum alignment we can assume. Return nonzero if a
2270 call to store_by_pieces should succeed. */
2273 can_store_by_pieces (unsigned HOST_WIDE_INT len
,
2274 rtx (*constfun
) (void *, HOST_WIDE_INT
, enum machine_mode
),
2275 void *constfundata
, unsigned int align
)
2277 unsigned HOST_WIDE_INT max_size
, l
;
2278 HOST_WIDE_INT offset
= 0;
2279 enum machine_mode mode
, tmode
;
2280 enum insn_code icode
;
2287 if (! STORE_BY_PIECES_P (len
, align
))
2290 if (! SLOW_UNALIGNED_ACCESS (word_mode
, align
)
2291 || align
> MOVE_MAX
* BITS_PER_UNIT
|| align
>= BIGGEST_ALIGNMENT
)
2292 align
= MOVE_MAX
* BITS_PER_UNIT
;
2294 /* We would first store what we can in the largest integer mode, then go to
2295 successively smaller modes. */
2298 reverse
<= (HAVE_PRE_DECREMENT
|| HAVE_POST_DECREMENT
);
2303 max_size
= STORE_MAX_PIECES
+ 1;
2304 while (max_size
> 1)
2306 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
2307 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
2308 if (GET_MODE_SIZE (tmode
) < max_size
)
2311 if (mode
== VOIDmode
)
2314 icode
= mov_optab
->handlers
[(int) mode
].insn_code
;
2315 if (icode
!= CODE_FOR_nothing
2316 && align
>= GET_MODE_ALIGNMENT (mode
))
2318 unsigned int size
= GET_MODE_SIZE (mode
);
2325 cst
= (*constfun
) (constfundata
, offset
, mode
);
2326 if (!LEGITIMATE_CONSTANT_P (cst
))
2336 max_size
= GET_MODE_SIZE (mode
);
2339 /* The code above should have handled everything. */
2347 /* Generate several move instructions to store LEN bytes generated by
2348 CONSTFUN to block TO. (A MEM rtx with BLKmode). CONSTFUNDATA is a
2349 pointer which will be passed as argument in every CONSTFUN call.
2350 ALIGN is maximum alignment we can assume.
2351 If ENDP is 0 return to, if ENDP is 1 return memory at the end ala
2352 mempcpy, and if ENDP is 2 return memory the end minus one byte ala
2356 store_by_pieces (rtx to
, unsigned HOST_WIDE_INT len
,
2357 rtx (*constfun
) (void *, HOST_WIDE_INT
, enum machine_mode
),
2358 void *constfundata
, unsigned int align
, int endp
)
2360 struct store_by_pieces data
;
2369 if (! STORE_BY_PIECES_P (len
, align
))
2371 to
= protect_from_queue (to
, 1);
2372 data
.constfun
= constfun
;
2373 data
.constfundata
= constfundata
;
2376 store_by_pieces_1 (&data
, align
);
2387 if (HAVE_POST_INCREMENT
&& data
.explicit_inc_to
> 0)
2388 emit_insn (gen_add2_insn (data
.to_addr
, constm1_rtx
));
2390 data
.to_addr
= copy_addr_to_reg (plus_constant (data
.to_addr
,
2393 to1
= adjust_automodify_address (data
.to
, QImode
, data
.to_addr
,
2400 to1
= adjust_address (data
.to
, QImode
, data
.offset
);
2408 /* Generate several move instructions to clear LEN bytes of block TO. (A MEM
2409 rtx with BLKmode). The caller must pass TO through protect_from_queue
2410 before calling. ALIGN is maximum alignment we can assume. */
2413 clear_by_pieces (rtx to
, unsigned HOST_WIDE_INT len
, unsigned int align
)
2415 struct store_by_pieces data
;
2420 data
.constfun
= clear_by_pieces_1
;
2421 data
.constfundata
= NULL
;
2424 store_by_pieces_1 (&data
, align
);
2427 /* Callback routine for clear_by_pieces.
2428 Return const0_rtx unconditionally. */
2431 clear_by_pieces_1 (void *data ATTRIBUTE_UNUSED
,
2432 HOST_WIDE_INT offset ATTRIBUTE_UNUSED
,
2433 enum machine_mode mode ATTRIBUTE_UNUSED
)
2438 /* Subroutine of clear_by_pieces and store_by_pieces.
2439 Generate several move instructions to store LEN bytes of block TO. (A MEM
2440 rtx with BLKmode). The caller must pass TO through protect_from_queue
2441 before calling. ALIGN is maximum alignment we can assume. */
2444 store_by_pieces_1 (struct store_by_pieces
*data ATTRIBUTE_UNUSED
,
2445 unsigned int align ATTRIBUTE_UNUSED
)
2447 rtx to_addr
= XEXP (data
->to
, 0);
2448 unsigned HOST_WIDE_INT max_size
= STORE_MAX_PIECES
+ 1;
2449 enum machine_mode mode
= VOIDmode
, tmode
;
2450 enum insn_code icode
;
2453 data
->to_addr
= to_addr
;
2455 = (GET_CODE (to_addr
) == PRE_INC
|| GET_CODE (to_addr
) == PRE_DEC
2456 || GET_CODE (to_addr
) == POST_INC
|| GET_CODE (to_addr
) == POST_DEC
);
2458 data
->explicit_inc_to
= 0;
2460 = (GET_CODE (to_addr
) == PRE_DEC
|| GET_CODE (to_addr
) == POST_DEC
);
2462 data
->offset
= data
->len
;
2464 /* If storing requires more than two move insns,
2465 copy addresses to registers (to make displacements shorter)
2466 and use post-increment if available. */
2467 if (!data
->autinc_to
2468 && move_by_pieces_ninsns (data
->len
, align
) > 2)
2470 /* Determine the main mode we'll be using. */
2471 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
2472 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
2473 if (GET_MODE_SIZE (tmode
) < max_size
)
2476 if (USE_STORE_PRE_DECREMENT (mode
) && data
->reverse
&& ! data
->autinc_to
)
2478 data
->to_addr
= copy_addr_to_reg (plus_constant (to_addr
, data
->len
));
2479 data
->autinc_to
= 1;
2480 data
->explicit_inc_to
= -1;
2483 if (USE_STORE_POST_INCREMENT (mode
) && ! data
->reverse
2484 && ! data
->autinc_to
)
2486 data
->to_addr
= copy_addr_to_reg (to_addr
);
2487 data
->autinc_to
= 1;
2488 data
->explicit_inc_to
= 1;
2491 if ( !data
->autinc_to
&& CONSTANT_P (to_addr
))
2492 data
->to_addr
= copy_addr_to_reg (to_addr
);
2495 if (! SLOW_UNALIGNED_ACCESS (word_mode
, align
)
2496 || align
> MOVE_MAX
* BITS_PER_UNIT
|| align
>= BIGGEST_ALIGNMENT
)
2497 align
= MOVE_MAX
* BITS_PER_UNIT
;
2499 /* First store what we can in the largest integer mode, then go to
2500 successively smaller modes. */
2502 while (max_size
> 1)
2504 for (tmode
= GET_CLASS_NARROWEST_MODE (MODE_INT
);
2505 tmode
!= VOIDmode
; tmode
= GET_MODE_WIDER_MODE (tmode
))
2506 if (GET_MODE_SIZE (tmode
) < max_size
)
2509 if (mode
== VOIDmode
)
2512 icode
= mov_optab
->handlers
[(int) mode
].insn_code
;
2513 if (icode
!= CODE_FOR_nothing
&& align
>= GET_MODE_ALIGNMENT (mode
))
2514 store_by_pieces_2 (GEN_FCN (icode
), mode
, data
);
2516 max_size
= GET_MODE_SIZE (mode
);
2519 /* The code above should have handled everything. */
2524 /* Subroutine of store_by_pieces_1. Store as many bytes as appropriate
2525 with move instructions for mode MODE. GENFUN is the gen_... function
2526 to make a move insn for that mode. DATA has all the other info. */
2529 store_by_pieces_2 (rtx (*genfun
) (rtx
, ...), enum machine_mode mode
,
2530 struct store_by_pieces
*data
)
2532 unsigned int size
= GET_MODE_SIZE (mode
);
2535 while (data
->len
>= size
)
2538 data
->offset
-= size
;
2540 if (data
->autinc_to
)
2541 to1
= adjust_automodify_address (data
->to
, mode
, data
->to_addr
,
2544 to1
= adjust_address (data
->to
, mode
, data
->offset
);
2546 if (HAVE_PRE_DECREMENT
&& data
->explicit_inc_to
< 0)
2547 emit_insn (gen_add2_insn (data
->to_addr
,
2548 GEN_INT (-(HOST_WIDE_INT
) size
)));
2550 cst
= (*data
->constfun
) (data
->constfundata
, data
->offset
, mode
);
2551 emit_insn ((*genfun
) (to1
, cst
));
2553 if (HAVE_POST_INCREMENT
&& data
->explicit_inc_to
> 0)
2554 emit_insn (gen_add2_insn (data
->to_addr
, GEN_INT (size
)));
2556 if (! data
->reverse
)
2557 data
->offset
+= size
;
2563 /* Write zeros through the storage of OBJECT. If OBJECT has BLKmode, SIZE is
2564 its length in bytes. */
2567 clear_storage (rtx object
, rtx size
)
2570 unsigned int align
= (GET_CODE (object
) == MEM
? MEM_ALIGN (object
)
2571 : GET_MODE_ALIGNMENT (GET_MODE (object
)));
2573 /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
2574 just move a zero. Otherwise, do this a piece at a time. */
2575 if (GET_MODE (object
) != BLKmode
2576 && GET_CODE (size
) == CONST_INT
2577 && INTVAL (size
) == (HOST_WIDE_INT
) GET_MODE_SIZE (GET_MODE (object
)))
2578 emit_move_insn (object
, CONST0_RTX (GET_MODE (object
)));
2581 object
= protect_from_queue (object
, 1);
2582 size
= protect_from_queue (size
, 0);
2584 if (size
== const0_rtx
)
2586 else if (GET_CODE (size
) == CONST_INT
2587 && CLEAR_BY_PIECES_P (INTVAL (size
), align
))
2588 clear_by_pieces (object
, INTVAL (size
), align
);
2589 else if (clear_storage_via_clrstr (object
, size
, align
))
2592 retval
= clear_storage_via_libcall (object
, size
);
2598 /* A subroutine of clear_storage. Expand a clrstr pattern;
2599 return true if successful. */
2602 clear_storage_via_clrstr (rtx object
, rtx size
, unsigned int align
)
2604 /* Try the most limited insn first, because there's no point
2605 including more than one in the machine description unless
2606 the more limited one has some advantage. */
2608 rtx opalign
= GEN_INT (align
/ BITS_PER_UNIT
);
2609 enum machine_mode mode
;
2611 for (mode
= GET_CLASS_NARROWEST_MODE (MODE_INT
); mode
!= VOIDmode
;
2612 mode
= GET_MODE_WIDER_MODE (mode
))
2614 enum insn_code code
= clrstr_optab
[(int) mode
];
2615 insn_operand_predicate_fn pred
;
2617 if (code
!= CODE_FOR_nothing
2618 /* We don't need MODE to be narrower than
2619 BITS_PER_HOST_WIDE_INT here because if SIZE is less than
2620 the mode mask, as it is returned by the macro, it will
2621 definitely be less than the actual mode mask. */
2622 && ((GET_CODE (size
) == CONST_INT
2623 && ((unsigned HOST_WIDE_INT
) INTVAL (size
)
2624 <= (GET_MODE_MASK (mode
) >> 1)))
2625 || GET_MODE_BITSIZE (mode
) >= BITS_PER_WORD
)
2626 && ((pred
= insn_data
[(int) code
].operand
[0].predicate
) == 0
2627 || (*pred
) (object
, BLKmode
))
2628 && ((pred
= insn_data
[(int) code
].operand
[2].predicate
) == 0
2629 || (*pred
) (opalign
, VOIDmode
)))
2632 rtx last
= get_last_insn ();
2635 op1
= convert_to_mode (mode
, size
, 1);
2636 pred
= insn_data
[(int) code
].operand
[1].predicate
;
2637 if (pred
!= 0 && ! (*pred
) (op1
, mode
))
2638 op1
= copy_to_mode_reg (mode
, op1
);
2640 pat
= GEN_FCN ((int) code
) (object
, op1
, opalign
);
2647 delete_insns_since (last
);
2654 /* A subroutine of clear_storage. Expand a call to memset or bzero.
2655 Return the return value of memset, 0 otherwise. */
2658 clear_storage_via_libcall (rtx object
, rtx size
)
2660 tree call_expr
, arg_list
, fn
, object_tree
, size_tree
;
2661 enum machine_mode size_mode
;
2664 /* OBJECT or SIZE may have been passed through protect_from_queue.
2666 It is unsafe to save the value generated by protect_from_queue
2667 and reuse it later. Consider what happens if emit_queue is
2668 called before the return value from protect_from_queue is used.
2670 Expansion of the CALL_EXPR below will call emit_queue before
2671 we are finished emitting RTL for argument setup. So if we are
2672 not careful we could get the wrong value for an argument.
2674 To avoid this problem we go ahead and emit code to copy OBJECT
2675 and SIZE into new pseudos. We can then place those new pseudos
2676 into an RTL_EXPR and use them later, even after a call to
2679 Note this is not strictly needed for library calls since they
2680 do not call emit_queue before loading their arguments. However,
2681 we may need to have library calls call emit_queue in the future
2682 since failing to do so could cause problems for targets which
2683 define SMALL_REGISTER_CLASSES and pass arguments in registers. */
2685 object
= copy_to_mode_reg (Pmode
, XEXP (object
, 0));
2687 if (TARGET_MEM_FUNCTIONS
)
2688 size_mode
= TYPE_MODE (sizetype
);
2690 size_mode
= TYPE_MODE (unsigned_type_node
);
2691 size
= convert_to_mode (size_mode
, size
, 1);
2692 size
= copy_to_mode_reg (size_mode
, size
);
2694 /* It is incorrect to use the libcall calling conventions to call
2695 memset in this context. This could be a user call to memset and
2696 the user may wish to examine the return value from memset. For
2697 targets where libcalls and normal calls have different conventions
2698 for returning pointers, we could end up generating incorrect code.
2700 For convenience, we generate the call to bzero this way as well. */
2702 object_tree
= make_tree (ptr_type_node
, object
);
2703 if (TARGET_MEM_FUNCTIONS
)
2704 size_tree
= make_tree (sizetype
, size
);
2706 size_tree
= make_tree (unsigned_type_node
, size
);
2708 fn
= clear_storage_libcall_fn (true);
2709 arg_list
= tree_cons (NULL_TREE
, size_tree
, NULL_TREE
);
2710 if (TARGET_MEM_FUNCTIONS
)
2711 arg_list
= tree_cons (NULL_TREE
, integer_zero_node
, arg_list
);
2712 arg_list
= tree_cons (NULL_TREE
, object_tree
, arg_list
);
2714 /* Now we have to build up the CALL_EXPR itself. */
2715 call_expr
= build1 (ADDR_EXPR
, build_pointer_type (TREE_TYPE (fn
)), fn
);
2716 call_expr
= build (CALL_EXPR
, TREE_TYPE (TREE_TYPE (fn
)),
2717 call_expr
, arg_list
, NULL_TREE
);
2719 retval
= expand_expr (call_expr
, NULL_RTX
, VOIDmode
, 0);
2721 /* If we are initializing a readonly value, show the above call
2722 clobbered it. Otherwise, a load from it may erroneously be
2723 hoisted from a loop. */
2724 if (RTX_UNCHANGING_P (object
))
2725 emit_insn (gen_rtx_CLOBBER (VOIDmode
, object
));
2727 return (TARGET_MEM_FUNCTIONS
? retval
: NULL_RTX
);
2730 /* A subroutine of clear_storage_via_libcall. Create the tree node
2731 for the function we use for block clears. The first time FOR_CALL
2732 is true, we call assemble_external. */
2734 static GTY(()) tree block_clear_fn
;
2737 init_block_clear_fn (const char *asmspec
)
2739 if (!block_clear_fn
)
2743 if (TARGET_MEM_FUNCTIONS
)
2745 fn
= get_identifier ("memset");
2746 args
= build_function_type_list (ptr_type_node
, ptr_type_node
,
2747 integer_type_node
, sizetype
,
2752 fn
= get_identifier ("bzero");
2753 args
= build_function_type_list (void_type_node
, ptr_type_node
,
2754 unsigned_type_node
, NULL_TREE
);
2757 fn
= build_decl (FUNCTION_DECL
, fn
, args
);
2758 DECL_EXTERNAL (fn
) = 1;
2759 TREE_PUBLIC (fn
) = 1;
2760 DECL_ARTIFICIAL (fn
) = 1;
2761 TREE_NOTHROW (fn
) = 1;
2763 block_clear_fn
= fn
;
2768 SET_DECL_RTL (block_clear_fn
, NULL_RTX
);
2769 SET_DECL_ASSEMBLER_NAME (block_clear_fn
, get_identifier (asmspec
));
2774 clear_storage_libcall_fn (int for_call
)
2776 static bool emitted_extern
;
2778 if (!block_clear_fn
)
2779 init_block_clear_fn (NULL
);
2781 if (for_call
&& !emitted_extern
)
2783 emitted_extern
= true;
2784 make_decl_rtl (block_clear_fn
, NULL
);
2785 assemble_external (block_clear_fn
);
2788 return block_clear_fn
;
2791 /* Generate code to copy Y into X.
2792 Both Y and X must have the same mode, except that
2793 Y can be a constant with VOIDmode.
2794 This mode cannot be BLKmode; use emit_block_move for that.
2796 Return the last instruction emitted. */
2799 emit_move_insn (rtx x
, rtx y
)
2801 enum machine_mode mode
= GET_MODE (x
);
2802 rtx y_cst
= NULL_RTX
;
2805 x
= protect_from_queue (x
, 1);
2806 y
= protect_from_queue (y
, 0);
2808 if (mode
== BLKmode
|| (GET_MODE (y
) != mode
&& GET_MODE (y
) != VOIDmode
))
2811 /* Never force constant_p_rtx to memory. */
2812 if (GET_CODE (y
) == CONSTANT_P_RTX
)
2814 else if (CONSTANT_P (y
))
2817 && SCALAR_FLOAT_MODE_P (GET_MODE (x
))
2818 && (last_insn
= compress_float_constant (x
, y
)))
2823 if (!LEGITIMATE_CONSTANT_P (y
))
2825 y
= force_const_mem (mode
, y
);
2827 /* If the target's cannot_force_const_mem prevented the spill,
2828 assume that the target's move expanders will also take care
2829 of the non-legitimate constant. */
2835 /* If X or Y are memory references, verify that their addresses are valid
2837 if (GET_CODE (x
) == MEM
2838 && ((! memory_address_p (GET_MODE (x
), XEXP (x
, 0))
2839 && ! push_operand (x
, GET_MODE (x
)))
2841 && CONSTANT_ADDRESS_P (XEXP (x
, 0)))))
2842 x
= validize_mem (x
);
2844 if (GET_CODE (y
) == MEM
2845 && (! memory_address_p (GET_MODE (y
), XEXP (y
, 0))
2847 && CONSTANT_ADDRESS_P (XEXP (y
, 0)))))
2848 y
= validize_mem (y
);
2850 if (mode
== BLKmode
)
2853 last_insn
= emit_move_insn_1 (x
, y
);
2855 if (y_cst
&& GET_CODE (x
) == REG
2856 && (set
= single_set (last_insn
)) != NULL_RTX
2857 && SET_DEST (set
) == x
2858 && ! rtx_equal_p (y_cst
, SET_SRC (set
)))
2859 set_unique_reg_note (last_insn
, REG_EQUAL
, y_cst
);
2864 /* Low level part of emit_move_insn.
2865 Called just like emit_move_insn, but assumes X and Y
2866 are basically valid. */
2869 emit_move_insn_1 (rtx x
, rtx y
)
2871 enum machine_mode mode
= GET_MODE (x
);
2872 enum machine_mode submode
;
2873 enum mode_class
class = GET_MODE_CLASS (mode
);
2875 if ((unsigned int) mode
>= (unsigned int) MAX_MACHINE_MODE
)
2878 if (mov_optab
->handlers
[(int) mode
].insn_code
!= CODE_FOR_nothing
)
2880 emit_insn (GEN_FCN (mov_optab
->handlers
[(int) mode
].insn_code
) (x
, y
));
2882 /* Expand complex moves by moving real part and imag part, if possible. */
2883 else if ((class == MODE_COMPLEX_FLOAT
|| class == MODE_COMPLEX_INT
)
2884 && BLKmode
!= (submode
= GET_MODE_INNER (mode
))
2885 && (mov_optab
->handlers
[(int) submode
].insn_code
2886 != CODE_FOR_nothing
))
2888 /* Don't split destination if it is a stack push. */
2889 int stack
= push_operand (x
, GET_MODE (x
));
2891 #ifdef PUSH_ROUNDING
2892 /* In case we output to the stack, but the size is smaller than the
2893 machine can push exactly, we need to use move instructions. */
2895 && (PUSH_ROUNDING (GET_MODE_SIZE (submode
))
2896 != GET_MODE_SIZE (submode
)))
2899 HOST_WIDE_INT offset1
, offset2
;
2901 /* Do not use anti_adjust_stack, since we don't want to update
2902 stack_pointer_delta. */
2903 temp
= expand_binop (Pmode
,
2904 #ifdef STACK_GROWS_DOWNWARD
2912 (GET_MODE_SIZE (GET_MODE (x
)))),
2913 stack_pointer_rtx
, 0, OPTAB_LIB_WIDEN
);
2915 if (temp
!= stack_pointer_rtx
)
2916 emit_move_insn (stack_pointer_rtx
, temp
);
2918 #ifdef STACK_GROWS_DOWNWARD
2920 offset2
= GET_MODE_SIZE (submode
);
2922 offset1
= -PUSH_ROUNDING (GET_MODE_SIZE (GET_MODE (x
)));
2923 offset2
= (-PUSH_ROUNDING (GET_MODE_SIZE (GET_MODE (x
)))
2924 + GET_MODE_SIZE (submode
));
2927 emit_move_insn (change_address (x
, submode
,
2928 gen_rtx_PLUS (Pmode
,
2930 GEN_INT (offset1
))),
2931 gen_realpart (submode
, y
));
2932 emit_move_insn (change_address (x
, submode
,
2933 gen_rtx_PLUS (Pmode
,
2935 GEN_INT (offset2
))),
2936 gen_imagpart (submode
, y
));
2940 /* If this is a stack, push the highpart first, so it
2941 will be in the argument order.
2943 In that case, change_address is used only to convert
2944 the mode, not to change the address. */
2947 /* Note that the real part always precedes the imag part in memory
2948 regardless of machine's endianness. */
2949 #ifdef STACK_GROWS_DOWNWARD
2950 emit_move_insn (gen_rtx_MEM (submode
, XEXP (x
, 0)),
2951 gen_imagpart (submode
, y
));
2952 emit_move_insn (gen_rtx_MEM (submode
, XEXP (x
, 0)),
2953 gen_realpart (submode
, y
));
2955 emit_move_insn (gen_rtx_MEM (submode
, XEXP (x
, 0)),
2956 gen_realpart (submode
, y
));
2957 emit_move_insn (gen_rtx_MEM (submode
, XEXP (x
, 0)),
2958 gen_imagpart (submode
, y
));
2963 rtx realpart_x
, realpart_y
;
2964 rtx imagpart_x
, imagpart_y
;
2966 /* If this is a complex value with each part being smaller than a
2967 word, the usual calling sequence will likely pack the pieces into
2968 a single register. Unfortunately, SUBREG of hard registers only
2969 deals in terms of words, so we have a problem converting input
2970 arguments to the CONCAT of two registers that is used elsewhere
2971 for complex values. If this is before reload, we can copy it into
2972 memory and reload. FIXME, we should see about using extract and
2973 insert on integer registers, but complex short and complex char
2974 variables should be rarely used. */
2975 if (GET_MODE_BITSIZE (mode
) < 2 * BITS_PER_WORD
2976 && (reload_in_progress
| reload_completed
) == 0)
2979 = (REG_P (x
) && REGNO (x
) < FIRST_PSEUDO_REGISTER
);
2981 = (REG_P (y
) && REGNO (y
) < FIRST_PSEUDO_REGISTER
);
2983 if (packed_dest_p
|| packed_src_p
)
2985 enum mode_class reg_class
= ((class == MODE_COMPLEX_FLOAT
)
2986 ? MODE_FLOAT
: MODE_INT
);
2988 enum machine_mode reg_mode
2989 = mode_for_size (GET_MODE_BITSIZE (mode
), reg_class
, 1);
2991 if (reg_mode
!= BLKmode
)
2993 rtx mem
= assign_stack_temp (reg_mode
,
2994 GET_MODE_SIZE (mode
), 0);
2995 rtx cmem
= adjust_address (mem
, mode
, 0);
2998 = N_("function using short complex types cannot be inline");
3002 rtx sreg
= gen_rtx_SUBREG (reg_mode
, x
, 0);
3004 emit_move_insn_1 (cmem
, y
);
3005 return emit_move_insn_1 (sreg
, mem
);
3009 rtx sreg
= gen_rtx_SUBREG (reg_mode
, y
, 0);
3011 emit_move_insn_1 (mem
, sreg
);
3012 return emit_move_insn_1 (x
, cmem
);
3018 realpart_x
= gen_realpart (submode
, x
);
3019 realpart_y
= gen_realpart (submode
, y
);
3020 imagpart_x
= gen_imagpart (submode
, x
);
3021 imagpart_y
= gen_imagpart (submode
, y
);
3023 /* Show the output dies here. This is necessary for SUBREGs
3024 of pseudos since we cannot track their lifetimes correctly;
3025 hard regs shouldn't appear here except as return values.
3026 We never want to emit such a clobber after reload. */
3028 && ! (reload_in_progress
|| reload_completed
)
3029 && (GET_CODE (realpart_x
) == SUBREG
3030 || GET_CODE (imagpart_x
) == SUBREG
))
3031 emit_insn (gen_rtx_CLOBBER (VOIDmode
, x
));
3033 emit_move_insn (realpart_x
, realpart_y
);
3034 emit_move_insn (imagpart_x
, imagpart_y
);
3037 return get_last_insn ();
3040 /* Handle MODE_CC modes: If we don't have a special move insn for this mode,
3041 find a mode to do it in. If we have a movcc, use it. Otherwise,
3042 find the MODE_INT mode of the same width. */
3043 else if (GET_MODE_CLASS (mode
) == MODE_CC
3044 && mov_optab
->handlers
[(int) mode
].insn_code
== CODE_FOR_nothing
)
3046 enum insn_code insn_code
;
3047 enum machine_mode tmode
= VOIDmode
;
3051 && mov_optab
->handlers
[(int) CCmode
].insn_code
!= CODE_FOR_nothing
)
3054 for (tmode
= QImode
; tmode
!= VOIDmode
;
3055 tmode
= GET_MODE_WIDER_MODE (tmode
))
3056 if (GET_MODE_SIZE (tmode
) == GET_MODE_SIZE (mode
))
3059 if (tmode
== VOIDmode
)
3062 /* Get X and Y in TMODE. We can't use gen_lowpart here because it
3063 may call change_address which is not appropriate if we were
3064 called when a reload was in progress. We don't have to worry
3065 about changing the address since the size in bytes is supposed to
3066 be the same. Copy the MEM to change the mode and move any
3067 substitutions from the old MEM to the new one. */
3069 if (reload_in_progress
)
3071 x
= gen_lowpart_common (tmode
, x1
);
3072 if (x
== 0 && GET_CODE (x1
) == MEM
)
3074 x
= adjust_address_nv (x1
, tmode
, 0);
3075 copy_replacements (x1
, x
);
3078 y
= gen_lowpart_common (tmode
, y1
);
3079 if (y
== 0 && GET_CODE (y1
) == MEM
)
3081 y
= adjust_address_nv (y1
, tmode
, 0);
3082 copy_replacements (y1
, y
);
3087 x
= gen_lowpart (tmode
, x
);
3088 y
= gen_lowpart (tmode
, y
);
3091 insn_code
= mov_optab
->handlers
[(int) tmode
].insn_code
;
3092 return emit_insn (GEN_FCN (insn_code
) (x
, y
));
3095 /* Try using a move pattern for the corresponding integer mode. This is
3096 only safe when simplify_subreg can convert MODE constants into integer
3097 constants. At present, it can only do this reliably if the value
3098 fits within a HOST_WIDE_INT. */
3099 else if (GET_MODE_BITSIZE (mode
) <= HOST_BITS_PER_WIDE_INT
3100 && (submode
= int_mode_for_mode (mode
)) != BLKmode
3101 && mov_optab
->handlers
[submode
].insn_code
!= CODE_FOR_nothing
)
3102 return emit_insn (GEN_FCN (mov_optab
->handlers
[submode
].insn_code
)
3103 (simplify_gen_subreg (submode
, x
, mode
, 0),
3104 simplify_gen_subreg (submode
, y
, mode
, 0)));
3106 /* This will handle any multi-word or full-word mode that lacks a move_insn
3107 pattern. However, you will get better code if you define such patterns,
3108 even if they must turn into multiple assembler instructions. */
3109 else if (GET_MODE_SIZE (mode
) >= UNITS_PER_WORD
)
3116 #ifdef PUSH_ROUNDING
3118 /* If X is a push on the stack, do the push now and replace
3119 X with a reference to the stack pointer. */
3120 if (push_operand (x
, GET_MODE (x
)))
3125 /* Do not use anti_adjust_stack, since we don't want to update
3126 stack_pointer_delta. */
3127 temp
= expand_binop (Pmode
,
3128 #ifdef STACK_GROWS_DOWNWARD
3136 (GET_MODE_SIZE (GET_MODE (x
)))),
3137 stack_pointer_rtx
, 0, OPTAB_LIB_WIDEN
);
3139 if (temp
!= stack_pointer_rtx
)
3140 emit_move_insn (stack_pointer_rtx
, temp
);
3142 code
= GET_CODE (XEXP (x
, 0));
3144 /* Just hope that small offsets off SP are OK. */
3145 if (code
== POST_INC
)
3146 temp
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
3147 GEN_INT (-((HOST_WIDE_INT
)
3148 GET_MODE_SIZE (GET_MODE (x
)))));
3149 else if (code
== POST_DEC
)
3150 temp
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
3151 GEN_INT (GET_MODE_SIZE (GET_MODE (x
))));
3153 temp
= stack_pointer_rtx
;
3155 x
= change_address (x
, VOIDmode
, temp
);
3159 /* If we are in reload, see if either operand is a MEM whose address
3160 is scheduled for replacement. */
3161 if (reload_in_progress
&& GET_CODE (x
) == MEM
3162 && (inner
= find_replacement (&XEXP (x
, 0))) != XEXP (x
, 0))
3163 x
= replace_equiv_address_nv (x
, inner
);
3164 if (reload_in_progress
&& GET_CODE (y
) == MEM
3165 && (inner
= find_replacement (&XEXP (y
, 0))) != XEXP (y
, 0))
3166 y
= replace_equiv_address_nv (y
, inner
);
3172 i
< (GET_MODE_SIZE (mode
) + (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
;
3175 rtx xpart
= operand_subword (x
, i
, 1, mode
);
3176 rtx ypart
= operand_subword (y
, i
, 1, mode
);
3178 /* If we can't get a part of Y, put Y into memory if it is a
3179 constant. Otherwise, force it into a register. If we still
3180 can't get a part of Y, abort. */
3181 if (ypart
== 0 && CONSTANT_P (y
))
3183 y
= force_const_mem (mode
, y
);
3184 ypart
= operand_subword (y
, i
, 1, mode
);
3186 else if (ypart
== 0)
3187 ypart
= operand_subword_force (y
, i
, mode
);
3189 if (xpart
== 0 || ypart
== 0)
3192 need_clobber
|= (GET_CODE (xpart
) == SUBREG
);
3194 last_insn
= emit_move_insn (xpart
, ypart
);
3200 /* Show the output dies here. This is necessary for SUBREGs
3201 of pseudos since we cannot track their lifetimes correctly;
3202 hard regs shouldn't appear here except as return values.
3203 We never want to emit such a clobber after reload. */
3205 && ! (reload_in_progress
|| reload_completed
)
3206 && need_clobber
!= 0)
3207 emit_insn (gen_rtx_CLOBBER (VOIDmode
, x
));
3217 /* If Y is representable exactly in a narrower mode, and the target can
3218 perform the extension directly from constant or memory, then emit the
3219 move as an extension. */
3222 compress_float_constant (rtx x
, rtx y
)
3224 enum machine_mode dstmode
= GET_MODE (x
);
3225 enum machine_mode orig_srcmode
= GET_MODE (y
);
3226 enum machine_mode srcmode
;
3229 REAL_VALUE_FROM_CONST_DOUBLE (r
, y
);
3231 for (srcmode
= GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (orig_srcmode
));
3232 srcmode
!= orig_srcmode
;
3233 srcmode
= GET_MODE_WIDER_MODE (srcmode
))
3236 rtx trunc_y
, last_insn
;
3238 /* Skip if the target can't extend this way. */
3239 ic
= can_extend_p (dstmode
, srcmode
, 0);
3240 if (ic
== CODE_FOR_nothing
)
3243 /* Skip if the narrowed value isn't exact. */
3244 if (! exact_real_truncate (srcmode
, &r
))
3247 trunc_y
= CONST_DOUBLE_FROM_REAL_VALUE (r
, srcmode
);
3249 if (LEGITIMATE_CONSTANT_P (trunc_y
))
3251 /* Skip if the target needs extra instructions to perform
3253 if (! (*insn_data
[ic
].operand
[1].predicate
) (trunc_y
, srcmode
))
3256 else if (float_extend_from_mem
[dstmode
][srcmode
])
3257 trunc_y
= validize_mem (force_const_mem (srcmode
, trunc_y
));
3261 emit_unop_insn (ic
, x
, trunc_y
, UNKNOWN
);
3262 last_insn
= get_last_insn ();
3264 if (GET_CODE (x
) == REG
)
3265 set_unique_reg_note (last_insn
, REG_EQUAL
, y
);
3273 /* Pushing data onto the stack. */
3275 /* Push a block of length SIZE (perhaps variable)
3276 and return an rtx to address the beginning of the block.
3277 Note that it is not possible for the value returned to be a QUEUED.
3278 The value may be virtual_outgoing_args_rtx.
3280 EXTRA is the number of bytes of padding to push in addition to SIZE.
3281 BELOW nonzero means this padding comes at low addresses;
3282 otherwise, the padding comes at high addresses. */
3285 push_block (rtx size
, int extra
, int below
)
3289 size
= convert_modes (Pmode
, ptr_mode
, size
, 1);
3290 if (CONSTANT_P (size
))
3291 anti_adjust_stack (plus_constant (size
, extra
));
3292 else if (GET_CODE (size
) == REG
&& extra
== 0)
3293 anti_adjust_stack (size
);
3296 temp
= copy_to_mode_reg (Pmode
, size
);
3298 temp
= expand_binop (Pmode
, add_optab
, temp
, GEN_INT (extra
),
3299 temp
, 0, OPTAB_LIB_WIDEN
);
3300 anti_adjust_stack (temp
);
3303 #ifndef STACK_GROWS_DOWNWARD
3309 temp
= virtual_outgoing_args_rtx
;
3310 if (extra
!= 0 && below
)
3311 temp
= plus_constant (temp
, extra
);
3315 if (GET_CODE (size
) == CONST_INT
)
3316 temp
= plus_constant (virtual_outgoing_args_rtx
,
3317 -INTVAL (size
) - (below
? 0 : extra
));
3318 else if (extra
!= 0 && !below
)
3319 temp
= gen_rtx_PLUS (Pmode
, virtual_outgoing_args_rtx
,
3320 negate_rtx (Pmode
, plus_constant (size
, extra
)));
3322 temp
= gen_rtx_PLUS (Pmode
, virtual_outgoing_args_rtx
,
3323 negate_rtx (Pmode
, size
));
3326 return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT
), temp
);
3329 #ifdef PUSH_ROUNDING
3331 /* Emit single push insn. */
3334 emit_single_push_insn (enum machine_mode mode
, rtx x
, tree type
)
3337 unsigned rounded_size
= PUSH_ROUNDING (GET_MODE_SIZE (mode
));
3339 enum insn_code icode
;
3340 insn_operand_predicate_fn pred
;
3342 stack_pointer_delta
+= PUSH_ROUNDING (GET_MODE_SIZE (mode
));
3343 /* If there is push pattern, use it. Otherwise try old way of throwing
3344 MEM representing push operation to move expander. */
3345 icode
= push_optab
->handlers
[(int) mode
].insn_code
;
3346 if (icode
!= CODE_FOR_nothing
)
3348 if (((pred
= insn_data
[(int) icode
].operand
[0].predicate
)
3349 && !((*pred
) (x
, mode
))))
3350 x
= force_reg (mode
, x
);
3351 emit_insn (GEN_FCN (icode
) (x
));
3354 if (GET_MODE_SIZE (mode
) == rounded_size
)
3355 dest_addr
= gen_rtx_fmt_e (STACK_PUSH_CODE
, Pmode
, stack_pointer_rtx
);
3356 /* If we are to pad downward, adjust the stack pointer first and
3357 then store X into the stack location using an offset. This is
3358 because emit_move_insn does not know how to pad; it does not have
3360 else if (FUNCTION_ARG_PADDING (mode
, type
) == downward
)
3362 unsigned padding_size
= rounded_size
- GET_MODE_SIZE (mode
);
3363 HOST_WIDE_INT offset
;
3365 emit_move_insn (stack_pointer_rtx
,
3366 expand_binop (Pmode
,
3367 #ifdef STACK_GROWS_DOWNWARD
3373 GEN_INT (rounded_size
),
3374 NULL_RTX
, 0, OPTAB_LIB_WIDEN
));
3376 offset
= (HOST_WIDE_INT
) padding_size
;
3377 #ifdef STACK_GROWS_DOWNWARD
3378 if (STACK_PUSH_CODE
== POST_DEC
)
3379 /* We have already decremented the stack pointer, so get the
3381 offset
+= (HOST_WIDE_INT
) rounded_size
;
3383 if (STACK_PUSH_CODE
== POST_INC
)
3384 /* We have already incremented the stack pointer, so get the
3386 offset
-= (HOST_WIDE_INT
) rounded_size
;
3388 dest_addr
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, GEN_INT (offset
));
3392 #ifdef STACK_GROWS_DOWNWARD
3393 /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC. */
3394 dest_addr
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
3395 GEN_INT (-(HOST_WIDE_INT
) rounded_size
));
3397 /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC. */
3398 dest_addr
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
3399 GEN_INT (rounded_size
));
3401 dest_addr
= gen_rtx_PRE_MODIFY (Pmode
, stack_pointer_rtx
, dest_addr
);
3404 dest
= gen_rtx_MEM (mode
, dest_addr
);
3408 set_mem_attributes (dest
, type
, 1);
3410 if (flag_optimize_sibling_calls
)
3411 /* Function incoming arguments may overlap with sibling call
3412 outgoing arguments and we cannot allow reordering of reads
3413 from function arguments with stores to outgoing arguments
3414 of sibling calls. */
3415 set_mem_alias_set (dest
, 0);
3417 emit_move_insn (dest
, x
);
3421 /* Generate code to push X onto the stack, assuming it has mode MODE and
3423 MODE is redundant except when X is a CONST_INT (since they don't
3425 SIZE is an rtx for the size of data to be copied (in bytes),
3426 needed only if X is BLKmode.
3428 ALIGN (in bits) is maximum alignment we can assume.
3430 If PARTIAL and REG are both nonzero, then copy that many of the first
3431 words of X into registers starting with REG, and push the rest of X.
3432 The amount of space pushed is decreased by PARTIAL words,
3433 rounded *down* to a multiple of PARM_BOUNDARY.
3434 REG must be a hard register in this case.
3435 If REG is zero but PARTIAL is not, take any all others actions for an
3436 argument partially in registers, but do not actually load any
3439 EXTRA is the amount in bytes of extra space to leave next to this arg.
3440 This is ignored if an argument block has already been allocated.
3442 On a machine that lacks real push insns, ARGS_ADDR is the address of
3443 the bottom of the argument block for this call. We use indexing off there
3444 to store the arg. On machines with push insns, ARGS_ADDR is 0 when a
3445 argument block has not been preallocated.
3447 ARGS_SO_FAR is the size of args previously pushed for this call.
3449 REG_PARM_STACK_SPACE is nonzero if functions require stack space
3450 for arguments passed in registers. If nonzero, it will be the number
3451 of bytes required. */
3454 emit_push_insn (rtx x
, enum machine_mode mode
, tree type
, rtx size
,
3455 unsigned int align
, int partial
, rtx reg
, int extra
,
3456 rtx args_addr
, rtx args_so_far
, int reg_parm_stack_space
,
3460 enum direction stack_direction
3461 #ifdef STACK_GROWS_DOWNWARD
3467 /* Decide where to pad the argument: `downward' for below,
3468 `upward' for above, or `none' for don't pad it.
3469 Default is below for small data on big-endian machines; else above. */
3470 enum direction where_pad
= FUNCTION_ARG_PADDING (mode
, type
);
3472 /* Invert direction if stack is post-decrement.
3474 if (STACK_PUSH_CODE
== POST_DEC
)
3475 if (where_pad
!= none
)
3476 where_pad
= (where_pad
== downward
? upward
: downward
);
3478 xinner
= x
= protect_from_queue (x
, 0);
3480 if (mode
== BLKmode
)
3482 /* Copy a block into the stack, entirely or partially. */
3485 int used
= partial
* UNITS_PER_WORD
;
3489 if (reg
&& GET_CODE (reg
) == PARALLEL
)
3491 /* Use the size of the elt to compute offset. */
3492 rtx elt
= XEXP (XVECEXP (reg
, 0, 0), 0);
3493 used
= partial
* GET_MODE_SIZE (GET_MODE (elt
));
3494 offset
= used
% (PARM_BOUNDARY
/ BITS_PER_UNIT
);
3497 offset
= used
% (PARM_BOUNDARY
/ BITS_PER_UNIT
);
3504 /* USED is now the # of bytes we need not copy to the stack
3505 because registers will take care of them. */
3508 xinner
= adjust_address (xinner
, BLKmode
, used
);
3510 /* If the partial register-part of the arg counts in its stack size,
3511 skip the part of stack space corresponding to the registers.
3512 Otherwise, start copying to the beginning of the stack space,
3513 by setting SKIP to 0. */
3514 skip
= (reg_parm_stack_space
== 0) ? 0 : used
;
3516 #ifdef PUSH_ROUNDING
3517 /* Do it with several push insns if that doesn't take lots of insns
3518 and if there is no difficulty with push insns that skip bytes
3519 on the stack for alignment purposes. */
3522 && GET_CODE (size
) == CONST_INT
3524 && MEM_ALIGN (xinner
) >= align
3525 && (MOVE_BY_PIECES_P ((unsigned) INTVAL (size
) - used
, align
))
3526 /* Here we avoid the case of a structure whose weak alignment
3527 forces many pushes of a small amount of data,
3528 and such small pushes do rounding that causes trouble. */
3529 && ((! SLOW_UNALIGNED_ACCESS (word_mode
, align
))
3530 || align
>= BIGGEST_ALIGNMENT
3531 || (PUSH_ROUNDING (align
/ BITS_PER_UNIT
)
3532 == (align
/ BITS_PER_UNIT
)))
3533 && PUSH_ROUNDING (INTVAL (size
)) == INTVAL (size
))
3535 /* Push padding now if padding above and stack grows down,
3536 or if padding below and stack grows up.
3537 But if space already allocated, this has already been done. */
3538 if (extra
&& args_addr
== 0
3539 && where_pad
!= none
&& where_pad
!= stack_direction
)
3540 anti_adjust_stack (GEN_INT (extra
));
3542 move_by_pieces (NULL
, xinner
, INTVAL (size
) - used
, align
, 0);
3545 #endif /* PUSH_ROUNDING */
3549 /* Otherwise make space on the stack and copy the data
3550 to the address of that space. */
3552 /* Deduct words put into registers from the size we must copy. */
3555 if (GET_CODE (size
) == CONST_INT
)
3556 size
= GEN_INT (INTVAL (size
) - used
);
3558 size
= expand_binop (GET_MODE (size
), sub_optab
, size
,
3559 GEN_INT (used
), NULL_RTX
, 0,
3563 /* Get the address of the stack space.
3564 In this case, we do not deal with EXTRA separately.
3565 A single stack adjust will do. */
3568 temp
= push_block (size
, extra
, where_pad
== downward
);
3571 else if (GET_CODE (args_so_far
) == CONST_INT
)
3572 temp
= memory_address (BLKmode
,
3573 plus_constant (args_addr
,
3574 skip
+ INTVAL (args_so_far
)));
3576 temp
= memory_address (BLKmode
,
3577 plus_constant (gen_rtx_PLUS (Pmode
,
3582 if (!ACCUMULATE_OUTGOING_ARGS
)
3584 /* If the source is referenced relative to the stack pointer,
3585 copy it to another register to stabilize it. We do not need
3586 to do this if we know that we won't be changing sp. */
3588 if (reg_mentioned_p (virtual_stack_dynamic_rtx
, temp
)
3589 || reg_mentioned_p (virtual_outgoing_args_rtx
, temp
))
3590 temp
= copy_to_reg (temp
);
3593 target
= gen_rtx_MEM (BLKmode
, temp
);
3597 set_mem_attributes (target
, type
, 1);
3598 /* Function incoming arguments may overlap with sibling call
3599 outgoing arguments and we cannot allow reordering of reads
3600 from function arguments with stores to outgoing arguments
3601 of sibling calls. */
3602 set_mem_alias_set (target
, 0);
3605 /* ALIGN may well be better aligned than TYPE, e.g. due to
3606 PARM_BOUNDARY. Assume the caller isn't lying. */
3607 set_mem_align (target
, align
);
3609 emit_block_move (target
, xinner
, size
, BLOCK_OP_CALL_PARM
);
3612 else if (partial
> 0)
3614 /* Scalar partly in registers. */
3616 int size
= GET_MODE_SIZE (mode
) / UNITS_PER_WORD
;
3619 /* # words of start of argument
3620 that we must make space for but need not store. */
3621 int offset
= partial
% (PARM_BOUNDARY
/ BITS_PER_WORD
);
3622 int args_offset
= INTVAL (args_so_far
);
3625 /* Push padding now if padding above and stack grows down,
3626 or if padding below and stack grows up.
3627 But if space already allocated, this has already been done. */
3628 if (extra
&& args_addr
== 0
3629 && where_pad
!= none
&& where_pad
!= stack_direction
)
3630 anti_adjust_stack (GEN_INT (extra
));
3632 /* If we make space by pushing it, we might as well push
3633 the real data. Otherwise, we can leave OFFSET nonzero
3634 and leave the space uninitialized. */
3638 /* Now NOT_STACK gets the number of words that we don't need to
3639 allocate on the stack. */
3640 not_stack
= partial
- offset
;
3642 /* If the partial register-part of the arg counts in its stack size,
3643 skip the part of stack space corresponding to the registers.
3644 Otherwise, start copying to the beginning of the stack space,
3645 by setting SKIP to 0. */
3646 skip
= (reg_parm_stack_space
== 0) ? 0 : not_stack
;
3648 if (CONSTANT_P (x
) && ! LEGITIMATE_CONSTANT_P (x
))
3649 x
= validize_mem (force_const_mem (mode
, x
));
3651 /* If X is a hard register in a non-integer mode, copy it into a pseudo;
3652 SUBREGs of such registers are not allowed. */
3653 if ((GET_CODE (x
) == REG
&& REGNO (x
) < FIRST_PSEUDO_REGISTER
3654 && GET_MODE_CLASS (GET_MODE (x
)) != MODE_INT
))
3655 x
= copy_to_reg (x
);
3657 /* Loop over all the words allocated on the stack for this arg. */
3658 /* We can do it by words, because any scalar bigger than a word
3659 has a size a multiple of a word. */
3660 #ifndef PUSH_ARGS_REVERSED
3661 for (i
= not_stack
; i
< size
; i
++)
3663 for (i
= size
- 1; i
>= not_stack
; i
--)
3665 if (i
>= not_stack
+ offset
)
3666 emit_push_insn (operand_subword_force (x
, i
, mode
),
3667 word_mode
, NULL_TREE
, NULL_RTX
, align
, 0, NULL_RTX
,
3669 GEN_INT (args_offset
+ ((i
- not_stack
+ skip
)
3671 reg_parm_stack_space
, alignment_pad
);
3678 /* Push padding now if padding above and stack grows down,
3679 or if padding below and stack grows up.
3680 But if space already allocated, this has already been done. */
3681 if (extra
&& args_addr
== 0
3682 && where_pad
!= none
&& where_pad
!= stack_direction
)
3683 anti_adjust_stack (GEN_INT (extra
));
3685 #ifdef PUSH_ROUNDING
3686 if (args_addr
== 0 && PUSH_ARGS
)
3687 emit_single_push_insn (mode
, x
, type
);
3691 if (GET_CODE (args_so_far
) == CONST_INT
)
3693 = memory_address (mode
,
3694 plus_constant (args_addr
,
3695 INTVAL (args_so_far
)));
3697 addr
= memory_address (mode
, gen_rtx_PLUS (Pmode
, args_addr
,
3699 dest
= gen_rtx_MEM (mode
, addr
);
3702 set_mem_attributes (dest
, type
, 1);
3703 /* Function incoming arguments may overlap with sibling call
3704 outgoing arguments and we cannot allow reordering of reads
3705 from function arguments with stores to outgoing arguments
3706 of sibling calls. */
3707 set_mem_alias_set (dest
, 0);
3710 emit_move_insn (dest
, x
);
3714 /* If part should go in registers, copy that part
3715 into the appropriate registers. Do this now, at the end,
3716 since mem-to-mem copies above may do function calls. */
3717 if (partial
> 0 && reg
!= 0)
3719 /* Handle calls that pass values in multiple non-contiguous locations.
3720 The Irix 6 ABI has examples of this. */
3721 if (GET_CODE (reg
) == PARALLEL
)
3722 emit_group_load (reg
, x
, type
, -1);
3724 move_block_to_reg (REGNO (reg
), x
, partial
, mode
);
3727 if (extra
&& args_addr
== 0 && where_pad
== stack_direction
)
3728 anti_adjust_stack (GEN_INT (extra
));
3730 if (alignment_pad
&& args_addr
== 0)
3731 anti_adjust_stack (alignment_pad
);
3734 /* Return X if X can be used as a subtarget in a sequence of arithmetic
3738 get_subtarget (rtx x
)
3741 /* Only registers can be subtargets. */
3742 || GET_CODE (x
) != REG
3743 /* If the register is readonly, it can't be set more than once. */
3744 || RTX_UNCHANGING_P (x
)
3745 /* Don't use hard regs to avoid extending their life. */
3746 || REGNO (x
) < FIRST_PSEUDO_REGISTER
3747 /* Avoid subtargets inside loops,
3748 since they hide some invariant expressions. */
3749 || preserve_subexpressions_p ())
3753 /* Expand an assignment that stores the value of FROM into TO.
3754 If WANT_VALUE is nonzero, return an rtx for the value of TO.
3755 (This may contain a QUEUED rtx;
3756 if the value is constant, this rtx is a constant.)
3757 Otherwise, the returned value is NULL_RTX. */
3760 expand_assignment (tree to
, tree from
, int want_value
)
3765 /* Don't crash if the lhs of the assignment was erroneous. */
3767 if (TREE_CODE (to
) == ERROR_MARK
)
3769 result
= expand_expr (from
, NULL_RTX
, VOIDmode
, 0);
3770 return want_value
? result
: NULL_RTX
;
3773 /* Assignment of a structure component needs special treatment
3774 if the structure component's rtx is not simply a MEM.
3775 Assignment of an array element at a constant index, and assignment of
3776 an array element in an unaligned packed structure field, has the same
3779 if (TREE_CODE (to
) == COMPONENT_REF
|| TREE_CODE (to
) == BIT_FIELD_REF
3780 || TREE_CODE (to
) == ARRAY_REF
|| TREE_CODE (to
) == ARRAY_RANGE_REF
3781 || TREE_CODE (TREE_TYPE (to
)) == ARRAY_TYPE
)
3783 enum machine_mode mode1
;
3784 HOST_WIDE_INT bitsize
, bitpos
;
3792 tem
= get_inner_reference (to
, &bitsize
, &bitpos
, &offset
, &mode1
,
3793 &unsignedp
, &volatilep
);
3795 /* If we are going to use store_bit_field and extract_bit_field,
3796 make sure to_rtx will be safe for multiple use. */
3798 if (mode1
== VOIDmode
&& want_value
)
3799 tem
= stabilize_reference (tem
);
3801 orig_to_rtx
= to_rtx
= expand_expr (tem
, NULL_RTX
, VOIDmode
, 0);
3805 rtx offset_rtx
= expand_expr (offset
, NULL_RTX
, VOIDmode
, EXPAND_SUM
);
3807 if (GET_CODE (to_rtx
) != MEM
)
3810 #ifdef POINTERS_EXTEND_UNSIGNED
3811 if (GET_MODE (offset_rtx
) != Pmode
)
3812 offset_rtx
= convert_to_mode (Pmode
, offset_rtx
, 0);
3814 if (GET_MODE (offset_rtx
) != ptr_mode
)
3815 offset_rtx
= convert_to_mode (ptr_mode
, offset_rtx
, 0);
3818 /* A constant address in TO_RTX can have VOIDmode, we must not try
3819 to call force_reg for that case. Avoid that case. */
3820 if (GET_CODE (to_rtx
) == MEM
3821 && GET_MODE (to_rtx
) == BLKmode
3822 && GET_MODE (XEXP (to_rtx
, 0)) != VOIDmode
3824 && (bitpos
% bitsize
) == 0
3825 && (bitsize
% GET_MODE_ALIGNMENT (mode1
)) == 0
3826 && MEM_ALIGN (to_rtx
) == GET_MODE_ALIGNMENT (mode1
))
3828 to_rtx
= adjust_address (to_rtx
, mode1
, bitpos
/ BITS_PER_UNIT
);
3832 to_rtx
= offset_address (to_rtx
, offset_rtx
,
3833 highest_pow2_factor_for_target (to
,
3837 if (GET_CODE (to_rtx
) == MEM
)
3839 /* If the field is at offset zero, we could have been given the
3840 DECL_RTX of the parent struct. Don't munge it. */
3841 to_rtx
= shallow_copy_rtx (to_rtx
);
3843 set_mem_attributes_minus_bitpos (to_rtx
, to
, 0, bitpos
);
3846 /* Deal with volatile and readonly fields. The former is only done
3847 for MEM. Also set MEM_KEEP_ALIAS_SET_P if needed. */
3848 if (volatilep
&& GET_CODE (to_rtx
) == MEM
)
3850 if (to_rtx
== orig_to_rtx
)
3851 to_rtx
= copy_rtx (to_rtx
);
3852 MEM_VOLATILE_P (to_rtx
) = 1;
3855 if (TREE_CODE (to
) == COMPONENT_REF
3856 && TREE_READONLY (TREE_OPERAND (to
, 1))
3857 /* We can't assert that a MEM won't be set more than once
3858 if the component is not addressable because another
3859 non-addressable component may be referenced by the same MEM. */
3860 && ! (GET_CODE (to_rtx
) == MEM
&& ! can_address_p (to
)))
3862 if (to_rtx
== orig_to_rtx
)
3863 to_rtx
= copy_rtx (to_rtx
);
3864 RTX_UNCHANGING_P (to_rtx
) = 1;
3867 if (GET_CODE (to_rtx
) == MEM
&& ! can_address_p (to
))
3869 if (to_rtx
== orig_to_rtx
)
3870 to_rtx
= copy_rtx (to_rtx
);
3871 MEM_KEEP_ALIAS_SET_P (to_rtx
) = 1;
3874 result
= store_field (to_rtx
, bitsize
, bitpos
, mode1
, from
,
3876 /* Spurious cast for HPUX compiler. */
3877 ? ((enum machine_mode
)
3878 TYPE_MODE (TREE_TYPE (to
)))
3880 unsignedp
, TREE_TYPE (tem
), get_alias_set (to
));
3882 preserve_temp_slots (result
);
3886 /* If the value is meaningful, convert RESULT to the proper mode.
3887 Otherwise, return nothing. */
3888 return (want_value
? convert_modes (TYPE_MODE (TREE_TYPE (to
)),
3889 TYPE_MODE (TREE_TYPE (from
)),
3891 TREE_UNSIGNED (TREE_TYPE (to
)))
3895 /* If the rhs is a function call and its value is not an aggregate,
3896 call the function before we start to compute the lhs.
3897 This is needed for correct code for cases such as
3898 val = setjmp (buf) on machines where reference to val
3899 requires loading up part of an address in a separate insn.
3901 Don't do this if TO is a VAR_DECL or PARM_DECL whose DECL_RTL is REG
3902 since it might be a promoted variable where the zero- or sign- extension
3903 needs to be done. Handling this in the normal way is safe because no
3904 computation is done before the call. */
3905 if (TREE_CODE (from
) == CALL_EXPR
&& ! aggregate_value_p (from
, from
)
3906 && TREE_CODE (TYPE_SIZE (TREE_TYPE (from
))) == INTEGER_CST
3907 && ! ((TREE_CODE (to
) == VAR_DECL
|| TREE_CODE (to
) == PARM_DECL
)
3908 && GET_CODE (DECL_RTL (to
)) == REG
))
3913 value
= expand_expr (from
, NULL_RTX
, VOIDmode
, 0);
3915 to_rtx
= expand_expr (to
, NULL_RTX
, VOIDmode
, EXPAND_WRITE
);
3917 /* Handle calls that return values in multiple non-contiguous locations.
3918 The Irix 6 ABI has examples of this. */
3919 if (GET_CODE (to_rtx
) == PARALLEL
)
3920 emit_group_load (to_rtx
, value
, TREE_TYPE (from
),
3921 int_size_in_bytes (TREE_TYPE (from
)));
3922 else if (GET_MODE (to_rtx
) == BLKmode
)
3923 emit_block_move (to_rtx
, value
, expr_size (from
), BLOCK_OP_NORMAL
);
3926 if (POINTER_TYPE_P (TREE_TYPE (to
)))
3927 value
= convert_memory_address (GET_MODE (to_rtx
), value
);
3928 emit_move_insn (to_rtx
, value
);
3930 preserve_temp_slots (to_rtx
);
3933 return want_value
? to_rtx
: NULL_RTX
;
3936 /* Ordinary treatment. Expand TO to get a REG or MEM rtx.
3937 Don't re-expand if it was expanded already (in COMPONENT_REF case). */
3940 to_rtx
= expand_expr (to
, NULL_RTX
, VOIDmode
, EXPAND_WRITE
);
3942 /* Don't move directly into a return register. */
3943 if (TREE_CODE (to
) == RESULT_DECL
3944 && (GET_CODE (to_rtx
) == REG
|| GET_CODE (to_rtx
) == PARALLEL
))
3949 temp
= expand_expr (from
, 0, GET_MODE (to_rtx
), 0);
3951 if (GET_CODE (to_rtx
) == PARALLEL
)
3952 emit_group_load (to_rtx
, temp
, TREE_TYPE (from
),
3953 int_size_in_bytes (TREE_TYPE (from
)));
3955 emit_move_insn (to_rtx
, temp
);
3957 preserve_temp_slots (to_rtx
);
3960 return want_value
? to_rtx
: NULL_RTX
;
3963 /* In case we are returning the contents of an object which overlaps
3964 the place the value is being stored, use a safe function when copying
3965 a value through a pointer into a structure value return block. */
3966 if (TREE_CODE (to
) == RESULT_DECL
&& TREE_CODE (from
) == INDIRECT_REF
3967 && current_function_returns_struct
3968 && !current_function_returns_pcc_struct
)
3973 size
= expr_size (from
);
3974 from_rtx
= expand_expr (from
, NULL_RTX
, VOIDmode
, 0);
3976 if (TARGET_MEM_FUNCTIONS
)
3977 emit_library_call (memmove_libfunc
, LCT_NORMAL
,
3978 VOIDmode
, 3, XEXP (to_rtx
, 0), Pmode
,
3979 XEXP (from_rtx
, 0), Pmode
,
3980 convert_to_mode (TYPE_MODE (sizetype
),
3981 size
, TREE_UNSIGNED (sizetype
)),
3982 TYPE_MODE (sizetype
));
3984 emit_library_call (bcopy_libfunc
, LCT_NORMAL
,
3985 VOIDmode
, 3, XEXP (from_rtx
, 0), Pmode
,
3986 XEXP (to_rtx
, 0), Pmode
,
3987 convert_to_mode (TYPE_MODE (integer_type_node
),
3989 TREE_UNSIGNED (integer_type_node
)),
3990 TYPE_MODE (integer_type_node
));
3992 preserve_temp_slots (to_rtx
);
3995 return want_value
? to_rtx
: NULL_RTX
;
3998 /* Compute FROM and store the value in the rtx we got. */
4001 result
= store_expr (from
, to_rtx
, want_value
);
4002 preserve_temp_slots (result
);
4005 return want_value
? result
: NULL_RTX
;
4008 /* Generate code for computing expression EXP,
4009 and storing the value into TARGET.
4010 TARGET may contain a QUEUED rtx.
4012 If WANT_VALUE & 1 is nonzero, return a copy of the value
4013 not in TARGET, so that we can be sure to use the proper
4014 value in a containing expression even if TARGET has something
4015 else stored in it. If possible, we copy the value through a pseudo
4016 and return that pseudo. Or, if the value is constant, we try to
4017 return the constant. In some cases, we return a pseudo
4018 copied *from* TARGET.
4020 If the mode is BLKmode then we may return TARGET itself.
4021 It turns out that in BLKmode it doesn't cause a problem.
4022 because C has no operators that could combine two different
4023 assignments into the same BLKmode object with different values
4024 with no sequence point. Will other languages need this to
4027 If WANT_VALUE & 1 is 0, we return NULL, to make sure
4028 to catch quickly any cases where the caller uses the value
4029 and fails to set WANT_VALUE.
4031 If WANT_VALUE & 2 is set, this is a store into a call param on the
4032 stack, and block moves may need to be treated specially. */
4035 store_expr (tree exp
, rtx target
, int want_value
)
4038 rtx alt_rtl
= NULL_RTX
;
4039 rtx mark
= mark_queue ();
4040 int dont_return_target
= 0;
4041 int dont_store_target
= 0;
4043 if (VOID_TYPE_P (TREE_TYPE (exp
)))
4045 /* C++ can generate ?: expressions with a throw expression in one
4046 branch and an rvalue in the other. Here, we resolve attempts to
4047 store the throw expression's nonexistent result. */
4050 expand_expr (exp
, const0_rtx
, VOIDmode
, 0);
4053 if (TREE_CODE (exp
) == COMPOUND_EXPR
)
4055 /* Perform first part of compound expression, then assign from second
4057 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
,
4058 want_value
& 2 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
);
4060 return store_expr (TREE_OPERAND (exp
, 1), target
, want_value
);
4062 else if (TREE_CODE (exp
) == COND_EXPR
&& GET_MODE (target
) == BLKmode
)
4064 /* For conditional expression, get safe form of the target. Then
4065 test the condition, doing the appropriate assignment on either
4066 side. This avoids the creation of unnecessary temporaries.
4067 For non-BLKmode, it is more efficient not to do this. */
4069 rtx lab1
= gen_label_rtx (), lab2
= gen_label_rtx ();
4072 target
= protect_from_queue (target
, 1);
4074 do_pending_stack_adjust ();
4076 jumpifnot (TREE_OPERAND (exp
, 0), lab1
);
4077 start_cleanup_deferral ();
4078 store_expr (TREE_OPERAND (exp
, 1), target
, want_value
& 2);
4079 end_cleanup_deferral ();
4081 emit_jump_insn (gen_jump (lab2
));
4084 start_cleanup_deferral ();
4085 store_expr (TREE_OPERAND (exp
, 2), target
, want_value
& 2);
4086 end_cleanup_deferral ();
4091 return want_value
& 1 ? target
: NULL_RTX
;
4093 else if (queued_subexp_p (target
))
4094 /* If target contains a postincrement, let's not risk
4095 using it as the place to generate the rhs. */
4097 if (GET_MODE (target
) != BLKmode
&& GET_MODE (target
) != VOIDmode
)
4099 /* Expand EXP into a new pseudo. */
4100 temp
= gen_reg_rtx (GET_MODE (target
));
4101 temp
= expand_expr (exp
, temp
, GET_MODE (target
),
4103 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
));
4106 temp
= expand_expr (exp
, NULL_RTX
, GET_MODE (target
),
4108 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
));
4110 /* If target is volatile, ANSI requires accessing the value
4111 *from* the target, if it is accessed. So make that happen.
4112 In no case return the target itself. */
4113 if (! MEM_VOLATILE_P (target
) && (want_value
& 1) != 0)
4114 dont_return_target
= 1;
4116 else if ((want_value
& 1) != 0
4117 && GET_CODE (target
) == MEM
4118 && ! MEM_VOLATILE_P (target
)
4119 && GET_MODE (target
) != BLKmode
)
4120 /* If target is in memory and caller wants value in a register instead,
4121 arrange that. Pass TARGET as target for expand_expr so that,
4122 if EXP is another assignment, WANT_VALUE will be nonzero for it.
4123 We know expand_expr will not use the target in that case.
4124 Don't do this if TARGET is volatile because we are supposed
4125 to write it and then read it. */
4127 temp
= expand_expr (exp
, target
, GET_MODE (target
),
4128 want_value
& 2 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
);
4129 if (GET_MODE (temp
) != BLKmode
&& GET_MODE (temp
) != VOIDmode
)
4131 /* If TEMP is already in the desired TARGET, only copy it from
4132 memory and don't store it there again. */
4134 || (rtx_equal_p (temp
, target
)
4135 && ! side_effects_p (temp
) && ! side_effects_p (target
)))
4136 dont_store_target
= 1;
4137 temp
= copy_to_reg (temp
);
4139 dont_return_target
= 1;
4141 else if (GET_CODE (target
) == SUBREG
&& SUBREG_PROMOTED_VAR_P (target
))
4142 /* If this is a scalar in a register that is stored in a wider mode
4143 than the declared mode, compute the result into its declared mode
4144 and then convert to the wider mode. Our value is the computed
4147 rtx inner_target
= 0;
4149 /* If we don't want a value, we can do the conversion inside EXP,
4150 which will often result in some optimizations. Do the conversion
4151 in two steps: first change the signedness, if needed, then
4152 the extend. But don't do this if the type of EXP is a subtype
4153 of something else since then the conversion might involve
4154 more than just converting modes. */
4155 if ((want_value
& 1) == 0
4156 && INTEGRAL_TYPE_P (TREE_TYPE (exp
))
4157 && TREE_TYPE (TREE_TYPE (exp
)) == 0)
4159 if (TREE_UNSIGNED (TREE_TYPE (exp
))
4160 != SUBREG_PROMOTED_UNSIGNED_P (target
))
4162 ((*lang_hooks
.types
.signed_or_unsigned_type
)
4163 (SUBREG_PROMOTED_UNSIGNED_P (target
), TREE_TYPE (exp
)), exp
);
4165 exp
= convert ((*lang_hooks
.types
.type_for_mode
)
4166 (GET_MODE (SUBREG_REG (target
)),
4167 SUBREG_PROMOTED_UNSIGNED_P (target
)),
4170 inner_target
= SUBREG_REG (target
);
4173 temp
= expand_expr (exp
, inner_target
, VOIDmode
,
4174 want_value
& 2 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
);
4176 /* If TEMP is a MEM and we want a result value, make the access
4177 now so it gets done only once. Strictly speaking, this is
4178 only necessary if the MEM is volatile, or if the address
4179 overlaps TARGET. But not performing the load twice also
4180 reduces the amount of rtl we generate and then have to CSE. */
4181 if (GET_CODE (temp
) == MEM
&& (want_value
& 1) != 0)
4182 temp
= copy_to_reg (temp
);
4184 /* If TEMP is a VOIDmode constant, use convert_modes to make
4185 sure that we properly convert it. */
4186 if (CONSTANT_P (temp
) && GET_MODE (temp
) == VOIDmode
)
4188 temp
= convert_modes (GET_MODE (target
), TYPE_MODE (TREE_TYPE (exp
)),
4189 temp
, SUBREG_PROMOTED_UNSIGNED_P (target
));
4190 temp
= convert_modes (GET_MODE (SUBREG_REG (target
)),
4191 GET_MODE (target
), temp
,
4192 SUBREG_PROMOTED_UNSIGNED_P (target
));
4195 convert_move (SUBREG_REG (target
), temp
,
4196 SUBREG_PROMOTED_UNSIGNED_P (target
));
4198 /* If we promoted a constant, change the mode back down to match
4199 target. Otherwise, the caller might get confused by a result whose
4200 mode is larger than expected. */
4202 if ((want_value
& 1) != 0 && GET_MODE (temp
) != GET_MODE (target
))
4204 if (GET_MODE (temp
) != VOIDmode
)
4206 temp
= gen_lowpart_SUBREG (GET_MODE (target
), temp
);
4207 SUBREG_PROMOTED_VAR_P (temp
) = 1;
4208 SUBREG_PROMOTED_UNSIGNED_SET (temp
,
4209 SUBREG_PROMOTED_UNSIGNED_P (target
));
4212 temp
= convert_modes (GET_MODE (target
),
4213 GET_MODE (SUBREG_REG (target
)),
4214 temp
, SUBREG_PROMOTED_UNSIGNED_P (target
));
4217 return want_value
& 1 ? temp
: NULL_RTX
;
4221 temp
= expand_expr_real (exp
, target
, GET_MODE (target
),
4223 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
),
4225 /* Return TARGET if it's a specified hardware register.
4226 If TARGET is a volatile mem ref, either return TARGET
4227 or return a reg copied *from* TARGET; ANSI requires this.
4229 Otherwise, if TEMP is not TARGET, return TEMP
4230 if it is constant (for efficiency),
4231 or if we really want the correct value. */
4232 if (!(target
&& GET_CODE (target
) == REG
4233 && REGNO (target
) < FIRST_PSEUDO_REGISTER
)
4234 && !(GET_CODE (target
) == MEM
&& MEM_VOLATILE_P (target
))
4235 && ! rtx_equal_p (temp
, target
)
4236 && (CONSTANT_P (temp
) || (want_value
& 1) != 0))
4237 dont_return_target
= 1;
4240 /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
4241 the same as that of TARGET, adjust the constant. This is needed, for
4242 example, in case it is a CONST_DOUBLE and we want only a word-sized
4244 if (CONSTANT_P (temp
) && GET_MODE (temp
) == VOIDmode
4245 && TREE_CODE (exp
) != ERROR_MARK
4246 && GET_MODE (target
) != TYPE_MODE (TREE_TYPE (exp
)))
4247 temp
= convert_modes (GET_MODE (target
), TYPE_MODE (TREE_TYPE (exp
)),
4248 temp
, TREE_UNSIGNED (TREE_TYPE (exp
)));
4250 /* If value was not generated in the target, store it there.
4251 Convert the value to TARGET's type first if necessary and emit the
4252 pending incrementations that have been queued when expanding EXP.
4253 Note that we cannot emit the whole queue blindly because this will
4254 effectively disable the POST_INC optimization later.
4256 If TEMP and TARGET compare equal according to rtx_equal_p, but
4257 one or both of them are volatile memory refs, we have to distinguish
4259 - expand_expr has used TARGET. In this case, we must not generate
4260 another copy. This can be detected by TARGET being equal according
4262 - expand_expr has not used TARGET - that means that the source just
4263 happens to have the same RTX form. Since temp will have been created
4264 by expand_expr, it will compare unequal according to == .
4265 We must generate a copy in this case, to reach the correct number
4266 of volatile memory references. */
4268 if ((! rtx_equal_p (temp
, target
)
4269 || (temp
!= target
&& (side_effects_p (temp
)
4270 || side_effects_p (target
))))
4271 && TREE_CODE (exp
) != ERROR_MARK
4272 && ! dont_store_target
4273 /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET,
4274 but TARGET is not valid memory reference, TEMP will differ
4275 from TARGET although it is really the same location. */
4276 && !(alt_rtl
&& rtx_equal_p (alt_rtl
, target
))
4277 /* If there's nothing to copy, don't bother. Don't call expr_size
4278 unless necessary, because some front-ends (C++) expr_size-hook
4279 aborts on objects that are not supposed to be bit-copied or
4281 && expr_size (exp
) != const0_rtx
)
4283 emit_insns_enqueued_after_mark (mark
);
4284 target
= protect_from_queue (target
, 1);
4285 temp
= protect_from_queue (temp
, 0);
4286 if (GET_MODE (temp
) != GET_MODE (target
)
4287 && GET_MODE (temp
) != VOIDmode
)
4289 int unsignedp
= TREE_UNSIGNED (TREE_TYPE (exp
));
4290 if (dont_return_target
)
4292 /* In this case, we will return TEMP,
4293 so make sure it has the proper mode.
4294 But don't forget to store the value into TARGET. */
4295 temp
= convert_to_mode (GET_MODE (target
), temp
, unsignedp
);
4296 emit_move_insn (target
, temp
);
4299 convert_move (target
, temp
, unsignedp
);
4302 else if (GET_MODE (temp
) == BLKmode
&& TREE_CODE (exp
) == STRING_CST
)
4304 /* Handle copying a string constant into an array. The string
4305 constant may be shorter than the array. So copy just the string's
4306 actual length, and clear the rest. First get the size of the data
4307 type of the string, which is actually the size of the target. */
4308 rtx size
= expr_size (exp
);
4310 if (GET_CODE (size
) == CONST_INT
4311 && INTVAL (size
) < TREE_STRING_LENGTH (exp
))
4312 emit_block_move (target
, temp
, size
,
4314 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
4317 /* Compute the size of the data to copy from the string. */
4319 = size_binop (MIN_EXPR
,
4320 make_tree (sizetype
, size
),
4321 size_int (TREE_STRING_LENGTH (exp
)));
4323 = expand_expr (copy_size
, NULL_RTX
, VOIDmode
,
4325 ? EXPAND_STACK_PARM
: EXPAND_NORMAL
));
4328 /* Copy that much. */
4329 copy_size_rtx
= convert_to_mode (ptr_mode
, copy_size_rtx
,
4330 TREE_UNSIGNED (sizetype
));
4331 emit_block_move (target
, temp
, copy_size_rtx
,
4333 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
4335 /* Figure out how much is left in TARGET that we have to clear.
4336 Do all calculations in ptr_mode. */
4337 if (GET_CODE (copy_size_rtx
) == CONST_INT
)
4339 size
= plus_constant (size
, -INTVAL (copy_size_rtx
));
4340 target
= adjust_address (target
, BLKmode
,
4341 INTVAL (copy_size_rtx
));
4345 size
= expand_binop (TYPE_MODE (sizetype
), sub_optab
, size
,
4346 copy_size_rtx
, NULL_RTX
, 0,
4349 #ifdef POINTERS_EXTEND_UNSIGNED
4350 if (GET_MODE (copy_size_rtx
) != Pmode
)
4351 copy_size_rtx
= convert_to_mode (Pmode
, copy_size_rtx
,
4352 TREE_UNSIGNED (sizetype
));
4355 target
= offset_address (target
, copy_size_rtx
,
4356 highest_pow2_factor (copy_size
));
4357 label
= gen_label_rtx ();
4358 emit_cmp_and_jump_insns (size
, const0_rtx
, LT
, NULL_RTX
,
4359 GET_MODE (size
), 0, label
);
4362 if (size
!= const0_rtx
)
4363 clear_storage (target
, size
);
4369 /* Handle calls that return values in multiple non-contiguous locations.
4370 The Irix 6 ABI has examples of this. */
4371 else if (GET_CODE (target
) == PARALLEL
)
4372 emit_group_load (target
, temp
, TREE_TYPE (exp
),
4373 int_size_in_bytes (TREE_TYPE (exp
)));
4374 else if (GET_MODE (temp
) == BLKmode
)
4375 emit_block_move (target
, temp
, expr_size (exp
),
4377 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
4379 emit_move_insn (target
, temp
);
4382 /* If we don't want a value, return NULL_RTX. */
4383 if ((want_value
& 1) == 0)
4386 /* If we are supposed to return TEMP, do so as long as it isn't a MEM.
4387 ??? The latter test doesn't seem to make sense. */
4388 else if (dont_return_target
&& GET_CODE (temp
) != MEM
)
4391 /* Return TARGET itself if it is a hard register. */
4392 else if ((want_value
& 1) != 0
4393 && GET_MODE (target
) != BLKmode
4394 && ! (GET_CODE (target
) == REG
4395 && REGNO (target
) < FIRST_PSEUDO_REGISTER
))
4396 return copy_to_reg (target
);
4402 /* Return 1 if EXP just contains zeros. FIXME merge with initializer_zerop. */
4405 is_zeros_p (tree exp
)
4409 switch (TREE_CODE (exp
))
4413 case NON_LVALUE_EXPR
:
4414 case VIEW_CONVERT_EXPR
:
4415 return is_zeros_p (TREE_OPERAND (exp
, 0));
4418 return integer_zerop (exp
);
4422 is_zeros_p (TREE_REALPART (exp
)) && is_zeros_p (TREE_IMAGPART (exp
));
4425 return REAL_VALUES_IDENTICAL (TREE_REAL_CST (exp
), dconst0
);
4428 for (elt
= TREE_VECTOR_CST_ELTS (exp
); elt
;
4429 elt
= TREE_CHAIN (elt
))
4430 if (!is_zeros_p (TREE_VALUE (elt
)))
4436 if (TREE_TYPE (exp
) && TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
4437 return CONSTRUCTOR_ELTS (exp
) == NULL_TREE
;
4438 for (elt
= CONSTRUCTOR_ELTS (exp
); elt
; elt
= TREE_CHAIN (elt
))
4439 if (! is_zeros_p (TREE_VALUE (elt
)))
4449 /* Return 1 if EXP contains mostly (3/4) zeros. */
4452 mostly_zeros_p (tree exp
)
4454 if (TREE_CODE (exp
) == CONSTRUCTOR
)
4456 int elts
= 0, zeros
= 0;
4457 tree elt
= CONSTRUCTOR_ELTS (exp
);
4458 if (TREE_TYPE (exp
) && TREE_CODE (TREE_TYPE (exp
)) == SET_TYPE
)
4460 /* If there are no ranges of true bits, it is all zero. */
4461 return elt
== NULL_TREE
;
4463 for (; elt
; elt
= TREE_CHAIN (elt
))
4465 /* We do not handle the case where the index is a RANGE_EXPR,
4466 so the statistic will be somewhat inaccurate.
4467 We do make a more accurate count in store_constructor itself,
4468 so since this function is only used for nested array elements,
4469 this should be close enough. */
4470 if (mostly_zeros_p (TREE_VALUE (elt
)))
4475 return 4 * zeros
>= 3 * elts
;
4478 return is_zeros_p (exp
);
4481 /* Helper function for store_constructor.
4482 TARGET, BITSIZE, BITPOS, MODE, EXP are as for store_field.
4483 TYPE is the type of the CONSTRUCTOR, not the element type.
4484 CLEARED is as for store_constructor.
4485 ALIAS_SET is the alias set to use for any stores.
4487 This provides a recursive shortcut back to store_constructor when it isn't
4488 necessary to go through store_field. This is so that we can pass through
4489 the cleared field to let store_constructor know that we may not have to
4490 clear a substructure if the outer structure has already been cleared. */
4493 store_constructor_field (rtx target
, unsigned HOST_WIDE_INT bitsize
,
4494 HOST_WIDE_INT bitpos
, enum machine_mode mode
,
4495 tree exp
, tree type
, int cleared
, int alias_set
)
4497 if (TREE_CODE (exp
) == CONSTRUCTOR
4498 && bitpos
% BITS_PER_UNIT
== 0
4499 /* If we have a nonzero bitpos for a register target, then we just
4500 let store_field do the bitfield handling. This is unlikely to
4501 generate unnecessary clear instructions anyways. */
4502 && (bitpos
== 0 || GET_CODE (target
) == MEM
))
4504 if (GET_CODE (target
) == MEM
)
4506 = adjust_address (target
,
4507 GET_MODE (target
) == BLKmode
4509 % GET_MODE_ALIGNMENT (GET_MODE (target
)))
4510 ? BLKmode
: VOIDmode
, bitpos
/ BITS_PER_UNIT
);
4513 /* Update the alias set, if required. */
4514 if (GET_CODE (target
) == MEM
&& ! MEM_KEEP_ALIAS_SET_P (target
)
4515 && MEM_ALIAS_SET (target
) != 0)
4517 target
= copy_rtx (target
);
4518 set_mem_alias_set (target
, alias_set
);
4521 store_constructor (exp
, target
, cleared
, bitsize
/ BITS_PER_UNIT
);
4524 store_field (target
, bitsize
, bitpos
, mode
, exp
, VOIDmode
, 0, type
,
4528 /* Store the value of constructor EXP into the rtx TARGET.
4529 TARGET is either a REG or a MEM; we know it cannot conflict, since
4530 safe_from_p has been called.
4531 CLEARED is true if TARGET is known to have been zero'd.
4532 SIZE is the number of bytes of TARGET we are allowed to modify: this
4533 may not be the same as the size of EXP if we are assigning to a field
4534 which has been packed to exclude padding bits. */
4537 store_constructor (tree exp
, rtx target
, int cleared
, HOST_WIDE_INT size
)
4539 tree type
= TREE_TYPE (exp
);
4540 #ifdef WORD_REGISTER_OPERATIONS
4541 HOST_WIDE_INT exp_size
= int_size_in_bytes (type
);
4544 if (TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
4545 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
4549 /* If size is zero or the target is already cleared, do nothing. */
4550 if (size
== 0 || cleared
)
4552 /* We either clear the aggregate or indicate the value is dead. */
4553 else if ((TREE_CODE (type
) == UNION_TYPE
4554 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
4555 && ! CONSTRUCTOR_ELTS (exp
))
4556 /* If the constructor is empty, clear the union. */
4558 clear_storage (target
, expr_size (exp
));
4562 /* If we are building a static constructor into a register,
4563 set the initial value as zero so we can fold the value into
4564 a constant. But if more than one register is involved,
4565 this probably loses. */
4566 else if (GET_CODE (target
) == REG
&& TREE_STATIC (exp
)
4567 && GET_MODE_SIZE (GET_MODE (target
)) <= UNITS_PER_WORD
)
4569 emit_move_insn (target
, CONST0_RTX (GET_MODE (target
)));
4573 /* If the constructor has fewer fields than the structure
4574 or if we are initializing the structure to mostly zeros,
4575 clear the whole structure first. Don't do this if TARGET is a
4576 register whose mode size isn't equal to SIZE since clear_storage
4577 can't handle this case. */
4579 && ((list_length (CONSTRUCTOR_ELTS (exp
)) != fields_length (type
))
4580 || mostly_zeros_p (exp
))
4581 && (GET_CODE (target
) != REG
4582 || ((HOST_WIDE_INT
) GET_MODE_SIZE (GET_MODE (target
))
4585 rtx xtarget
= target
;
4587 if (RTX_UNCHANGING_P (target
))
4589 xtarget
= copy_rtx (target
);
4590 RTX_UNCHANGING_P (xtarget
) = 0;
4593 clear_storage (xtarget
, GEN_INT (size
));
4595 if (RTX_UNCHANGING_P (target
) || readonly_fields_p (type
))
4597 /* ??? Emit a blockage to prevent the scheduler from swapping
4598 the memory write issued above without the /u flag and
4599 memory writes that will be issued later with it.
4600 Note that the clearing above cannot be simply disabled
4601 in the unsafe cases because the C front-end relies on
4602 it to implement the semantics of constructors for
4603 automatic objects. However, not all machine descriptions
4604 define a blockage insn, so emit an ASM_INPUT to
4606 emit_insn (gen_rtx_ASM_INPUT (VOIDmode
, ""));
4611 emit_insn (gen_rtx_CLOBBER (VOIDmode
, target
));
4613 /* Store each element of the constructor into
4614 the corresponding field of TARGET. */
4616 for (elt
= CONSTRUCTOR_ELTS (exp
); elt
; elt
= TREE_CHAIN (elt
))
4618 tree field
= TREE_PURPOSE (elt
);
4619 tree value
= TREE_VALUE (elt
);
4620 enum machine_mode mode
;
4621 HOST_WIDE_INT bitsize
;
4622 HOST_WIDE_INT bitpos
= 0;
4624 rtx to_rtx
= target
;
4626 /* Just ignore missing fields.
4627 We cleared the whole structure, above,
4628 if any fields are missing. */
4632 if (cleared
&& is_zeros_p (value
))
4635 if (host_integerp (DECL_SIZE (field
), 1))
4636 bitsize
= tree_low_cst (DECL_SIZE (field
), 1);
4640 mode
= DECL_MODE (field
);
4641 if (DECL_BIT_FIELD (field
))
4644 offset
= DECL_FIELD_OFFSET (field
);
4645 if (host_integerp (offset
, 0)
4646 && host_integerp (bit_position (field
), 0))
4648 bitpos
= int_bit_position (field
);
4652 bitpos
= tree_low_cst (DECL_FIELD_BIT_OFFSET (field
), 0);
4658 if (CONTAINS_PLACEHOLDER_P (offset
))
4659 offset
= build (WITH_RECORD_EXPR
, sizetype
,
4660 offset
, make_tree (TREE_TYPE (exp
), target
));
4662 offset_rtx
= expand_expr (offset
, NULL_RTX
, VOIDmode
, 0);
4663 if (GET_CODE (to_rtx
) != MEM
)
4666 #ifdef POINTERS_EXTEND_UNSIGNED
4667 if (GET_MODE (offset_rtx
) != Pmode
)
4668 offset_rtx
= convert_to_mode (Pmode
, offset_rtx
, 0);
4670 if (GET_MODE (offset_rtx
) != ptr_mode
)
4671 offset_rtx
= convert_to_mode (ptr_mode
, offset_rtx
, 0);
4674 to_rtx
= offset_address (to_rtx
, offset_rtx
,
4675 highest_pow2_factor (offset
));
4678 if (TREE_READONLY (field
))
4680 if (GET_CODE (to_rtx
) == MEM
)
4681 to_rtx
= copy_rtx (to_rtx
);
4683 RTX_UNCHANGING_P (to_rtx
) = 1;
4686 #ifdef WORD_REGISTER_OPERATIONS
4687 /* If this initializes a field that is smaller than a word, at the
4688 start of a word, try to widen it to a full word.
4689 This special case allows us to output C++ member function
4690 initializations in a form that the optimizers can understand. */
4691 if (GET_CODE (target
) == REG
4692 && bitsize
< BITS_PER_WORD
4693 && bitpos
% BITS_PER_WORD
== 0
4694 && GET_MODE_CLASS (mode
) == MODE_INT
4695 && TREE_CODE (value
) == INTEGER_CST
4697 && bitpos
+ BITS_PER_WORD
<= exp_size
* BITS_PER_UNIT
)
4699 tree type
= TREE_TYPE (value
);
4701 if (TYPE_PRECISION (type
) < BITS_PER_WORD
)
4703 type
= (*lang_hooks
.types
.type_for_size
)
4704 (BITS_PER_WORD
, TREE_UNSIGNED (type
));
4705 value
= convert (type
, value
);
4708 if (BYTES_BIG_ENDIAN
)
4710 = fold (build (LSHIFT_EXPR
, type
, value
,
4711 build_int_2 (BITS_PER_WORD
- bitsize
, 0)));
4712 bitsize
= BITS_PER_WORD
;
4717 if (GET_CODE (to_rtx
) == MEM
&& !MEM_KEEP_ALIAS_SET_P (to_rtx
)
4718 && DECL_NONADDRESSABLE_P (field
))
4720 to_rtx
= copy_rtx (to_rtx
);
4721 MEM_KEEP_ALIAS_SET_P (to_rtx
) = 1;
4724 store_constructor_field (to_rtx
, bitsize
, bitpos
, mode
,
4725 value
, type
, cleared
,
4726 get_alias_set (TREE_TYPE (field
)));
4729 else if (TREE_CODE (type
) == ARRAY_TYPE
4730 || TREE_CODE (type
) == VECTOR_TYPE
)
4735 tree domain
= TYPE_DOMAIN (type
);
4736 tree elttype
= TREE_TYPE (type
);
4738 HOST_WIDE_INT minelt
= 0;
4739 HOST_WIDE_INT maxelt
= 0;
4743 unsigned n_elts
= 0;
4745 /* Vectors are like arrays, but the domain is stored via an array
4747 if (TREE_CODE (type
) == VECTOR_TYPE
)
4749 /* Note that although TYPE_DEBUG_REPRESENTATION_TYPE uses
4750 the same field as TYPE_DOMAIN, we are not guaranteed that
4752 domain
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
4753 domain
= TYPE_DOMAIN (TREE_TYPE (TYPE_FIELDS (domain
)));
4754 if (REG_P (target
) && VECTOR_MODE_P (GET_MODE (target
)))
4756 enum machine_mode mode
= GET_MODE (target
);
4758 icode
= (int) vec_init_optab
->handlers
[mode
].insn_code
;
4759 if (icode
!= CODE_FOR_nothing
)
4763 elt_size
= GET_MODE_SIZE (GET_MODE_INNER (mode
));
4764 n_elts
= (GET_MODE_SIZE (mode
) / elt_size
);
4765 vector
= alloca (n_elts
);
4766 for (i
= 0; i
< n_elts
; i
++)
4767 vector
[i
] = CONST0_RTX (GET_MODE_INNER (mode
));
4772 const_bounds_p
= (TYPE_MIN_VALUE (domain
)
4773 && TYPE_MAX_VALUE (domain
)
4774 && host_integerp (TYPE_MIN_VALUE (domain
), 0)
4775 && host_integerp (TYPE_MAX_VALUE (domain
), 0));
4777 /* If we have constant bounds for the range of the type, get them. */
4780 minelt
= tree_low_cst (TYPE_MIN_VALUE (domain
), 0);
4781 maxelt
= tree_low_cst (TYPE_MAX_VALUE (domain
), 0);
4784 /* If the constructor has fewer elements than the array,
4785 clear the whole array first. Similarly if this is
4786 static constructor of a non-BLKmode object. */
4787 if (cleared
|| (GET_CODE (target
) == REG
&& TREE_STATIC (exp
)))
4791 HOST_WIDE_INT count
= 0, zero_count
= 0;
4792 need_to_clear
= ! const_bounds_p
;
4794 /* This loop is a more accurate version of the loop in
4795 mostly_zeros_p (it handles RANGE_EXPR in an index).
4796 It is also needed to check for missing elements. */
4797 for (elt
= CONSTRUCTOR_ELTS (exp
);
4798 elt
!= NULL_TREE
&& ! need_to_clear
;
4799 elt
= TREE_CHAIN (elt
))
4801 tree index
= TREE_PURPOSE (elt
);
4802 HOST_WIDE_INT this_node_count
;
4804 if (index
!= NULL_TREE
&& TREE_CODE (index
) == RANGE_EXPR
)
4806 tree lo_index
= TREE_OPERAND (index
, 0);
4807 tree hi_index
= TREE_OPERAND (index
, 1);
4809 if (! host_integerp (lo_index
, 1)
4810 || ! host_integerp (hi_index
, 1))
4816 this_node_count
= (tree_low_cst (hi_index
, 1)
4817 - tree_low_cst (lo_index
, 1) + 1);
4820 this_node_count
= 1;
4822 count
+= this_node_count
;
4823 if (mostly_zeros_p (TREE_VALUE (elt
)))
4824 zero_count
+= this_node_count
;
4827 /* Clear the entire array first if there are any missing elements,
4828 or if the incidence of zero elements is >= 75%. */
4830 && (count
< maxelt
- minelt
+ 1 || 4 * zero_count
>= 3 * count
))
4834 if (need_to_clear
&& size
> 0 && !vector
)
4839 emit_move_insn (target
, CONST0_RTX (GET_MODE (target
)));
4842 rtx xtarget
= target
;
4844 if (RTX_UNCHANGING_P (target
))
4846 xtarget
= copy_rtx (target
);
4847 RTX_UNCHANGING_P (xtarget
) = 0;
4850 clear_storage (xtarget
, GEN_INT (size
));
4852 if (RTX_UNCHANGING_P (target
))
4854 /* ??? Emit a blockage to prevent the scheduler from
4855 swapping the memory write issued above without the
4856 /u flag and memory writes that will be issued later
4858 emit_insn (gen_rtx_ASM_INPUT (VOIDmode
, ""));
4864 else if (REG_P (target
))
4865 /* Inform later passes that the old value is dead. */
4866 emit_insn (gen_rtx_CLOBBER (VOIDmode
, target
));
4868 /* Store each element of the constructor into
4869 the corresponding element of TARGET, determined
4870 by counting the elements. */
4871 for (elt
= CONSTRUCTOR_ELTS (exp
), i
= 0;
4873 elt
= TREE_CHAIN (elt
), i
++)
4875 enum machine_mode mode
;
4876 HOST_WIDE_INT bitsize
;
4877 HOST_WIDE_INT bitpos
;
4879 tree value
= TREE_VALUE (elt
);
4880 tree index
= TREE_PURPOSE (elt
);
4881 rtx xtarget
= target
;
4883 if (cleared
&& is_zeros_p (value
))
4886 unsignedp
= TREE_UNSIGNED (elttype
);
4887 mode
= TYPE_MODE (elttype
);
4888 if (mode
== BLKmode
)
4889 bitsize
= (host_integerp (TYPE_SIZE (elttype
), 1)
4890 ? tree_low_cst (TYPE_SIZE (elttype
), 1)
4893 bitsize
= GET_MODE_BITSIZE (mode
);
4895 if (index
!= NULL_TREE
&& TREE_CODE (index
) == RANGE_EXPR
)
4897 tree lo_index
= TREE_OPERAND (index
, 0);
4898 tree hi_index
= TREE_OPERAND (index
, 1);
4899 rtx index_r
, pos_rtx
, loop_end
;
4900 struct nesting
*loop
;
4901 HOST_WIDE_INT lo
, hi
, count
;
4907 /* If the range is constant and "small", unroll the loop. */
4909 && host_integerp (lo_index
, 0)
4910 && host_integerp (hi_index
, 0)
4911 && (lo
= tree_low_cst (lo_index
, 0),
4912 hi
= tree_low_cst (hi_index
, 0),
4913 count
= hi
- lo
+ 1,
4914 (GET_CODE (target
) != MEM
4916 || (host_integerp (TYPE_SIZE (elttype
), 1)
4917 && (tree_low_cst (TYPE_SIZE (elttype
), 1) * count
4920 lo
-= minelt
; hi
-= minelt
;
4921 for (; lo
<= hi
; lo
++)
4923 bitpos
= lo
* tree_low_cst (TYPE_SIZE (elttype
), 0);
4925 if (GET_CODE (target
) == MEM
4926 && !MEM_KEEP_ALIAS_SET_P (target
)
4927 && TREE_CODE (type
) == ARRAY_TYPE
4928 && TYPE_NONALIASED_COMPONENT (type
))
4930 target
= copy_rtx (target
);
4931 MEM_KEEP_ALIAS_SET_P (target
) = 1;
4934 store_constructor_field
4935 (target
, bitsize
, bitpos
, mode
, value
, type
, cleared
,
4936 get_alias_set (elttype
));
4941 expand_expr (hi_index
, NULL_RTX
, VOIDmode
, 0);
4942 loop_end
= gen_label_rtx ();
4944 unsignedp
= TREE_UNSIGNED (domain
);
4946 index
= build_decl (VAR_DECL
, NULL_TREE
, domain
);
4949 = gen_reg_rtx (promote_mode (domain
, DECL_MODE (index
),
4951 SET_DECL_RTL (index
, index_r
);
4952 if (TREE_CODE (value
) == SAVE_EXPR
4953 && SAVE_EXPR_RTL (value
) == 0)
4955 /* Make sure value gets expanded once before the
4957 expand_expr (value
, const0_rtx
, VOIDmode
, 0);
4960 store_expr (lo_index
, index_r
, 0);
4961 loop
= expand_start_loop (0);
4963 /* Assign value to element index. */
4965 = convert (ssizetype
,
4966 fold (build (MINUS_EXPR
, TREE_TYPE (index
),
4967 index
, TYPE_MIN_VALUE (domain
))));
4968 position
= size_binop (MULT_EXPR
, position
,
4970 TYPE_SIZE_UNIT (elttype
)));
4972 pos_rtx
= expand_expr (position
, 0, VOIDmode
, 0);
4973 xtarget
= offset_address (target
, pos_rtx
,
4974 highest_pow2_factor (position
));
4975 xtarget
= adjust_address (xtarget
, mode
, 0);
4976 if (TREE_CODE (value
) == CONSTRUCTOR
)
4977 store_constructor (value
, xtarget
, cleared
,
4978 bitsize
/ BITS_PER_UNIT
);
4980 store_expr (value
, xtarget
, 0);
4982 expand_exit_loop_if_false (loop
,
4983 build (LT_EXPR
, integer_type_node
,
4986 expand_increment (build (PREINCREMENT_EXPR
,
4988 index
, integer_one_node
), 0, 0);
4990 emit_label (loop_end
);
4993 else if ((index
!= 0 && ! host_integerp (index
, 0))
4994 || ! host_integerp (TYPE_SIZE (elttype
), 1))
5002 index
= ssize_int (1);
5005 index
= convert (ssizetype
,
5006 fold (build (MINUS_EXPR
, index
,
5007 TYPE_MIN_VALUE (domain
))));
5009 position
= size_binop (MULT_EXPR
, index
,
5011 TYPE_SIZE_UNIT (elttype
)));
5012 xtarget
= offset_address (target
,
5013 expand_expr (position
, 0, VOIDmode
, 0),
5014 highest_pow2_factor (position
));
5015 xtarget
= adjust_address (xtarget
, mode
, 0);
5016 store_expr (value
, xtarget
, 0);
5023 pos
= tree_low_cst (index
, 0) - minelt
;
5026 vector
[pos
] = expand_expr (value
, NULL_RTX
, VOIDmode
, 0);
5031 bitpos
= ((tree_low_cst (index
, 0) - minelt
)
5032 * tree_low_cst (TYPE_SIZE (elttype
), 1));
5034 bitpos
= (i
* tree_low_cst (TYPE_SIZE (elttype
), 1));
5036 if (GET_CODE (target
) == MEM
&& !MEM_KEEP_ALIAS_SET_P (target
)
5037 && TREE_CODE (type
) == ARRAY_TYPE
5038 && TYPE_NONALIASED_COMPONENT (type
))
5040 target
= copy_rtx (target
);
5041 MEM_KEEP_ALIAS_SET_P (target
) = 1;
5043 store_constructor_field (target
, bitsize
, bitpos
, mode
, value
,
5044 type
, cleared
, get_alias_set (elttype
));
5049 emit_insn (GEN_FCN (icode
) (target
,
5050 gen_rtx_PARALLEL (GET_MODE (target
),
5051 gen_rtvec_v (n_elts
, vector
))));
5055 /* Set constructor assignments. */
5056 else if (TREE_CODE (type
) == SET_TYPE
)
5058 tree elt
= CONSTRUCTOR_ELTS (exp
);
5059 unsigned HOST_WIDE_INT nbytes
= int_size_in_bytes (type
), nbits
;
5060 tree domain
= TYPE_DOMAIN (type
);
5061 tree domain_min
, domain_max
, bitlength
;
5063 /* The default implementation strategy is to extract the constant
5064 parts of the constructor, use that to initialize the target,
5065 and then "or" in whatever non-constant ranges we need in addition.
5067 If a large set is all zero or all ones, it is
5068 probably better to set it using memset (if available) or bzero.
5069 Also, if a large set has just a single range, it may also be
5070 better to first clear all the first clear the set (using
5071 bzero/memset), and set the bits we want. */
5073 /* Check for all zeros. */
5074 if (elt
== NULL_TREE
&& size
> 0)
5077 clear_storage (target
, GEN_INT (size
));
5081 domain_min
= convert (sizetype
, TYPE_MIN_VALUE (domain
));
5082 domain_max
= convert (sizetype
, TYPE_MAX_VALUE (domain
));
5083 bitlength
= size_binop (PLUS_EXPR
,
5084 size_diffop (domain_max
, domain_min
),
5087 nbits
= tree_low_cst (bitlength
, 1);
5089 /* For "small" sets, or "medium-sized" (up to 32 bytes) sets that
5090 are "complicated" (more than one range), initialize (the
5091 constant parts) by copying from a constant. */
5092 if (GET_MODE (target
) != BLKmode
|| nbits
<= 2 * BITS_PER_WORD
5093 || (nbytes
<= 32 && TREE_CHAIN (elt
) != NULL_TREE
))
5095 unsigned int set_word_size
= TYPE_ALIGN (TREE_TYPE (exp
));
5096 enum machine_mode mode
= mode_for_size (set_word_size
, MODE_INT
, 1);
5097 char *bit_buffer
= alloca (nbits
);
5098 HOST_WIDE_INT word
= 0;
5099 unsigned int bit_pos
= 0;
5100 unsigned int ibit
= 0;
5101 unsigned int offset
= 0; /* In bytes from beginning of set. */
5103 elt
= get_set_constructor_bits (exp
, bit_buffer
, nbits
);
5106 if (bit_buffer
[ibit
])
5108 if (BYTES_BIG_ENDIAN
)
5109 word
|= (1 << (set_word_size
- 1 - bit_pos
));
5111 word
|= 1 << bit_pos
;
5115 if (bit_pos
>= set_word_size
|| ibit
== nbits
)
5117 if (word
!= 0 || ! cleared
)
5119 rtx datum
= gen_int_mode (word
, mode
);
5122 /* The assumption here is that it is safe to use
5123 XEXP if the set is multi-word, but not if
5124 it's single-word. */
5125 if (GET_CODE (target
) == MEM
)
5126 to_rtx
= adjust_address (target
, mode
, offset
);
5127 else if (offset
== 0)
5131 emit_move_insn (to_rtx
, datum
);
5138 offset
+= set_word_size
/ BITS_PER_UNIT
;
5143 /* Don't bother clearing storage if the set is all ones. */
5144 if (TREE_CHAIN (elt
) != NULL_TREE
5145 || (TREE_PURPOSE (elt
) == NULL_TREE
5147 : ( ! host_integerp (TREE_VALUE (elt
), 0)
5148 || ! host_integerp (TREE_PURPOSE (elt
), 0)
5149 || (tree_low_cst (TREE_VALUE (elt
), 0)
5150 - tree_low_cst (TREE_PURPOSE (elt
), 0) + 1
5151 != (HOST_WIDE_INT
) nbits
))))
5152 clear_storage (target
, expr_size (exp
));
5154 for (; elt
!= NULL_TREE
; elt
= TREE_CHAIN (elt
))
5156 /* Start of range of element or NULL. */
5157 tree startbit
= TREE_PURPOSE (elt
);
5158 /* End of range of element, or element value. */
5159 tree endbit
= TREE_VALUE (elt
);
5160 HOST_WIDE_INT startb
, endb
;
5161 rtx bitlength_rtx
, startbit_rtx
, endbit_rtx
, targetx
;
5163 bitlength_rtx
= expand_expr (bitlength
,
5164 NULL_RTX
, MEM
, EXPAND_CONST_ADDRESS
);
5166 /* Handle non-range tuple element like [ expr ]. */
5167 if (startbit
== NULL_TREE
)
5169 startbit
= save_expr (endbit
);
5173 startbit
= convert (sizetype
, startbit
);
5174 endbit
= convert (sizetype
, endbit
);
5175 if (! integer_zerop (domain_min
))
5177 startbit
= size_binop (MINUS_EXPR
, startbit
, domain_min
);
5178 endbit
= size_binop (MINUS_EXPR
, endbit
, domain_min
);
5180 startbit_rtx
= expand_expr (startbit
, NULL_RTX
, MEM
,
5181 EXPAND_CONST_ADDRESS
);
5182 endbit_rtx
= expand_expr (endbit
, NULL_RTX
, MEM
,
5183 EXPAND_CONST_ADDRESS
);
5189 ((build_qualified_type ((*lang_hooks
.types
.type_for_mode
)
5190 (GET_MODE (target
), 0),
5193 emit_move_insn (targetx
, target
);
5196 else if (GET_CODE (target
) == MEM
)
5201 /* Optimization: If startbit and endbit are constants divisible
5202 by BITS_PER_UNIT, call memset instead. */
5203 if (TARGET_MEM_FUNCTIONS
5204 && TREE_CODE (startbit
) == INTEGER_CST
5205 && TREE_CODE (endbit
) == INTEGER_CST
5206 && (startb
= TREE_INT_CST_LOW (startbit
)) % BITS_PER_UNIT
== 0
5207 && (endb
= TREE_INT_CST_LOW (endbit
) + 1) % BITS_PER_UNIT
== 0)
5209 emit_library_call (memset_libfunc
, LCT_NORMAL
,
5211 plus_constant (XEXP (targetx
, 0),
5212 startb
/ BITS_PER_UNIT
),
5214 constm1_rtx
, TYPE_MODE (integer_type_node
),
5215 GEN_INT ((endb
- startb
) / BITS_PER_UNIT
),
5216 TYPE_MODE (sizetype
));
5219 emit_library_call (setbits_libfunc
, LCT_NORMAL
,
5220 VOIDmode
, 4, XEXP (targetx
, 0),
5221 Pmode
, bitlength_rtx
, TYPE_MODE (sizetype
),
5222 startbit_rtx
, TYPE_MODE (sizetype
),
5223 endbit_rtx
, TYPE_MODE (sizetype
));
5226 emit_move_insn (target
, targetx
);
5234 /* Store the value of EXP (an expression tree)
5235 into a subfield of TARGET which has mode MODE and occupies
5236 BITSIZE bits, starting BITPOS bits from the start of TARGET.
5237 If MODE is VOIDmode, it means that we are storing into a bit-field.
5239 If VALUE_MODE is VOIDmode, return nothing in particular.
5240 UNSIGNEDP is not used in this case.
5242 Otherwise, return an rtx for the value stored. This rtx
5243 has mode VALUE_MODE if that is convenient to do.
5244 In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
5246 TYPE is the type of the underlying object,
5248 ALIAS_SET is the alias set for the destination. This value will
5249 (in general) be different from that for TARGET, since TARGET is a
5250 reference to the containing structure. */
5253 store_field (rtx target
, HOST_WIDE_INT bitsize
, HOST_WIDE_INT bitpos
,
5254 enum machine_mode mode
, tree exp
, enum machine_mode value_mode
,
5255 int unsignedp
, tree type
, int alias_set
)
5257 HOST_WIDE_INT width_mask
= 0;
5259 if (TREE_CODE (exp
) == ERROR_MARK
)
5262 /* If we have nothing to store, do nothing unless the expression has
5265 return expand_expr (exp
, const0_rtx
, VOIDmode
, 0);
5266 else if (bitsize
>= 0 && bitsize
< HOST_BITS_PER_WIDE_INT
)
5267 width_mask
= ((HOST_WIDE_INT
) 1 << bitsize
) - 1;
5269 /* If we are storing into an unaligned field of an aligned union that is
5270 in a register, we may have the mode of TARGET being an integer mode but
5271 MODE == BLKmode. In that case, get an aligned object whose size and
5272 alignment are the same as TARGET and store TARGET into it (we can avoid
5273 the store if the field being stored is the entire width of TARGET). Then
5274 call ourselves recursively to store the field into a BLKmode version of
5275 that object. Finally, load from the object into TARGET. This is not
5276 very efficient in general, but should only be slightly more expensive
5277 than the otherwise-required unaligned accesses. Perhaps this can be
5278 cleaned up later. It's tempting to make OBJECT readonly, but it's set
5279 twice, once with emit_move_insn and once via store_field. */
5282 && (GET_CODE (target
) == REG
|| GET_CODE (target
) == SUBREG
))
5284 rtx object
= assign_temp (type
, 0, 1, 1);
5285 rtx blk_object
= adjust_address (object
, BLKmode
, 0);
5287 if (bitsize
!= (HOST_WIDE_INT
) GET_MODE_BITSIZE (GET_MODE (target
)))
5288 emit_move_insn (object
, target
);
5290 store_field (blk_object
, bitsize
, bitpos
, mode
, exp
, VOIDmode
, 0, type
,
5293 emit_move_insn (target
, object
);
5295 /* We want to return the BLKmode version of the data. */
5299 if (GET_CODE (target
) == CONCAT
)
5301 /* We're storing into a struct containing a single __complex. */
5305 return store_expr (exp
, target
, 0);
5308 /* If the structure is in a register or if the component
5309 is a bit field, we cannot use addressing to access it.
5310 Use bit-field techniques or SUBREG to store in it. */
5312 if (mode
== VOIDmode
5313 || (mode
!= BLKmode
&& ! direct_store
[(int) mode
]
5314 && GET_MODE_CLASS (mode
) != MODE_COMPLEX_INT
5315 && GET_MODE_CLASS (mode
) != MODE_COMPLEX_FLOAT
)
5316 || GET_CODE (target
) == REG
5317 || GET_CODE (target
) == SUBREG
5318 /* If the field isn't aligned enough to store as an ordinary memref,
5319 store it as a bit field. */
5321 && ((((MEM_ALIGN (target
) < GET_MODE_ALIGNMENT (mode
))
5322 || bitpos
% GET_MODE_ALIGNMENT (mode
))
5323 && SLOW_UNALIGNED_ACCESS (mode
, MEM_ALIGN (target
)))
5324 || (bitpos
% BITS_PER_UNIT
!= 0)))
5325 /* If the RHS and field are a constant size and the size of the
5326 RHS isn't the same size as the bitfield, we must use bitfield
5329 && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp
))) == INTEGER_CST
5330 && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp
)), bitsize
) != 0))
5332 rtx temp
= expand_expr (exp
, NULL_RTX
, VOIDmode
, 0);
5334 /* If BITSIZE is narrower than the size of the type of EXP
5335 we will be narrowing TEMP. Normally, what's wanted are the
5336 low-order bits. However, if EXP's type is a record and this is
5337 big-endian machine, we want the upper BITSIZE bits. */
5338 if (BYTES_BIG_ENDIAN
&& GET_MODE_CLASS (GET_MODE (temp
)) == MODE_INT
5339 && bitsize
< (HOST_WIDE_INT
) GET_MODE_BITSIZE (GET_MODE (temp
))
5340 && TREE_CODE (TREE_TYPE (exp
)) == RECORD_TYPE
)
5341 temp
= expand_shift (RSHIFT_EXPR
, GET_MODE (temp
), temp
,
5342 size_int (GET_MODE_BITSIZE (GET_MODE (temp
))
5346 /* Unless MODE is VOIDmode or BLKmode, convert TEMP to
5348 if (mode
!= VOIDmode
&& mode
!= BLKmode
5349 && mode
!= TYPE_MODE (TREE_TYPE (exp
)))
5350 temp
= convert_modes (mode
, TYPE_MODE (TREE_TYPE (exp
)), temp
, 1);
5352 /* If the modes of TARGET and TEMP are both BLKmode, both
5353 must be in memory and BITPOS must be aligned on a byte
5354 boundary. If so, we simply do a block copy. */
5355 if (GET_MODE (target
) == BLKmode
&& GET_MODE (temp
) == BLKmode
)
5357 if (GET_CODE (target
) != MEM
|| GET_CODE (temp
) != MEM
5358 || bitpos
% BITS_PER_UNIT
!= 0)
5361 target
= adjust_address (target
, VOIDmode
, bitpos
/ BITS_PER_UNIT
);
5362 emit_block_move (target
, temp
,
5363 GEN_INT ((bitsize
+ BITS_PER_UNIT
- 1)
5367 return value_mode
== VOIDmode
? const0_rtx
: target
;
5370 /* Store the value in the bitfield. */
5371 store_bit_field (target
, bitsize
, bitpos
, mode
, temp
,
5372 int_size_in_bytes (type
));
5374 if (value_mode
!= VOIDmode
)
5376 /* The caller wants an rtx for the value.
5377 If possible, avoid refetching from the bitfield itself. */
5379 && ! (GET_CODE (target
) == MEM
&& MEM_VOLATILE_P (target
)))
5382 enum machine_mode tmode
;
5384 tmode
= GET_MODE (temp
);
5385 if (tmode
== VOIDmode
)
5389 return expand_and (tmode
, temp
,
5390 gen_int_mode (width_mask
, tmode
),
5393 count
= build_int_2 (GET_MODE_BITSIZE (tmode
) - bitsize
, 0);
5394 temp
= expand_shift (LSHIFT_EXPR
, tmode
, temp
, count
, 0, 0);
5395 return expand_shift (RSHIFT_EXPR
, tmode
, temp
, count
, 0, 0);
5398 return extract_bit_field (target
, bitsize
, bitpos
, unsignedp
,
5399 NULL_RTX
, value_mode
, VOIDmode
,
5400 int_size_in_bytes (type
));
5406 rtx addr
= XEXP (target
, 0);
5407 rtx to_rtx
= target
;
5409 /* If a value is wanted, it must be the lhs;
5410 so make the address stable for multiple use. */
5412 if (value_mode
!= VOIDmode
&& GET_CODE (addr
) != REG
5413 && ! CONSTANT_ADDRESS_P (addr
)
5414 /* A frame-pointer reference is already stable. */
5415 && ! (GET_CODE (addr
) == PLUS
5416 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
5417 && (XEXP (addr
, 0) == virtual_incoming_args_rtx
5418 || XEXP (addr
, 0) == virtual_stack_vars_rtx
)))
5419 to_rtx
= replace_equiv_address (to_rtx
, copy_to_reg (addr
));
5421 /* Now build a reference to just the desired component. */
5423 to_rtx
= adjust_address (target
, mode
, bitpos
/ BITS_PER_UNIT
);
5425 if (to_rtx
== target
)
5426 to_rtx
= copy_rtx (to_rtx
);
5428 MEM_SET_IN_STRUCT_P (to_rtx
, 1);
5429 if (!MEM_KEEP_ALIAS_SET_P (to_rtx
) && MEM_ALIAS_SET (to_rtx
) != 0)
5430 set_mem_alias_set (to_rtx
, alias_set
);
5432 return store_expr (exp
, to_rtx
, value_mode
!= VOIDmode
);
5436 /* Given an expression EXP that may be a COMPONENT_REF, a BIT_FIELD_REF,
5437 an ARRAY_REF, or an ARRAY_RANGE_REF, look for nested operations of these
5438 codes and find the ultimate containing object, which we return.
5440 We set *PBITSIZE to the size in bits that we want, *PBITPOS to the
5441 bit position, and *PUNSIGNEDP to the signedness of the field.
5442 If the position of the field is variable, we store a tree
5443 giving the variable offset (in units) in *POFFSET.
5444 This offset is in addition to the bit position.
5445 If the position is not variable, we store 0 in *POFFSET.
5447 If any of the extraction expressions is volatile,
5448 we store 1 in *PVOLATILEP. Otherwise we don't change that.
5450 If the field is a bit-field, *PMODE is set to VOIDmode. Otherwise, it
5451 is a mode that can be used to access the field. In that case, *PBITSIZE
5454 If the field describes a variable-sized object, *PMODE is set to
5455 VOIDmode and *PBITSIZE is set to -1. An access cannot be made in
5456 this case, but the address of the object can be found. */
5459 get_inner_reference (tree exp
, HOST_WIDE_INT
*pbitsize
,
5460 HOST_WIDE_INT
*pbitpos
, tree
*poffset
,
5461 enum machine_mode
*pmode
, int *punsignedp
,
5465 enum machine_mode mode
= VOIDmode
;
5466 tree offset
= size_zero_node
;
5467 tree bit_offset
= bitsize_zero_node
;
5468 tree placeholder_ptr
= 0;
5471 /* First get the mode, signedness, and size. We do this from just the
5472 outermost expression. */
5473 if (TREE_CODE (exp
) == COMPONENT_REF
)
5475 size_tree
= DECL_SIZE (TREE_OPERAND (exp
, 1));
5476 if (! DECL_BIT_FIELD (TREE_OPERAND (exp
, 1)))
5477 mode
= DECL_MODE (TREE_OPERAND (exp
, 1));
5479 *punsignedp
= TREE_UNSIGNED (TREE_OPERAND (exp
, 1));
5481 else if (TREE_CODE (exp
) == BIT_FIELD_REF
)
5483 size_tree
= TREE_OPERAND (exp
, 1);
5484 *punsignedp
= TREE_UNSIGNED (exp
);
5488 mode
= TYPE_MODE (TREE_TYPE (exp
));
5489 *punsignedp
= TREE_UNSIGNED (TREE_TYPE (exp
));
5491 if (mode
== BLKmode
)
5492 size_tree
= TYPE_SIZE (TREE_TYPE (exp
));
5494 *pbitsize
= GET_MODE_BITSIZE (mode
);
5499 if (! host_integerp (size_tree
, 1))
5500 mode
= BLKmode
, *pbitsize
= -1;
5502 *pbitsize
= tree_low_cst (size_tree
, 1);
5505 /* Compute cumulative bit-offset for nested component-refs and array-refs,
5506 and find the ultimate containing object. */
5509 if (TREE_CODE (exp
) == BIT_FIELD_REF
)
5510 bit_offset
= size_binop (PLUS_EXPR
, bit_offset
, TREE_OPERAND (exp
, 2));
5511 else if (TREE_CODE (exp
) == COMPONENT_REF
)
5513 tree field
= TREE_OPERAND (exp
, 1);
5514 tree this_offset
= DECL_FIELD_OFFSET (field
);
5516 /* If this field hasn't been filled in yet, don't go
5517 past it. This should only happen when folding expressions
5518 made during type construction. */
5519 if (this_offset
== 0)
5521 else if (CONTAINS_PLACEHOLDER_P (this_offset
))
5522 this_offset
= build (WITH_RECORD_EXPR
, sizetype
, this_offset
, exp
);
5524 offset
= size_binop (PLUS_EXPR
, offset
, this_offset
);
5525 bit_offset
= size_binop (PLUS_EXPR
, bit_offset
,
5526 DECL_FIELD_BIT_OFFSET (field
));
5528 /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN. */
5531 else if (TREE_CODE (exp
) == ARRAY_REF
5532 || TREE_CODE (exp
) == ARRAY_RANGE_REF
)
5534 tree index
= TREE_OPERAND (exp
, 1);
5535 tree array
= TREE_OPERAND (exp
, 0);
5536 tree domain
= TYPE_DOMAIN (TREE_TYPE (array
));
5537 tree low_bound
= (domain
? TYPE_MIN_VALUE (domain
) : 0);
5538 tree unit_size
= TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (array
)));
5540 /* We assume all arrays have sizes that are a multiple of a byte.
5541 First subtract the lower bound, if any, in the type of the
5542 index, then convert to sizetype and multiply by the size of the
5544 if (low_bound
!= 0 && ! integer_zerop (low_bound
))
5545 index
= fold (build (MINUS_EXPR
, TREE_TYPE (index
),
5548 /* If the index has a self-referential type, pass it to a
5549 WITH_RECORD_EXPR; if the component size is, pass our
5550 component to one. */
5551 if (CONTAINS_PLACEHOLDER_P (index
))
5552 index
= build (WITH_RECORD_EXPR
, TREE_TYPE (index
), index
, exp
);
5553 if (CONTAINS_PLACEHOLDER_P (unit_size
))
5554 unit_size
= build (WITH_RECORD_EXPR
, sizetype
, unit_size
, array
);
5556 offset
= size_binop (PLUS_EXPR
, offset
,
5557 size_binop (MULT_EXPR
,
5558 convert (sizetype
, index
),
5562 else if (TREE_CODE (exp
) == PLACEHOLDER_EXPR
)
5564 tree
new = find_placeholder (exp
, &placeholder_ptr
);
5566 /* If we couldn't find the replacement, return the PLACEHOLDER_EXPR.
5567 We might have been called from tree optimization where we
5568 haven't set up an object yet. */
5577 /* We can go inside most conversions: all NON_VALUE_EXPRs, all normal
5578 conversions that don't change the mode, and all view conversions
5579 except those that need to "step up" the alignment. */
5580 else if (TREE_CODE (exp
) != NON_LVALUE_EXPR
5581 && ! (TREE_CODE (exp
) == VIEW_CONVERT_EXPR
5582 && ! ((TYPE_ALIGN (TREE_TYPE (exp
))
5583 > TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp
, 0))))
5585 && (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp
, 0)))
5586 < BIGGEST_ALIGNMENT
)
5587 && (TYPE_ALIGN_OK (TREE_TYPE (exp
))
5588 || TYPE_ALIGN_OK (TREE_TYPE
5589 (TREE_OPERAND (exp
, 0))))))
5590 && ! ((TREE_CODE (exp
) == NOP_EXPR
5591 || TREE_CODE (exp
) == CONVERT_EXPR
)
5592 && (TYPE_MODE (TREE_TYPE (exp
))
5593 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0))))))
5596 /* If any reference in the chain is volatile, the effect is volatile. */
5597 if (TREE_THIS_VOLATILE (exp
))
5600 exp
= TREE_OPERAND (exp
, 0);
5603 /* If OFFSET is constant, see if we can return the whole thing as a
5604 constant bit position. Otherwise, split it up. */
5605 if (host_integerp (offset
, 0)
5606 && 0 != (tem
= size_binop (MULT_EXPR
, convert (bitsizetype
, offset
),
5608 && 0 != (tem
= size_binop (PLUS_EXPR
, tem
, bit_offset
))
5609 && host_integerp (tem
, 0))
5610 *pbitpos
= tree_low_cst (tem
, 0), *poffset
= 0;
5612 *pbitpos
= tree_low_cst (bit_offset
, 0), *poffset
= offset
;
5618 /* Return 1 if T is an expression that get_inner_reference handles. */
5621 handled_component_p (tree t
)
5623 switch (TREE_CODE (t
))
5628 case ARRAY_RANGE_REF
:
5629 case NON_LVALUE_EXPR
:
5630 case VIEW_CONVERT_EXPR
:
5633 /* ??? Sure they are handled, but get_inner_reference may return
5634 a different PBITSIZE, depending upon whether the expression is
5635 wrapped up in a NOP_EXPR or not, e.g. for bitfields. */
5638 return (TYPE_MODE (TREE_TYPE (t
))
5639 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (t
, 0))));
5646 /* Given an rtx VALUE that may contain additions and multiplications, return
5647 an equivalent value that just refers to a register, memory, or constant.
5648 This is done by generating instructions to perform the arithmetic and
5649 returning a pseudo-register containing the value.
5651 The returned value may be a REG, SUBREG, MEM or constant. */
5654 force_operand (rtx value
, rtx target
)
5657 /* Use subtarget as the target for operand 0 of a binary operation. */
5658 rtx subtarget
= get_subtarget (target
);
5659 enum rtx_code code
= GET_CODE (value
);
5661 /* Check for a PIC address load. */
5662 if ((code
== PLUS
|| code
== MINUS
)
5663 && XEXP (value
, 0) == pic_offset_table_rtx
5664 && (GET_CODE (XEXP (value
, 1)) == SYMBOL_REF
5665 || GET_CODE (XEXP (value
, 1)) == LABEL_REF
5666 || GET_CODE (XEXP (value
, 1)) == CONST
))
5669 subtarget
= gen_reg_rtx (GET_MODE (value
));
5670 emit_move_insn (subtarget
, value
);
5674 if (code
== ZERO_EXTEND
|| code
== SIGN_EXTEND
)
5677 target
= gen_reg_rtx (GET_MODE (value
));
5678 convert_move (target
, force_operand (XEXP (value
, 0), NULL
),
5679 code
== ZERO_EXTEND
);
5683 if (GET_RTX_CLASS (code
) == '2' || GET_RTX_CLASS (code
) == 'c')
5685 op2
= XEXP (value
, 1);
5686 if (!CONSTANT_P (op2
) && !(GET_CODE (op2
) == REG
&& op2
!= subtarget
))
5688 if (code
== MINUS
&& GET_CODE (op2
) == CONST_INT
)
5691 op2
= negate_rtx (GET_MODE (value
), op2
);
5694 /* Check for an addition with OP2 a constant integer and our first
5695 operand a PLUS of a virtual register and something else. In that
5696 case, we want to emit the sum of the virtual register and the
5697 constant first and then add the other value. This allows virtual
5698 register instantiation to simply modify the constant rather than
5699 creating another one around this addition. */
5700 if (code
== PLUS
&& GET_CODE (op2
) == CONST_INT
5701 && GET_CODE (XEXP (value
, 0)) == PLUS
5702 && GET_CODE (XEXP (XEXP (value
, 0), 0)) == REG
5703 && REGNO (XEXP (XEXP (value
, 0), 0)) >= FIRST_VIRTUAL_REGISTER
5704 && REGNO (XEXP (XEXP (value
, 0), 0)) <= LAST_VIRTUAL_REGISTER
)
5706 rtx temp
= expand_simple_binop (GET_MODE (value
), code
,
5707 XEXP (XEXP (value
, 0), 0), op2
,
5708 subtarget
, 0, OPTAB_LIB_WIDEN
);
5709 return expand_simple_binop (GET_MODE (value
), code
, temp
,
5710 force_operand (XEXP (XEXP (value
,
5712 target
, 0, OPTAB_LIB_WIDEN
);
5715 op1
= force_operand (XEXP (value
, 0), subtarget
);
5716 op2
= force_operand (op2
, NULL_RTX
);
5720 return expand_mult (GET_MODE (value
), op1
, op2
, target
, 1);
5722 if (!INTEGRAL_MODE_P (GET_MODE (value
)))
5723 return expand_simple_binop (GET_MODE (value
), code
, op1
, op2
,
5724 target
, 1, OPTAB_LIB_WIDEN
);
5726 return expand_divmod (0,
5727 FLOAT_MODE_P (GET_MODE (value
))
5728 ? RDIV_EXPR
: TRUNC_DIV_EXPR
,
5729 GET_MODE (value
), op1
, op2
, target
, 0);
5732 return expand_divmod (1, TRUNC_MOD_EXPR
, GET_MODE (value
), op1
, op2
,
5736 return expand_divmod (0, TRUNC_DIV_EXPR
, GET_MODE (value
), op1
, op2
,
5740 return expand_divmod (1, TRUNC_MOD_EXPR
, GET_MODE (value
), op1
, op2
,
5744 return expand_simple_binop (GET_MODE (value
), code
, op1
, op2
,
5745 target
, 0, OPTAB_LIB_WIDEN
);
5748 return expand_simple_binop (GET_MODE (value
), code
, op1
, op2
,
5749 target
, 1, OPTAB_LIB_WIDEN
);
5752 if (GET_RTX_CLASS (code
) == '1')
5754 op1
= force_operand (XEXP (value
, 0), NULL_RTX
);
5755 return expand_simple_unop (GET_MODE (value
), code
, op1
, target
, 0);
5758 #ifdef INSN_SCHEDULING
5759 /* On machines that have insn scheduling, we want all memory reference to be
5760 explicit, so we need to deal with such paradoxical SUBREGs. */
5761 if (GET_CODE (value
) == SUBREG
&& GET_CODE (SUBREG_REG (value
)) == MEM
5762 && (GET_MODE_SIZE (GET_MODE (value
))
5763 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (value
)))))
5765 = simplify_gen_subreg (GET_MODE (value
),
5766 force_reg (GET_MODE (SUBREG_REG (value
)),
5767 force_operand (SUBREG_REG (value
),
5769 GET_MODE (SUBREG_REG (value
)),
5770 SUBREG_BYTE (value
));
5776 /* Subroutine of expand_expr: return nonzero iff there is no way that
5777 EXP can reference X, which is being modified. TOP_P is nonzero if this
5778 call is going to be used to determine whether we need a temporary
5779 for EXP, as opposed to a recursive call to this function.
5781 It is always safe for this routine to return zero since it merely
5782 searches for optimization opportunities. */
5785 safe_from_p (rtx x
, tree exp
, int top_p
)
5789 static tree save_expr_list
;
5792 /* If EXP has varying size, we MUST use a target since we currently
5793 have no way of allocating temporaries of variable size
5794 (except for arrays that have TYPE_ARRAY_MAX_SIZE set).
5795 So we assume here that something at a higher level has prevented a
5796 clash. This is somewhat bogus, but the best we can do. Only
5797 do this when X is BLKmode and when we are at the top level. */
5798 || (top_p
&& TREE_TYPE (exp
) != 0 && COMPLETE_TYPE_P (TREE_TYPE (exp
))
5799 && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp
))) != INTEGER_CST
5800 && (TREE_CODE (TREE_TYPE (exp
)) != ARRAY_TYPE
5801 || TYPE_ARRAY_MAX_SIZE (TREE_TYPE (exp
)) == NULL_TREE
5802 || TREE_CODE (TYPE_ARRAY_MAX_SIZE (TREE_TYPE (exp
)))
5804 && GET_MODE (x
) == BLKmode
)
5805 /* If X is in the outgoing argument area, it is always safe. */
5806 || (GET_CODE (x
) == MEM
5807 && (XEXP (x
, 0) == virtual_outgoing_args_rtx
5808 || (GET_CODE (XEXP (x
, 0)) == PLUS
5809 && XEXP (XEXP (x
, 0), 0) == virtual_outgoing_args_rtx
))))
5812 /* If this is a subreg of a hard register, declare it unsafe, otherwise,
5813 find the underlying pseudo. */
5814 if (GET_CODE (x
) == SUBREG
)
5817 if (GET_CODE (x
) == REG
&& REGNO (x
) < FIRST_PSEUDO_REGISTER
)
5821 /* A SAVE_EXPR might appear many times in the expression passed to the
5822 top-level safe_from_p call, and if it has a complex subexpression,
5823 examining it multiple times could result in a combinatorial explosion.
5824 E.g. on an Alpha running at least 200MHz, a Fortran testcase compiled
5825 with optimization took about 28 minutes to compile -- even though it was
5826 only a few lines long. So we mark each SAVE_EXPR we see with TREE_PRIVATE
5827 and turn that off when we are done. We keep a list of the SAVE_EXPRs
5828 we have processed. Note that the only test of top_p was above. */
5837 rtn
= safe_from_p (x
, exp
, 0);
5839 for (t
= save_expr_list
; t
!= 0; t
= TREE_CHAIN (t
))
5840 TREE_PRIVATE (TREE_PURPOSE (t
)) = 0;
5845 /* Now look at our tree code and possibly recurse. */
5846 switch (TREE_CODE_CLASS (TREE_CODE (exp
)))
5849 exp_rtl
= DECL_RTL_IF_SET (exp
);
5856 if (TREE_CODE (exp
) == TREE_LIST
)
5860 if (TREE_VALUE (exp
) && !safe_from_p (x
, TREE_VALUE (exp
), 0))
5862 exp
= TREE_CHAIN (exp
);
5865 if (TREE_CODE (exp
) != TREE_LIST
)
5866 return safe_from_p (x
, exp
, 0);
5869 else if (TREE_CODE (exp
) == ERROR_MARK
)
5870 return 1; /* An already-visited SAVE_EXPR? */
5876 if (!safe_from_p (x
, TREE_OPERAND (exp
, 1), 0))
5881 return safe_from_p (x
, TREE_OPERAND (exp
, 0), 0);
5885 /* Now do code-specific tests. EXP_RTL is set to any rtx we find in
5886 the expression. If it is set, we conflict iff we are that rtx or
5887 both are in memory. Otherwise, we check all operands of the
5888 expression recursively. */
5890 switch (TREE_CODE (exp
))
5893 /* If the operand is static or we are static, we can't conflict.
5894 Likewise if we don't conflict with the operand at all. */
5895 if (staticp (TREE_OPERAND (exp
, 0))
5896 || TREE_STATIC (exp
)
5897 || safe_from_p (x
, TREE_OPERAND (exp
, 0), 0))
5900 /* Otherwise, the only way this can conflict is if we are taking
5901 the address of a DECL a that address if part of X, which is
5903 exp
= TREE_OPERAND (exp
, 0);
5906 if (!DECL_RTL_SET_P (exp
)
5907 || GET_CODE (DECL_RTL (exp
)) != MEM
)
5910 exp_rtl
= XEXP (DECL_RTL (exp
), 0);
5915 if (GET_CODE (x
) == MEM
5916 && alias_sets_conflict_p (MEM_ALIAS_SET (x
),
5917 get_alias_set (exp
)))
5922 /* Assume that the call will clobber all hard registers and
5924 if ((GET_CODE (x
) == REG
&& REGNO (x
) < FIRST_PSEUDO_REGISTER
)
5925 || GET_CODE (x
) == MEM
)
5930 /* If a sequence exists, we would have to scan every instruction
5931 in the sequence to see if it was safe. This is probably not
5933 if (RTL_EXPR_SEQUENCE (exp
))
5936 exp_rtl
= RTL_EXPR_RTL (exp
);
5939 case WITH_CLEANUP_EXPR
:
5940 exp_rtl
= WITH_CLEANUP_EXPR_RTL (exp
);
5943 case CLEANUP_POINT_EXPR
:
5944 return safe_from_p (x
, TREE_OPERAND (exp
, 0), 0);
5947 exp_rtl
= SAVE_EXPR_RTL (exp
);
5951 /* If we've already scanned this, don't do it again. Otherwise,
5952 show we've scanned it and record for clearing the flag if we're
5954 if (TREE_PRIVATE (exp
))
5957 TREE_PRIVATE (exp
) = 1;
5958 if (! safe_from_p (x
, TREE_OPERAND (exp
, 0), 0))
5960 TREE_PRIVATE (exp
) = 0;
5964 save_expr_list
= tree_cons (exp
, NULL_TREE
, save_expr_list
);
5968 /* The only operand we look at is operand 1. The rest aren't
5969 part of the expression. */
5970 return safe_from_p (x
, TREE_OPERAND (exp
, 1), 0);
5976 /* If we have an rtx, we do not need to scan our operands. */
5980 nops
= first_rtl_op (TREE_CODE (exp
));
5981 for (i
= 0; i
< nops
; i
++)
5982 if (TREE_OPERAND (exp
, i
) != 0
5983 && ! safe_from_p (x
, TREE_OPERAND (exp
, i
), 0))
5986 /* If this is a language-specific tree code, it may require
5987 special handling. */
5988 if ((unsigned int) TREE_CODE (exp
)
5989 >= (unsigned int) LAST_AND_UNUSED_TREE_CODE
5990 && !(*lang_hooks
.safe_from_p
) (x
, exp
))
5994 /* If we have an rtl, find any enclosed object. Then see if we conflict
5998 if (GET_CODE (exp_rtl
) == SUBREG
)
6000 exp_rtl
= SUBREG_REG (exp_rtl
);
6001 if (GET_CODE (exp_rtl
) == REG
6002 && REGNO (exp_rtl
) < FIRST_PSEUDO_REGISTER
)
6006 /* If the rtl is X, then it is not safe. Otherwise, it is unless both
6007 are memory and they conflict. */
6008 return ! (rtx_equal_p (x
, exp_rtl
)
6009 || (GET_CODE (x
) == MEM
&& GET_CODE (exp_rtl
) == MEM
6010 && true_dependence (exp_rtl
, VOIDmode
, x
,
6011 rtx_addr_varies_p
)));
6014 /* If we reach here, it is safe. */
6018 /* Subroutine of expand_expr: return rtx if EXP is a
6019 variable or parameter; else return 0. */
6025 switch (TREE_CODE (exp
))
6029 return DECL_RTL (exp
);
6035 /* Return the highest power of two that EXP is known to be a multiple of.
6036 This is used in updating alignment of MEMs in array references. */
6038 static unsigned HOST_WIDE_INT
6039 highest_pow2_factor (tree exp
)
6041 unsigned HOST_WIDE_INT c0
, c1
;
6043 switch (TREE_CODE (exp
))
6046 /* We can find the lowest bit that's a one. If the low
6047 HOST_BITS_PER_WIDE_INT bits are zero, return BIGGEST_ALIGNMENT.
6048 We need to handle this case since we can find it in a COND_EXPR,
6049 a MIN_EXPR, or a MAX_EXPR. If the constant overflows, we have an
6050 erroneous program, so return BIGGEST_ALIGNMENT to avoid any
6052 if (TREE_CONSTANT_OVERFLOW (exp
))
6053 return BIGGEST_ALIGNMENT
;
6056 /* Note: tree_low_cst is intentionally not used here,
6057 we don't care about the upper bits. */
6058 c0
= TREE_INT_CST_LOW (exp
);
6060 return c0
? c0
: BIGGEST_ALIGNMENT
;
6064 case PLUS_EXPR
: case MINUS_EXPR
: case MIN_EXPR
: case MAX_EXPR
:
6065 c0
= highest_pow2_factor (TREE_OPERAND (exp
, 0));
6066 c1
= highest_pow2_factor (TREE_OPERAND (exp
, 1));
6067 return MIN (c0
, c1
);
6070 c0
= highest_pow2_factor (TREE_OPERAND (exp
, 0));
6071 c1
= highest_pow2_factor (TREE_OPERAND (exp
, 1));
6074 case ROUND_DIV_EXPR
: case TRUNC_DIV_EXPR
: case FLOOR_DIV_EXPR
:
6076 if (integer_pow2p (TREE_OPERAND (exp
, 1))
6077 && host_integerp (TREE_OPERAND (exp
, 1), 1))
6079 c0
= highest_pow2_factor (TREE_OPERAND (exp
, 0));
6080 c1
= tree_low_cst (TREE_OPERAND (exp
, 1), 1);
6081 return MAX (1, c0
/ c1
);
6085 case NON_LVALUE_EXPR
: case NOP_EXPR
: case CONVERT_EXPR
:
6086 case SAVE_EXPR
: case WITH_RECORD_EXPR
:
6087 return highest_pow2_factor (TREE_OPERAND (exp
, 0));
6090 return highest_pow2_factor (TREE_OPERAND (exp
, 1));
6093 c0
= highest_pow2_factor (TREE_OPERAND (exp
, 1));
6094 c1
= highest_pow2_factor (TREE_OPERAND (exp
, 2));
6095 return MIN (c0
, c1
);
6104 /* Similar, except that the alignment requirements of TARGET are
6105 taken into account. Assume it is at least as aligned as its
6106 type, unless it is a COMPONENT_REF in which case the layout of
6107 the structure gives the alignment. */
6109 static unsigned HOST_WIDE_INT
6110 highest_pow2_factor_for_target (tree target
, tree exp
)
6112 unsigned HOST_WIDE_INT target_align
, factor
;
6114 factor
= highest_pow2_factor (exp
);
6115 if (TREE_CODE (target
) == COMPONENT_REF
)
6116 target_align
= DECL_ALIGN (TREE_OPERAND (target
, 1)) / BITS_PER_UNIT
;
6118 target_align
= TYPE_ALIGN (TREE_TYPE (target
)) / BITS_PER_UNIT
;
6119 return MAX (factor
, target_align
);
6122 /* Return an object on the placeholder list that matches EXP, a
6123 PLACEHOLDER_EXPR. An object "matches" if it is of the type of the
6124 PLACEHOLDER_EXPR or a pointer type to it. For further information, see
6125 tree.def. If no such object is found, return 0. If PLIST is nonzero, it
6126 is a location which initially points to a starting location in the
6127 placeholder list (zero means start of the list) and where a pointer into
6128 the placeholder list at which the object is found is placed. */
6131 find_placeholder (tree exp
, tree
*plist
)
6133 tree type
= TREE_TYPE (exp
);
6134 tree placeholder_expr
;
6136 for (placeholder_expr
6137 = plist
&& *plist
? TREE_CHAIN (*plist
) : placeholder_list
;
6138 placeholder_expr
!= 0;
6139 placeholder_expr
= TREE_CHAIN (placeholder_expr
))
6141 tree need_type
= TYPE_MAIN_VARIANT (type
);
6144 /* Find the outermost reference that is of the type we want. If none,
6145 see if any object has a type that is a pointer to the type we
6147 for (elt
= TREE_PURPOSE (placeholder_expr
); elt
!= 0;
6148 elt
= ((TREE_CODE (elt
) == COMPOUND_EXPR
6149 || TREE_CODE (elt
) == COND_EXPR
)
6150 ? TREE_OPERAND (elt
, 1)
6151 : (TREE_CODE_CLASS (TREE_CODE (elt
)) == 'r'
6152 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '1'
6153 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '2'
6154 || TREE_CODE_CLASS (TREE_CODE (elt
)) == 'e')
6155 ? TREE_OPERAND (elt
, 0) : 0))
6156 if (TYPE_MAIN_VARIANT (TREE_TYPE (elt
)) == need_type
)
6159 *plist
= placeholder_expr
;
6163 for (elt
= TREE_PURPOSE (placeholder_expr
); elt
!= 0;
6165 = ((TREE_CODE (elt
) == COMPOUND_EXPR
6166 || TREE_CODE (elt
) == COND_EXPR
)
6167 ? TREE_OPERAND (elt
, 1)
6168 : (TREE_CODE_CLASS (TREE_CODE (elt
)) == 'r'
6169 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '1'
6170 || TREE_CODE_CLASS (TREE_CODE (elt
)) == '2'
6171 || TREE_CODE_CLASS (TREE_CODE (elt
)) == 'e')
6172 ? TREE_OPERAND (elt
, 0) : 0))
6173 if (POINTER_TYPE_P (TREE_TYPE (elt
))
6174 && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (elt
)))
6178 *plist
= placeholder_expr
;
6179 return build1 (INDIRECT_REF
, need_type
, elt
);
6186 /* Subroutine of expand_expr. Expand the two operands of a binary
6187 expression EXP0 and EXP1 placing the results in OP0 and OP1.
6188 The value may be stored in TARGET if TARGET is nonzero. The
6189 MODIFIER argument is as documented by expand_expr. */
6192 expand_operands (tree exp0
, tree exp1
, rtx target
, rtx
*op0
, rtx
*op1
,
6193 enum expand_modifier modifier
)
6195 if (! safe_from_p (target
, exp1
, 1))
6197 if (operand_equal_p (exp0
, exp1
, 0))
6199 *op0
= expand_expr (exp0
, target
, VOIDmode
, modifier
);
6200 *op1
= copy_rtx (*op0
);
6204 /* If we need to preserve evaluation order, copy exp0 into its own
6205 temporary variable so that it can't be clobbered by exp1. */
6206 if (flag_evaluation_order
&& TREE_SIDE_EFFECTS (exp1
))
6207 exp0
= save_expr (exp0
);
6208 *op0
= expand_expr (exp0
, target
, VOIDmode
, modifier
);
6209 *op1
= expand_expr (exp1
, NULL_RTX
, VOIDmode
, modifier
);
6214 /* expand_expr: generate code for computing expression EXP.
6215 An rtx for the computed value is returned. The value is never null.
6216 In the case of a void EXP, const0_rtx is returned.
6218 The value may be stored in TARGET if TARGET is nonzero.
6219 TARGET is just a suggestion; callers must assume that
6220 the rtx returned may not be the same as TARGET.
6222 If TARGET is CONST0_RTX, it means that the value will be ignored.
6224 If TMODE is not VOIDmode, it suggests generating the
6225 result in mode TMODE. But this is done only when convenient.
6226 Otherwise, TMODE is ignored and the value generated in its natural mode.
6227 TMODE is just a suggestion; callers must assume that
6228 the rtx returned may not have mode TMODE.
6230 Note that TARGET may have neither TMODE nor MODE. In that case, it
6231 probably will not be used.
6233 If MODIFIER is EXPAND_SUM then when EXP is an addition
6234 we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
6235 or a nest of (PLUS ...) and (MINUS ...) where the terms are
6236 products as above, or REG or MEM, or constant.
6237 Ordinarily in such cases we would output mul or add instructions
6238 and then return a pseudo reg containing the sum.
6240 EXPAND_INITIALIZER is much like EXPAND_SUM except that
6241 it also marks a label as absolutely required (it can't be dead).
6242 It also makes a ZERO_EXTEND or SIGN_EXTEND instead of emitting extend insns.
6243 This is used for outputting expressions used in initializers.
6245 EXPAND_CONST_ADDRESS says that it is okay to return a MEM
6246 with a constant address even if that address is not normally legitimate.
6247 EXPAND_INITIALIZER and EXPAND_SUM also have this effect.
6249 EXPAND_STACK_PARM is used when expanding to a TARGET on the stack for
6250 a call parameter. Such targets require special care as we haven't yet
6251 marked TARGET so that it's safe from being trashed by libcalls. We
6252 don't want to use TARGET for anything but the final result;
6253 Intermediate values must go elsewhere. Additionally, calls to
6254 emit_block_move will be flagged with BLOCK_OP_CALL_PARM.
6256 If EXP is a VAR_DECL whose DECL_RTL was a MEM with an invalid
6257 address, and ALT_RTL is non-NULL, then *ALT_RTL is set to the
6258 DECL_RTL of the VAR_DECL. *ALT_RTL is also set if EXP is a
6259 COMPOUND_EXPR whose second argument is such a VAR_DECL, and so on
6263 expand_expr_real (tree exp
, rtx target
, enum machine_mode tmode
,
6264 enum expand_modifier modifier
, rtx
*alt_rtl
)
6267 tree type
= TREE_TYPE (exp
);
6268 int unsignedp
= TREE_UNSIGNED (type
);
6269 enum machine_mode mode
;
6270 enum tree_code code
= TREE_CODE (exp
);
6272 rtx subtarget
, original_target
;
6276 /* Handle ERROR_MARK before anybody tries to access its type. */
6277 if (TREE_CODE (exp
) == ERROR_MARK
|| TREE_CODE (type
) == ERROR_MARK
)
6279 op0
= CONST0_RTX (tmode
);
6285 mode
= TYPE_MODE (type
);
6286 /* Use subtarget as the target for operand 0 of a binary operation. */
6287 subtarget
= get_subtarget (target
);
6288 original_target
= target
;
6289 ignore
= (target
== const0_rtx
6290 || ((code
== NON_LVALUE_EXPR
|| code
== NOP_EXPR
6291 || code
== CONVERT_EXPR
|| code
== REFERENCE_EXPR
6292 || code
== COND_EXPR
|| code
== VIEW_CONVERT_EXPR
)
6293 && TREE_CODE (type
) == VOID_TYPE
));
6295 /* If we are going to ignore this result, we need only do something
6296 if there is a side-effect somewhere in the expression. If there
6297 is, short-circuit the most common cases here. Note that we must
6298 not call expand_expr with anything but const0_rtx in case this
6299 is an initial expansion of a size that contains a PLACEHOLDER_EXPR. */
6303 if (! TREE_SIDE_EFFECTS (exp
))
6306 /* Ensure we reference a volatile object even if value is ignored, but
6307 don't do this if all we are doing is taking its address. */
6308 if (TREE_THIS_VOLATILE (exp
)
6309 && TREE_CODE (exp
) != FUNCTION_DECL
6310 && mode
!= VOIDmode
&& mode
!= BLKmode
6311 && modifier
!= EXPAND_CONST_ADDRESS
)
6313 temp
= expand_expr (exp
, NULL_RTX
, VOIDmode
, modifier
);
6314 if (GET_CODE (temp
) == MEM
)
6315 temp
= copy_to_reg (temp
);
6319 if (TREE_CODE_CLASS (code
) == '1' || code
== COMPONENT_REF
6320 || code
== INDIRECT_REF
|| code
== BUFFER_REF
)
6321 return expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
,
6324 else if (TREE_CODE_CLASS (code
) == '2' || TREE_CODE_CLASS (code
) == '<'
6325 || code
== ARRAY_REF
|| code
== ARRAY_RANGE_REF
)
6327 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
, modifier
);
6328 expand_expr (TREE_OPERAND (exp
, 1), const0_rtx
, VOIDmode
, modifier
);
6331 else if ((code
== TRUTH_ANDIF_EXPR
|| code
== TRUTH_ORIF_EXPR
)
6332 && ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp
, 1)))
6333 /* If the second operand has no side effects, just evaluate
6335 return expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
,
6337 else if (code
== BIT_FIELD_REF
)
6339 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
, modifier
);
6340 expand_expr (TREE_OPERAND (exp
, 1), const0_rtx
, VOIDmode
, modifier
);
6341 expand_expr (TREE_OPERAND (exp
, 2), const0_rtx
, VOIDmode
, modifier
);
6348 /* If will do cse, generate all results into pseudo registers
6349 since 1) that allows cse to find more things
6350 and 2) otherwise cse could produce an insn the machine
6351 cannot support. An exception is a CONSTRUCTOR into a multi-word
6352 MEM: that's much more likely to be most efficient into the MEM.
6353 Another is a CALL_EXPR which must return in memory. */
6355 if (! cse_not_expected
&& mode
!= BLKmode
&& target
6356 && (GET_CODE (target
) != REG
|| REGNO (target
) < FIRST_PSEUDO_REGISTER
)
6357 && ! (code
== CONSTRUCTOR
&& GET_MODE_SIZE (mode
) > UNITS_PER_WORD
)
6358 && ! (code
== CALL_EXPR
&& aggregate_value_p (exp
, exp
)))
6365 tree function
= decl_function_context (exp
);
6366 /* Labels in containing functions, or labels used from initializers,
6368 if (modifier
== EXPAND_INITIALIZER
6369 || (function
!= current_function_decl
6370 && function
!= inline_function_decl
6372 temp
= force_label_rtx (exp
);
6374 temp
= label_rtx (exp
);
6376 temp
= gen_rtx_MEM (FUNCTION_MODE
, gen_rtx_LABEL_REF (Pmode
, temp
));
6377 if (function
!= current_function_decl
6378 && function
!= inline_function_decl
&& function
!= 0)
6379 LABEL_REF_NONLOCAL_P (XEXP (temp
, 0)) = 1;
6384 if (!DECL_RTL_SET_P (exp
))
6386 error ("%Jprior parameter's size depends on '%D'", exp
, exp
);
6387 return CONST0_RTX (mode
);
6390 /* ... fall through ... */
6393 /* If a static var's type was incomplete when the decl was written,
6394 but the type is complete now, lay out the decl now. */
6395 if (DECL_SIZE (exp
) == 0
6396 && COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (TREE_TYPE (exp
))
6397 && (TREE_STATIC (exp
) || DECL_EXTERNAL (exp
)))
6398 layout_decl (exp
, 0);
6400 /* ... fall through ... */
6404 if (DECL_RTL (exp
) == 0)
6407 /* Ensure variable marked as used even if it doesn't go through
6408 a parser. If it hasn't be used yet, write out an external
6410 if (! TREE_USED (exp
))
6412 assemble_external (exp
);
6413 TREE_USED (exp
) = 1;
6416 /* Show we haven't gotten RTL for this yet. */
6419 /* Handle variables inherited from containing functions. */
6420 context
= decl_function_context (exp
);
6422 /* We treat inline_function_decl as an alias for the current function
6423 because that is the inline function whose vars, types, etc.
6424 are being merged into the current function.
6425 See expand_inline_function. */
6427 if (context
!= 0 && context
!= current_function_decl
6428 && context
!= inline_function_decl
6429 /* If var is static, we don't need a static chain to access it. */
6430 && ! (GET_CODE (DECL_RTL (exp
)) == MEM
6431 && CONSTANT_P (XEXP (DECL_RTL (exp
), 0))))
6435 /* Mark as non-local and addressable. */
6436 DECL_NONLOCAL (exp
) = 1;
6437 if (DECL_NO_STATIC_CHAIN (current_function_decl
))
6439 (*lang_hooks
.mark_addressable
) (exp
);
6440 if (GET_CODE (DECL_RTL (exp
)) != MEM
)
6442 addr
= XEXP (DECL_RTL (exp
), 0);
6443 if (GET_CODE (addr
) == MEM
)
6445 = replace_equiv_address (addr
,
6446 fix_lexical_addr (XEXP (addr
, 0), exp
));
6448 addr
= fix_lexical_addr (addr
, exp
);
6450 temp
= replace_equiv_address (DECL_RTL (exp
), addr
);
6453 /* This is the case of an array whose size is to be determined
6454 from its initializer, while the initializer is still being parsed.
6457 else if (GET_CODE (DECL_RTL (exp
)) == MEM
6458 && GET_CODE (XEXP (DECL_RTL (exp
), 0)) == REG
)
6459 temp
= validize_mem (DECL_RTL (exp
));
6461 /* If DECL_RTL is memory, we are in the normal case and either
6462 the address is not valid or it is not a register and -fforce-addr
6463 is specified, get the address into a register. */
6465 else if (GET_CODE (DECL_RTL (exp
)) == MEM
6466 && modifier
!= EXPAND_CONST_ADDRESS
6467 && modifier
!= EXPAND_SUM
6468 && modifier
!= EXPAND_INITIALIZER
6469 && (! memory_address_p (DECL_MODE (exp
),
6470 XEXP (DECL_RTL (exp
), 0))
6472 && GET_CODE (XEXP (DECL_RTL (exp
), 0)) != REG
)))
6475 *alt_rtl
= DECL_RTL (exp
);
6476 temp
= replace_equiv_address (DECL_RTL (exp
),
6477 copy_rtx (XEXP (DECL_RTL (exp
), 0)));
6480 /* If we got something, return it. But first, set the alignment
6481 if the address is a register. */
6484 if (GET_CODE (temp
) == MEM
&& GET_CODE (XEXP (temp
, 0)) == REG
)
6485 mark_reg_pointer (XEXP (temp
, 0), DECL_ALIGN (exp
));
6490 /* If the mode of DECL_RTL does not match that of the decl, it
6491 must be a promoted value. We return a SUBREG of the wanted mode,
6492 but mark it so that we know that it was already extended. */
6494 if (GET_CODE (DECL_RTL (exp
)) == REG
6495 && GET_MODE (DECL_RTL (exp
)) != DECL_MODE (exp
))
6497 /* Get the signedness used for this variable. Ensure we get the
6498 same mode we got when the variable was declared. */
6499 if (GET_MODE (DECL_RTL (exp
))
6500 != promote_mode (type
, DECL_MODE (exp
), &unsignedp
,
6501 (TREE_CODE (exp
) == RESULT_DECL
? 1 : 0)))
6504 temp
= gen_lowpart_SUBREG (mode
, DECL_RTL (exp
));
6505 SUBREG_PROMOTED_VAR_P (temp
) = 1;
6506 SUBREG_PROMOTED_UNSIGNED_SET (temp
, unsignedp
);
6510 return DECL_RTL (exp
);
6513 temp
= immed_double_const (TREE_INT_CST_LOW (exp
),
6514 TREE_INT_CST_HIGH (exp
), mode
);
6516 /* ??? If overflow is set, fold will have done an incomplete job,
6517 which can result in (plus xx (const_int 0)), which can get
6518 simplified by validate_replace_rtx during virtual register
6519 instantiation, which can result in unrecognizable insns.
6520 Avoid this by forcing all overflows into registers. */
6521 if (TREE_CONSTANT_OVERFLOW (exp
)
6522 && modifier
!= EXPAND_INITIALIZER
)
6523 temp
= force_reg (mode
, temp
);
6528 return const_vector_from_tree (exp
);
6531 return expand_expr (DECL_INITIAL (exp
), target
, VOIDmode
, modifier
);
6534 /* If optimized, generate immediate CONST_DOUBLE
6535 which will be turned into memory by reload if necessary.
6537 We used to force a register so that loop.c could see it. But
6538 this does not allow gen_* patterns to perform optimizations with
6539 the constants. It also produces two insns in cases like "x = 1.0;".
6540 On most machines, floating-point constants are not permitted in
6541 many insns, so we'd end up copying it to a register in any case.
6543 Now, we do the copying in expand_binop, if appropriate. */
6544 return CONST_DOUBLE_FROM_REAL_VALUE (TREE_REAL_CST (exp
),
6545 TYPE_MODE (TREE_TYPE (exp
)));
6548 /* Handle evaluating a complex constant in a CONCAT target. */
6549 if (original_target
&& GET_CODE (original_target
) == CONCAT
)
6551 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (TREE_TYPE (exp
)));
6554 rtarg
= XEXP (original_target
, 0);
6555 itarg
= XEXP (original_target
, 1);
6557 /* Move the real and imaginary parts separately. */
6558 op0
= expand_expr (TREE_REALPART (exp
), rtarg
, mode
, 0);
6559 op1
= expand_expr (TREE_IMAGPART (exp
), itarg
, mode
, 0);
6562 emit_move_insn (rtarg
, op0
);
6564 emit_move_insn (itarg
, op1
);
6566 return original_target
;
6569 /* ... fall through ... */
6572 temp
= output_constant_def (exp
, 1);
6574 /* temp contains a constant address.
6575 On RISC machines where a constant address isn't valid,
6576 make some insns to get that address into a register. */
6577 if (modifier
!= EXPAND_CONST_ADDRESS
6578 && modifier
!= EXPAND_INITIALIZER
6579 && modifier
!= EXPAND_SUM
6580 && (! memory_address_p (mode
, XEXP (temp
, 0))
6581 || flag_force_addr
))
6582 return replace_equiv_address (temp
,
6583 copy_rtx (XEXP (temp
, 0)));
6586 case EXPR_WITH_FILE_LOCATION
:
6589 struct file_stack fs
;
6591 fs
.location
= input_location
;
6592 fs
.next
= expr_wfl_stack
;
6593 input_filename
= EXPR_WFL_FILENAME (exp
);
6594 input_line
= EXPR_WFL_LINENO (exp
);
6595 expr_wfl_stack
= &fs
;
6596 if (EXPR_WFL_EMIT_LINE_NOTE (exp
))
6597 emit_line_note (input_location
);
6598 /* Possibly avoid switching back and forth here. */
6599 to_return
= expand_expr (EXPR_WFL_NODE (exp
),
6600 (ignore
? const0_rtx
: target
),
6602 if (expr_wfl_stack
!= &fs
)
6604 input_location
= fs
.location
;
6605 expr_wfl_stack
= fs
.next
;
6610 context
= decl_function_context (exp
);
6612 /* If this SAVE_EXPR was at global context, assume we are an
6613 initialization function and move it into our context. */
6615 SAVE_EXPR_CONTEXT (exp
) = current_function_decl
;
6617 /* We treat inline_function_decl as an alias for the current function
6618 because that is the inline function whose vars, types, etc.
6619 are being merged into the current function.
6620 See expand_inline_function. */
6621 if (context
== current_function_decl
|| context
== inline_function_decl
)
6624 /* If this is non-local, handle it. */
6627 /* The following call just exists to abort if the context is
6628 not of a containing function. */
6629 find_function_data (context
);
6631 temp
= SAVE_EXPR_RTL (exp
);
6632 if (temp
&& GET_CODE (temp
) == REG
)
6634 put_var_into_stack (exp
, /*rescan=*/true);
6635 temp
= SAVE_EXPR_RTL (exp
);
6637 if (temp
== 0 || GET_CODE (temp
) != MEM
)
6640 replace_equiv_address (temp
,
6641 fix_lexical_addr (XEXP (temp
, 0), exp
));
6643 if (SAVE_EXPR_RTL (exp
) == 0)
6645 if (mode
== VOIDmode
)
6648 temp
= assign_temp (build_qualified_type (type
,
6650 | TYPE_QUAL_CONST
)),
6653 SAVE_EXPR_RTL (exp
) = temp
;
6654 if (!optimize
&& GET_CODE (temp
) == REG
)
6655 save_expr_regs
= gen_rtx_EXPR_LIST (VOIDmode
, temp
,
6658 /* If the mode of TEMP does not match that of the expression, it
6659 must be a promoted value. We pass store_expr a SUBREG of the
6660 wanted mode but mark it so that we know that it was already
6663 if (GET_CODE (temp
) == REG
&& GET_MODE (temp
) != mode
)
6665 temp
= gen_lowpart_SUBREG (mode
, SAVE_EXPR_RTL (exp
));
6666 promote_mode (type
, mode
, &unsignedp
, 0);
6667 SUBREG_PROMOTED_VAR_P (temp
) = 1;
6668 SUBREG_PROMOTED_UNSIGNED_SET (temp
, unsignedp
);
6671 if (temp
== const0_rtx
)
6672 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
, 0);
6674 store_expr (TREE_OPERAND (exp
, 0), temp
,
6675 modifier
== EXPAND_STACK_PARM
? 2 : 0);
6677 TREE_USED (exp
) = 1;
6680 /* If the mode of SAVE_EXPR_RTL does not match that of the expression, it
6681 must be a promoted value. We return a SUBREG of the wanted mode,
6682 but mark it so that we know that it was already extended. */
6684 if (GET_CODE (SAVE_EXPR_RTL (exp
)) == REG
6685 && GET_MODE (SAVE_EXPR_RTL (exp
)) != mode
)
6687 /* Compute the signedness and make the proper SUBREG. */
6688 promote_mode (type
, mode
, &unsignedp
, 0);
6689 temp
= gen_lowpart_SUBREG (mode
, SAVE_EXPR_RTL (exp
));
6690 SUBREG_PROMOTED_VAR_P (temp
) = 1;
6691 SUBREG_PROMOTED_UNSIGNED_SET (temp
, unsignedp
);
6695 return SAVE_EXPR_RTL (exp
);
6700 temp
= expand_expr (TREE_OPERAND (exp
, 0), target
, tmode
, modifier
);
6701 TREE_OPERAND (exp
, 0)
6702 = (*lang_hooks
.unsave_expr_now
) (TREE_OPERAND (exp
, 0));
6706 case PLACEHOLDER_EXPR
:
6708 tree old_list
= placeholder_list
;
6709 tree placeholder_expr
= 0;
6711 exp
= find_placeholder (exp
, &placeholder_expr
);
6715 placeholder_list
= TREE_CHAIN (placeholder_expr
);
6716 temp
= expand_expr (exp
, original_target
, tmode
, modifier
);
6717 placeholder_list
= old_list
;
6721 case WITH_RECORD_EXPR
:
6722 /* Put the object on the placeholder list, expand our first operand,
6723 and pop the list. */
6724 placeholder_list
= tree_cons (TREE_OPERAND (exp
, 1), NULL_TREE
,
6726 target
= expand_expr (TREE_OPERAND (exp
, 0), original_target
, tmode
,
6728 placeholder_list
= TREE_CHAIN (placeholder_list
);
6732 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == LABEL_DECL
)
6733 expand_goto (TREE_OPERAND (exp
, 0));
6735 expand_computed_goto (TREE_OPERAND (exp
, 0));
6739 expand_exit_loop_if_false (NULL
,
6740 invert_truthvalue (TREE_OPERAND (exp
, 0)));
6743 case LABELED_BLOCK_EXPR
:
6744 if (LABELED_BLOCK_BODY (exp
))
6745 expand_expr_stmt_value (LABELED_BLOCK_BODY (exp
), 0, 1);
6746 /* Should perhaps use expand_label, but this is simpler and safer. */
6747 do_pending_stack_adjust ();
6748 emit_label (label_rtx (LABELED_BLOCK_LABEL (exp
)));
6751 case EXIT_BLOCK_EXPR
:
6752 if (EXIT_BLOCK_RETURN (exp
))
6753 sorry ("returned value in block_exit_expr");
6754 expand_goto (LABELED_BLOCK_LABEL (EXIT_BLOCK_LABELED_BLOCK (exp
)));
6759 expand_start_loop (1);
6760 expand_expr_stmt_value (TREE_OPERAND (exp
, 0), 0, 1);
6768 tree vars
= TREE_OPERAND (exp
, 0);
6770 /* Need to open a binding contour here because
6771 if there are any cleanups they must be contained here. */
6772 expand_start_bindings (2);
6774 /* Mark the corresponding BLOCK for output in its proper place. */
6775 if (TREE_OPERAND (exp
, 2) != 0
6776 && ! TREE_USED (TREE_OPERAND (exp
, 2)))
6777 (*lang_hooks
.decls
.insert_block
) (TREE_OPERAND (exp
, 2));
6779 /* If VARS have not yet been expanded, expand them now. */
6782 if (!DECL_RTL_SET_P (vars
))
6784 expand_decl_init (vars
);
6785 vars
= TREE_CHAIN (vars
);
6788 temp
= expand_expr (TREE_OPERAND (exp
, 1), target
, tmode
, modifier
);
6790 expand_end_bindings (TREE_OPERAND (exp
, 0), 0, 0);
6796 if (RTL_EXPR_SEQUENCE (exp
))
6798 if (RTL_EXPR_SEQUENCE (exp
) == const0_rtx
)
6800 emit_insn (RTL_EXPR_SEQUENCE (exp
));
6801 RTL_EXPR_SEQUENCE (exp
) = const0_rtx
;
6803 preserve_rtl_expr_result (RTL_EXPR_RTL (exp
));
6804 free_temps_for_rtl_expr (exp
);
6806 *alt_rtl
= RTL_EXPR_ALT_RTL (exp
);
6807 return RTL_EXPR_RTL (exp
);
6810 /* If we don't need the result, just ensure we evaluate any
6816 for (elt
= CONSTRUCTOR_ELTS (exp
); elt
; elt
= TREE_CHAIN (elt
))
6817 expand_expr (TREE_VALUE (elt
), const0_rtx
, VOIDmode
, 0);
6822 /* All elts simple constants => refer to a constant in memory. But
6823 if this is a non-BLKmode mode, let it store a field at a time
6824 since that should make a CONST_INT or CONST_DOUBLE when we
6825 fold. Likewise, if we have a target we can use, it is best to
6826 store directly into the target unless the type is large enough
6827 that memcpy will be used. If we are making an initializer and
6828 all operands are constant, put it in memory as well.
6830 FIXME: Avoid trying to fill vector constructors piece-meal.
6831 Output them with output_constant_def below unless we're sure
6832 they're zeros. This should go away when vector initializers
6833 are treated like VECTOR_CST instead of arrays.
6835 else if ((TREE_STATIC (exp
)
6836 && ((mode
== BLKmode
6837 && ! (target
!= 0 && safe_from_p (target
, exp
, 1)))
6838 || TREE_ADDRESSABLE (exp
)
6839 || (host_integerp (TYPE_SIZE_UNIT (type
), 1)
6840 && (! MOVE_BY_PIECES_P
6841 (tree_low_cst (TYPE_SIZE_UNIT (type
), 1),
6843 && ((TREE_CODE (type
) == VECTOR_TYPE
6844 && !is_zeros_p (exp
))
6845 || ! mostly_zeros_p (exp
)))))
6846 || ((modifier
== EXPAND_INITIALIZER
6847 || modifier
== EXPAND_CONST_ADDRESS
)
6848 && TREE_CONSTANT (exp
)))
6850 rtx constructor
= output_constant_def (exp
, 1);
6852 if (modifier
!= EXPAND_CONST_ADDRESS
6853 && modifier
!= EXPAND_INITIALIZER
6854 && modifier
!= EXPAND_SUM
)
6855 constructor
= validize_mem (constructor
);
6861 /* Handle calls that pass values in multiple non-contiguous
6862 locations. The Irix 6 ABI has examples of this. */
6863 if (target
== 0 || ! safe_from_p (target
, exp
, 1)
6864 || GET_CODE (target
) == PARALLEL
6865 || modifier
== EXPAND_STACK_PARM
)
6867 = assign_temp (build_qualified_type (type
,
6869 | (TREE_READONLY (exp
)
6870 * TYPE_QUAL_CONST
))),
6871 0, TREE_ADDRESSABLE (exp
), 1);
6873 store_constructor (exp
, target
, 0, int_expr_size (exp
));
6879 tree exp1
= TREE_OPERAND (exp
, 0);
6881 tree string
= string_constant (exp1
, &index
);
6883 /* Try to optimize reads from const strings. */
6885 && TREE_CODE (string
) == STRING_CST
6886 && TREE_CODE (index
) == INTEGER_CST
6887 && compare_tree_int (index
, TREE_STRING_LENGTH (string
)) < 0
6888 && GET_MODE_CLASS (mode
) == MODE_INT
6889 && GET_MODE_SIZE (mode
) == 1
6890 && modifier
!= EXPAND_WRITE
)
6891 return gen_int_mode (TREE_STRING_POINTER (string
)
6892 [TREE_INT_CST_LOW (index
)], mode
);
6894 op0
= expand_expr (exp1
, NULL_RTX
, VOIDmode
, EXPAND_SUM
);
6895 op0
= memory_address (mode
, op0
);
6896 temp
= gen_rtx_MEM (mode
, op0
);
6897 set_mem_attributes (temp
, exp
, 0);
6899 /* If we are writing to this object and its type is a record with
6900 readonly fields, we must mark it as readonly so it will
6901 conflict with readonly references to those fields. */
6902 if (modifier
== EXPAND_WRITE
&& readonly_fields_p (type
))
6903 RTX_UNCHANGING_P (temp
) = 1;
6909 if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp
, 0))) != ARRAY_TYPE
)
6913 tree array
= TREE_OPERAND (exp
, 0);
6914 tree domain
= TYPE_DOMAIN (TREE_TYPE (array
));
6915 tree low_bound
= domain
? TYPE_MIN_VALUE (domain
) : integer_zero_node
;
6916 tree index
= convert (sizetype
, TREE_OPERAND (exp
, 1));
6919 /* Optimize the special-case of a zero lower bound.
6921 We convert the low_bound to sizetype to avoid some problems
6922 with constant folding. (E.g. suppose the lower bound is 1,
6923 and its mode is QI. Without the conversion, (ARRAY
6924 +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1))
6925 +INDEX), which becomes (ARRAY+255+INDEX). Oops!) */
6927 if (! integer_zerop (low_bound
))
6928 index
= size_diffop (index
, convert (sizetype
, low_bound
));
6930 /* Fold an expression like: "foo"[2].
6931 This is not done in fold so it won't happen inside &.
6932 Don't fold if this is for wide characters since it's too
6933 difficult to do correctly and this is a very rare case. */
6935 if (modifier
!= EXPAND_CONST_ADDRESS
6936 && modifier
!= EXPAND_INITIALIZER
6937 && modifier
!= EXPAND_MEMORY
6938 && TREE_CODE (array
) == STRING_CST
6939 && TREE_CODE (index
) == INTEGER_CST
6940 && compare_tree_int (index
, TREE_STRING_LENGTH (array
)) < 0
6941 && GET_MODE_CLASS (mode
) == MODE_INT
6942 && GET_MODE_SIZE (mode
) == 1)
6943 return gen_int_mode (TREE_STRING_POINTER (array
)
6944 [TREE_INT_CST_LOW (index
)], mode
);
6946 /* If this is a constant index into a constant array,
6947 just get the value from the array. Handle both the cases when
6948 we have an explicit constructor and when our operand is a variable
6949 that was declared const. */
6951 if (modifier
!= EXPAND_CONST_ADDRESS
6952 && modifier
!= EXPAND_INITIALIZER
6953 && modifier
!= EXPAND_MEMORY
6954 && TREE_CODE (array
) == CONSTRUCTOR
6955 && ! TREE_SIDE_EFFECTS (array
)
6956 && TREE_CODE (index
) == INTEGER_CST
6957 && 0 > compare_tree_int (index
,
6958 list_length (CONSTRUCTOR_ELTS
6959 (TREE_OPERAND (exp
, 0)))))
6963 for (elem
= CONSTRUCTOR_ELTS (TREE_OPERAND (exp
, 0)),
6964 i
= TREE_INT_CST_LOW (index
);
6965 elem
!= 0 && i
!= 0; i
--, elem
= TREE_CHAIN (elem
))
6969 return expand_expr (fold (TREE_VALUE (elem
)), target
, tmode
,
6973 else if (optimize
>= 1
6974 && modifier
!= EXPAND_CONST_ADDRESS
6975 && modifier
!= EXPAND_INITIALIZER
6976 && modifier
!= EXPAND_MEMORY
6977 && TREE_READONLY (array
) && ! TREE_SIDE_EFFECTS (array
)
6978 && TREE_CODE (array
) == VAR_DECL
&& DECL_INITIAL (array
)
6979 && TREE_CODE (DECL_INITIAL (array
)) != ERROR_MARK
6980 && targetm
.binds_local_p (array
))
6982 if (TREE_CODE (index
) == INTEGER_CST
)
6984 tree init
= DECL_INITIAL (array
);
6986 if (TREE_CODE (init
) == CONSTRUCTOR
)
6990 for (elem
= CONSTRUCTOR_ELTS (init
);
6992 && !tree_int_cst_equal (TREE_PURPOSE (elem
), index
));
6993 elem
= TREE_CHAIN (elem
))
6996 if (elem
&& !TREE_SIDE_EFFECTS (TREE_VALUE (elem
)))
6997 return expand_expr (fold (TREE_VALUE (elem
)), target
,
7000 else if (TREE_CODE (init
) == STRING_CST
7001 && 0 > compare_tree_int (index
,
7002 TREE_STRING_LENGTH (init
)))
7004 tree type
= TREE_TYPE (TREE_TYPE (init
));
7005 enum machine_mode mode
= TYPE_MODE (type
);
7007 if (GET_MODE_CLASS (mode
) == MODE_INT
7008 && GET_MODE_SIZE (mode
) == 1)
7009 return gen_int_mode (TREE_STRING_POINTER (init
)
7010 [TREE_INT_CST_LOW (index
)], mode
);
7015 goto normal_inner_ref
;
7018 /* If the operand is a CONSTRUCTOR, we can just extract the
7019 appropriate field if it is present. */
7020 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == CONSTRUCTOR
)
7024 for (elt
= CONSTRUCTOR_ELTS (TREE_OPERAND (exp
, 0)); elt
;
7025 elt
= TREE_CHAIN (elt
))
7026 if (TREE_PURPOSE (elt
) == TREE_OPERAND (exp
, 1)
7027 /* We can normally use the value of the field in the
7028 CONSTRUCTOR. However, if this is a bitfield in
7029 an integral mode that we can fit in a HOST_WIDE_INT,
7030 we must mask only the number of bits in the bitfield,
7031 since this is done implicitly by the constructor. If
7032 the bitfield does not meet either of those conditions,
7033 we can't do this optimization. */
7034 && (! DECL_BIT_FIELD (TREE_PURPOSE (elt
))
7035 || ((GET_MODE_CLASS (DECL_MODE (TREE_PURPOSE (elt
)))
7037 && (GET_MODE_BITSIZE (DECL_MODE (TREE_PURPOSE (elt
)))
7038 <= HOST_BITS_PER_WIDE_INT
))))
7040 if (DECL_BIT_FIELD (TREE_PURPOSE (elt
))
7041 && modifier
== EXPAND_STACK_PARM
)
7043 op0
= expand_expr (TREE_VALUE (elt
), target
, tmode
, modifier
);
7044 if (DECL_BIT_FIELD (TREE_PURPOSE (elt
)))
7046 HOST_WIDE_INT bitsize
7047 = TREE_INT_CST_LOW (DECL_SIZE (TREE_PURPOSE (elt
)));
7048 enum machine_mode imode
7049 = TYPE_MODE (TREE_TYPE (TREE_PURPOSE (elt
)));
7051 if (TREE_UNSIGNED (TREE_TYPE (TREE_PURPOSE (elt
))))
7053 op1
= GEN_INT (((HOST_WIDE_INT
) 1 << bitsize
) - 1);
7054 op0
= expand_and (imode
, op0
, op1
, target
);
7059 = build_int_2 (GET_MODE_BITSIZE (imode
) - bitsize
,
7062 op0
= expand_shift (LSHIFT_EXPR
, imode
, op0
, count
,
7064 op0
= expand_shift (RSHIFT_EXPR
, imode
, op0
, count
,
7072 goto normal_inner_ref
;
7075 case ARRAY_RANGE_REF
:
7078 enum machine_mode mode1
;
7079 HOST_WIDE_INT bitsize
, bitpos
;
7082 tree tem
= get_inner_reference (exp
, &bitsize
, &bitpos
, &offset
,
7083 &mode1
, &unsignedp
, &volatilep
);
7086 /* If we got back the original object, something is wrong. Perhaps
7087 we are evaluating an expression too early. In any event, don't
7088 infinitely recurse. */
7092 /* If TEM's type is a union of variable size, pass TARGET to the inner
7093 computation, since it will need a temporary and TARGET is known
7094 to have to do. This occurs in unchecked conversion in Ada. */
7098 (TREE_CODE (TREE_TYPE (tem
)) == UNION_TYPE
7099 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem
)))
7101 && modifier
!= EXPAND_STACK_PARM
7102 ? target
: NULL_RTX
),
7104 (modifier
== EXPAND_INITIALIZER
7105 || modifier
== EXPAND_CONST_ADDRESS
7106 || modifier
== EXPAND_STACK_PARM
)
7107 ? modifier
: EXPAND_NORMAL
);
7109 /* If this is a constant, put it into a register if it is a
7110 legitimate constant and OFFSET is 0 and memory if it isn't. */
7111 if (CONSTANT_P (op0
))
7113 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (tem
));
7114 if (mode
!= BLKmode
&& LEGITIMATE_CONSTANT_P (op0
)
7116 op0
= force_reg (mode
, op0
);
7118 op0
= validize_mem (force_const_mem (mode
, op0
));
7121 /* Otherwise, if this object not in memory and we either have an
7122 offset or a BLKmode result, put it there. This case can't occur in
7123 C, but can in Ada if we have unchecked conversion of an expression
7124 from a scalar type to an array or record type or for an
7125 ARRAY_RANGE_REF whose type is BLKmode. */
7126 else if (GET_CODE (op0
) != MEM
7128 || (code
== ARRAY_RANGE_REF
&& mode
== BLKmode
)))
7130 /* If the operand is a SAVE_EXPR, we can deal with this by
7131 forcing the SAVE_EXPR into memory. */
7132 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == SAVE_EXPR
)
7134 put_var_into_stack (TREE_OPERAND (exp
, 0),
7136 op0
= SAVE_EXPR_RTL (TREE_OPERAND (exp
, 0));
7141 = build_qualified_type (TREE_TYPE (tem
),
7142 (TYPE_QUALS (TREE_TYPE (tem
))
7143 | TYPE_QUAL_CONST
));
7144 rtx memloc
= assign_temp (nt
, 1, 1, 1);
7146 emit_move_insn (memloc
, op0
);
7153 rtx offset_rtx
= expand_expr (offset
, NULL_RTX
, VOIDmode
,
7156 if (GET_CODE (op0
) != MEM
)
7159 #ifdef POINTERS_EXTEND_UNSIGNED
7160 if (GET_MODE (offset_rtx
) != Pmode
)
7161 offset_rtx
= convert_to_mode (Pmode
, offset_rtx
, 0);
7163 if (GET_MODE (offset_rtx
) != ptr_mode
)
7164 offset_rtx
= convert_to_mode (ptr_mode
, offset_rtx
, 0);
7167 if (GET_MODE (op0
) == BLKmode
7168 /* A constant address in OP0 can have VOIDmode, we must
7169 not try to call force_reg in that case. */
7170 && GET_MODE (XEXP (op0
, 0)) != VOIDmode
7172 && (bitpos
% bitsize
) == 0
7173 && (bitsize
% GET_MODE_ALIGNMENT (mode1
)) == 0
7174 && MEM_ALIGN (op0
) == GET_MODE_ALIGNMENT (mode1
))
7176 op0
= adjust_address (op0
, mode1
, bitpos
/ BITS_PER_UNIT
);
7180 op0
= offset_address (op0
, offset_rtx
,
7181 highest_pow2_factor (offset
));
7184 /* If OFFSET is making OP0 more aligned than BIGGEST_ALIGNMENT,
7185 record its alignment as BIGGEST_ALIGNMENT. */
7186 if (GET_CODE (op0
) == MEM
&& bitpos
== 0 && offset
!= 0
7187 && is_aligning_offset (offset
, tem
))
7188 set_mem_align (op0
, BIGGEST_ALIGNMENT
);
7190 /* Don't forget about volatility even if this is a bitfield. */
7191 if (GET_CODE (op0
) == MEM
&& volatilep
&& ! MEM_VOLATILE_P (op0
))
7193 if (op0
== orig_op0
)
7194 op0
= copy_rtx (op0
);
7196 MEM_VOLATILE_P (op0
) = 1;
7199 /* The following code doesn't handle CONCAT.
7200 Assume only bitpos == 0 can be used for CONCAT, due to
7201 one element arrays having the same mode as its element. */
7202 if (GET_CODE (op0
) == CONCAT
)
7204 if (bitpos
!= 0 || bitsize
!= GET_MODE_BITSIZE (GET_MODE (op0
)))
7209 /* In cases where an aligned union has an unaligned object
7210 as a field, we might be extracting a BLKmode value from
7211 an integer-mode (e.g., SImode) object. Handle this case
7212 by doing the extract into an object as wide as the field
7213 (which we know to be the width of a basic mode), then
7214 storing into memory, and changing the mode to BLKmode. */
7215 if (mode1
== VOIDmode
7216 || GET_CODE (op0
) == REG
|| GET_CODE (op0
) == SUBREG
7217 || (mode1
!= BLKmode
&& ! direct_load
[(int) mode1
]
7218 && GET_MODE_CLASS (mode
) != MODE_COMPLEX_INT
7219 && GET_MODE_CLASS (mode
) != MODE_COMPLEX_FLOAT
7220 && modifier
!= EXPAND_CONST_ADDRESS
7221 && modifier
!= EXPAND_INITIALIZER
)
7222 /* If the field isn't aligned enough to fetch as a memref,
7223 fetch it as a bit field. */
7224 || (mode1
!= BLKmode
7225 && (((TYPE_ALIGN (TREE_TYPE (tem
)) < GET_MODE_ALIGNMENT (mode
)
7226 || (bitpos
% GET_MODE_ALIGNMENT (mode
) != 0)
7227 || (GET_CODE (op0
) == MEM
7228 && (MEM_ALIGN (op0
) < GET_MODE_ALIGNMENT (mode1
)
7229 || (bitpos
% GET_MODE_ALIGNMENT (mode1
) != 0))))
7230 && ((modifier
== EXPAND_CONST_ADDRESS
7231 || modifier
== EXPAND_INITIALIZER
)
7233 : SLOW_UNALIGNED_ACCESS (mode1
, MEM_ALIGN (op0
))))
7234 || (bitpos
% BITS_PER_UNIT
!= 0)))
7235 /* If the type and the field are a constant size and the
7236 size of the type isn't the same size as the bitfield,
7237 we must use bitfield operations. */
7239 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (exp
)))
7241 && 0 != compare_tree_int (TYPE_SIZE (TREE_TYPE (exp
)),
7244 enum machine_mode ext_mode
= mode
;
7246 if (ext_mode
== BLKmode
7247 && ! (target
!= 0 && GET_CODE (op0
) == MEM
7248 && GET_CODE (target
) == MEM
7249 && bitpos
% BITS_PER_UNIT
== 0))
7250 ext_mode
= mode_for_size (bitsize
, MODE_INT
, 1);
7252 if (ext_mode
== BLKmode
)
7255 target
= assign_temp (type
, 0, 1, 1);
7260 /* In this case, BITPOS must start at a byte boundary and
7261 TARGET, if specified, must be a MEM. */
7262 if (GET_CODE (op0
) != MEM
7263 || (target
!= 0 && GET_CODE (target
) != MEM
)
7264 || bitpos
% BITS_PER_UNIT
!= 0)
7267 emit_block_move (target
,
7268 adjust_address (op0
, VOIDmode
,
7269 bitpos
/ BITS_PER_UNIT
),
7270 GEN_INT ((bitsize
+ BITS_PER_UNIT
- 1)
7272 (modifier
== EXPAND_STACK_PARM
7273 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
7278 op0
= validize_mem (op0
);
7280 if (GET_CODE (op0
) == MEM
&& GET_CODE (XEXP (op0
, 0)) == REG
)
7281 mark_reg_pointer (XEXP (op0
, 0), MEM_ALIGN (op0
));
7283 op0
= extract_bit_field (op0
, bitsize
, bitpos
, unsignedp
,
7284 (modifier
== EXPAND_STACK_PARM
7285 ? NULL_RTX
: target
),
7287 int_size_in_bytes (TREE_TYPE (tem
)));
7289 /* If the result is a record type and BITSIZE is narrower than
7290 the mode of OP0, an integral mode, and this is a big endian
7291 machine, we must put the field into the high-order bits. */
7292 if (TREE_CODE (type
) == RECORD_TYPE
&& BYTES_BIG_ENDIAN
7293 && GET_MODE_CLASS (GET_MODE (op0
)) == MODE_INT
7294 && bitsize
< (HOST_WIDE_INT
) GET_MODE_BITSIZE (GET_MODE (op0
)))
7295 op0
= expand_shift (LSHIFT_EXPR
, GET_MODE (op0
), op0
,
7296 size_int (GET_MODE_BITSIZE (GET_MODE (op0
))
7300 if (mode
== BLKmode
)
7302 rtx
new = assign_temp (build_qualified_type
7303 ((*lang_hooks
.types
.type_for_mode
)
7305 TYPE_QUAL_CONST
), 0, 1, 1);
7307 emit_move_insn (new, op0
);
7308 op0
= copy_rtx (new);
7309 PUT_MODE (op0
, BLKmode
);
7310 set_mem_attributes (op0
, exp
, 1);
7316 /* If the result is BLKmode, use that to access the object
7318 if (mode
== BLKmode
)
7321 /* Get a reference to just this component. */
7322 if (modifier
== EXPAND_CONST_ADDRESS
7323 || modifier
== EXPAND_SUM
|| modifier
== EXPAND_INITIALIZER
)
7324 op0
= adjust_address_nv (op0
, mode1
, bitpos
/ BITS_PER_UNIT
);
7326 op0
= adjust_address (op0
, mode1
, bitpos
/ BITS_PER_UNIT
);
7328 if (op0
== orig_op0
)
7329 op0
= copy_rtx (op0
);
7331 set_mem_attributes (op0
, exp
, 0);
7332 if (GET_CODE (XEXP (op0
, 0)) == REG
)
7333 mark_reg_pointer (XEXP (op0
, 0), MEM_ALIGN (op0
));
7335 MEM_VOLATILE_P (op0
) |= volatilep
;
7336 if (mode
== mode1
|| mode1
== BLKmode
|| mode1
== tmode
7337 || modifier
== EXPAND_CONST_ADDRESS
7338 || modifier
== EXPAND_INITIALIZER
)
7340 else if (target
== 0)
7341 target
= gen_reg_rtx (tmode
!= VOIDmode
? tmode
: mode
);
7343 convert_move (target
, op0
, unsignedp
);
7349 rtx insn
, before
= get_last_insn (), vtbl_ref
;
7351 /* Evaluate the interior expression. */
7352 subtarget
= expand_expr (TREE_OPERAND (exp
, 0), target
,
7355 /* Get or create an instruction off which to hang a note. */
7356 if (REG_P (subtarget
))
7359 insn
= get_last_insn ();
7362 if (! INSN_P (insn
))
7363 insn
= prev_nonnote_insn (insn
);
7367 target
= gen_reg_rtx (GET_MODE (subtarget
));
7368 insn
= emit_move_insn (target
, subtarget
);
7371 /* Collect the data for the note. */
7372 vtbl_ref
= XEXP (DECL_RTL (TREE_OPERAND (exp
, 1)), 0);
7373 vtbl_ref
= plus_constant (vtbl_ref
,
7374 tree_low_cst (TREE_OPERAND (exp
, 2), 0));
7375 /* Discard the initial CONST that was added. */
7376 vtbl_ref
= XEXP (vtbl_ref
, 0);
7379 = gen_rtx_EXPR_LIST (REG_VTABLE_REF
, vtbl_ref
, REG_NOTES (insn
));
7384 /* Intended for a reference to a buffer of a file-object in Pascal.
7385 But it's not certain that a special tree code will really be
7386 necessary for these. INDIRECT_REF might work for them. */
7392 /* Pascal set IN expression.
7395 rlo = set_low - (set_low%bits_per_word);
7396 the_word = set [ (index - rlo)/bits_per_word ];
7397 bit_index = index % bits_per_word;
7398 bitmask = 1 << bit_index;
7399 return !!(the_word & bitmask); */
7401 tree set
= TREE_OPERAND (exp
, 0);
7402 tree index
= TREE_OPERAND (exp
, 1);
7403 int iunsignedp
= TREE_UNSIGNED (TREE_TYPE (index
));
7404 tree set_type
= TREE_TYPE (set
);
7405 tree set_low_bound
= TYPE_MIN_VALUE (TYPE_DOMAIN (set_type
));
7406 tree set_high_bound
= TYPE_MAX_VALUE (TYPE_DOMAIN (set_type
));
7407 rtx index_val
= expand_expr (index
, 0, VOIDmode
, 0);
7408 rtx lo_r
= expand_expr (set_low_bound
, 0, VOIDmode
, 0);
7409 rtx hi_r
= expand_expr (set_high_bound
, 0, VOIDmode
, 0);
7410 rtx setval
= expand_expr (set
, 0, VOIDmode
, 0);
7411 rtx setaddr
= XEXP (setval
, 0);
7412 enum machine_mode index_mode
= TYPE_MODE (TREE_TYPE (index
));
7414 rtx diff
, quo
, rem
, addr
, bit
, result
;
7416 /* If domain is empty, answer is no. Likewise if index is constant
7417 and out of bounds. */
7418 if (((TREE_CODE (set_high_bound
) == INTEGER_CST
7419 && TREE_CODE (set_low_bound
) == INTEGER_CST
7420 && tree_int_cst_lt (set_high_bound
, set_low_bound
))
7421 || (TREE_CODE (index
) == INTEGER_CST
7422 && TREE_CODE (set_low_bound
) == INTEGER_CST
7423 && tree_int_cst_lt (index
, set_low_bound
))
7424 || (TREE_CODE (set_high_bound
) == INTEGER_CST
7425 && TREE_CODE (index
) == INTEGER_CST
7426 && tree_int_cst_lt (set_high_bound
, index
))))
7430 target
= gen_reg_rtx (tmode
!= VOIDmode
? tmode
: mode
);
7432 /* If we get here, we have to generate the code for both cases
7433 (in range and out of range). */
7435 op0
= gen_label_rtx ();
7436 op1
= gen_label_rtx ();
7438 if (! (GET_CODE (index_val
) == CONST_INT
7439 && GET_CODE (lo_r
) == CONST_INT
))
7440 emit_cmp_and_jump_insns (index_val
, lo_r
, LT
, NULL_RTX
,
7441 GET_MODE (index_val
), iunsignedp
, op1
);
7443 if (! (GET_CODE (index_val
) == CONST_INT
7444 && GET_CODE (hi_r
) == CONST_INT
))
7445 emit_cmp_and_jump_insns (index_val
, hi_r
, GT
, NULL_RTX
,
7446 GET_MODE (index_val
), iunsignedp
, op1
);
7448 /* Calculate the element number of bit zero in the first word
7450 if (GET_CODE (lo_r
) == CONST_INT
)
7451 rlow
= GEN_INT (INTVAL (lo_r
)
7452 & ~((HOST_WIDE_INT
) 1 << BITS_PER_UNIT
));
7454 rlow
= expand_binop (index_mode
, and_optab
, lo_r
,
7455 GEN_INT (~((HOST_WIDE_INT
) 1 << BITS_PER_UNIT
)),
7456 NULL_RTX
, iunsignedp
, OPTAB_LIB_WIDEN
);
7458 diff
= expand_binop (index_mode
, sub_optab
, index_val
, rlow
,
7459 NULL_RTX
, iunsignedp
, OPTAB_LIB_WIDEN
);
7461 quo
= expand_divmod (0, TRUNC_DIV_EXPR
, index_mode
, diff
,
7462 GEN_INT (BITS_PER_UNIT
), NULL_RTX
, iunsignedp
);
7463 rem
= expand_divmod (1, TRUNC_MOD_EXPR
, index_mode
, index_val
,
7464 GEN_INT (BITS_PER_UNIT
), NULL_RTX
, iunsignedp
);
7466 addr
= memory_address (byte_mode
,
7467 expand_binop (index_mode
, add_optab
, diff
,
7468 setaddr
, NULL_RTX
, iunsignedp
,
7471 /* Extract the bit we want to examine. */
7472 bit
= expand_shift (RSHIFT_EXPR
, byte_mode
,
7473 gen_rtx_MEM (byte_mode
, addr
),
7474 make_tree (TREE_TYPE (index
), rem
),
7476 result
= expand_binop (byte_mode
, and_optab
, bit
, const1_rtx
,
7477 GET_MODE (target
) == byte_mode
? target
: 0,
7478 1, OPTAB_LIB_WIDEN
);
7480 if (result
!= target
)
7481 convert_move (target
, result
, 1);
7483 /* Output the code to handle the out-of-range case. */
7486 emit_move_insn (target
, const0_rtx
);
7491 case WITH_CLEANUP_EXPR
:
7492 if (WITH_CLEANUP_EXPR_RTL (exp
) == 0)
7494 WITH_CLEANUP_EXPR_RTL (exp
)
7495 = expand_expr (TREE_OPERAND (exp
, 0), target
, tmode
, modifier
);
7496 expand_decl_cleanup_eh (NULL_TREE
, TREE_OPERAND (exp
, 1),
7497 CLEANUP_EH_ONLY (exp
));
7499 /* That's it for this cleanup. */
7500 TREE_OPERAND (exp
, 1) = 0;
7502 return WITH_CLEANUP_EXPR_RTL (exp
);
7504 case CLEANUP_POINT_EXPR
:
7506 /* Start a new binding layer that will keep track of all cleanup
7507 actions to be performed. */
7508 expand_start_bindings (2);
7510 target_temp_slot_level
= temp_slot_level
;
7512 op0
= expand_expr (TREE_OPERAND (exp
, 0), target
, tmode
, modifier
);
7513 /* If we're going to use this value, load it up now. */
7515 op0
= force_not_mem (op0
);
7516 preserve_temp_slots (op0
);
7517 expand_end_bindings (NULL_TREE
, 0, 0);
7522 /* Check for a built-in function. */
7523 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == ADDR_EXPR
7524 && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
7526 && DECL_BUILT_IN (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))
7528 if (DECL_BUILT_IN_CLASS (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))
7529 == BUILT_IN_FRONTEND
)
7530 return (*lang_hooks
.expand_expr
) (exp
, original_target
,
7534 return expand_builtin (exp
, target
, subtarget
, tmode
, ignore
);
7537 return expand_call (exp
, target
, ignore
);
7539 case NON_LVALUE_EXPR
:
7542 case REFERENCE_EXPR
:
7543 if (TREE_OPERAND (exp
, 0) == error_mark_node
)
7546 if (TREE_CODE (type
) == UNION_TYPE
)
7548 tree valtype
= TREE_TYPE (TREE_OPERAND (exp
, 0));
7550 /* If both input and output are BLKmode, this conversion isn't doing
7551 anything except possibly changing memory attribute. */
7552 if (mode
== BLKmode
&& TYPE_MODE (valtype
) == BLKmode
)
7554 rtx result
= expand_expr (TREE_OPERAND (exp
, 0), target
, tmode
,
7557 result
= copy_rtx (result
);
7558 set_mem_attributes (result
, exp
, 0);
7564 if (TYPE_MODE (type
) != BLKmode
)
7565 target
= gen_reg_rtx (TYPE_MODE (type
));
7567 target
= assign_temp (type
, 0, 1, 1);
7570 if (GET_CODE (target
) == MEM
)
7571 /* Store data into beginning of memory target. */
7572 store_expr (TREE_OPERAND (exp
, 0),
7573 adjust_address (target
, TYPE_MODE (valtype
), 0),
7574 modifier
== EXPAND_STACK_PARM
? 2 : 0);
7576 else if (GET_CODE (target
) == REG
)
7577 /* Store this field into a union of the proper type. */
7578 store_field (target
,
7579 MIN ((int_size_in_bytes (TREE_TYPE
7580 (TREE_OPERAND (exp
, 0)))
7582 (HOST_WIDE_INT
) GET_MODE_BITSIZE (mode
)),
7583 0, TYPE_MODE (valtype
), TREE_OPERAND (exp
, 0),
7584 VOIDmode
, 0, type
, 0);
7588 /* Return the entire union. */
7592 if (mode
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0))))
7594 op0
= expand_expr (TREE_OPERAND (exp
, 0), target
, VOIDmode
,
7597 /* If the signedness of the conversion differs and OP0 is
7598 a promoted SUBREG, clear that indication since we now
7599 have to do the proper extension. */
7600 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp
, 0))) != unsignedp
7601 && GET_CODE (op0
) == SUBREG
)
7602 SUBREG_PROMOTED_VAR_P (op0
) = 0;
7607 op0
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, mode
, modifier
);
7608 if (GET_MODE (op0
) == mode
)
7611 /* If OP0 is a constant, just convert it into the proper mode. */
7612 if (CONSTANT_P (op0
))
7614 tree inner_type
= TREE_TYPE (TREE_OPERAND (exp
, 0));
7615 enum machine_mode inner_mode
= TYPE_MODE (inner_type
);
7617 if (modifier
== EXPAND_INITIALIZER
)
7618 return simplify_gen_subreg (mode
, op0
, inner_mode
,
7619 subreg_lowpart_offset (mode
,
7622 return convert_modes (mode
, inner_mode
, op0
,
7623 TREE_UNSIGNED (inner_type
));
7626 if (modifier
== EXPAND_INITIALIZER
)
7627 return gen_rtx_fmt_e (unsignedp
? ZERO_EXTEND
: SIGN_EXTEND
, mode
, op0
);
7631 convert_to_mode (mode
, op0
,
7632 TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp
, 0))));
7634 convert_move (target
, op0
,
7635 TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp
, 0))));
7638 case VIEW_CONVERT_EXPR
:
7639 op0
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, mode
, modifier
);
7641 /* If the input and output modes are both the same, we are done.
7642 Otherwise, if neither mode is BLKmode and both are integral and within
7643 a word, we can use gen_lowpart. If neither is true, make sure the
7644 operand is in memory and convert the MEM to the new mode. */
7645 if (TYPE_MODE (type
) == GET_MODE (op0
))
7647 else if (TYPE_MODE (type
) != BLKmode
&& GET_MODE (op0
) != BLKmode
7648 && GET_MODE_CLASS (GET_MODE (op0
)) == MODE_INT
7649 && GET_MODE_CLASS (TYPE_MODE (type
)) == MODE_INT
7650 && GET_MODE_SIZE (TYPE_MODE (type
)) <= UNITS_PER_WORD
7651 && GET_MODE_SIZE (GET_MODE (op0
)) <= UNITS_PER_WORD
)
7652 op0
= gen_lowpart (TYPE_MODE (type
), op0
);
7653 else if (GET_CODE (op0
) != MEM
)
7655 /* If the operand is not a MEM, force it into memory. Since we
7656 are going to be be changing the mode of the MEM, don't call
7657 force_const_mem for constants because we don't allow pool
7658 constants to change mode. */
7659 tree inner_type
= TREE_TYPE (TREE_OPERAND (exp
, 0));
7661 if (TREE_ADDRESSABLE (exp
))
7664 if (target
== 0 || GET_MODE (target
) != TYPE_MODE (inner_type
))
7666 = assign_stack_temp_for_type
7667 (TYPE_MODE (inner_type
),
7668 GET_MODE_SIZE (TYPE_MODE (inner_type
)), 0, inner_type
);
7670 emit_move_insn (target
, op0
);
7674 /* At this point, OP0 is in the correct mode. If the output type is such
7675 that the operand is known to be aligned, indicate that it is.
7676 Otherwise, we need only be concerned about alignment for non-BLKmode
7678 if (GET_CODE (op0
) == MEM
)
7680 op0
= copy_rtx (op0
);
7682 if (TYPE_ALIGN_OK (type
))
7683 set_mem_align (op0
, MAX (MEM_ALIGN (op0
), TYPE_ALIGN (type
)));
7684 else if (TYPE_MODE (type
) != BLKmode
&& STRICT_ALIGNMENT
7685 && MEM_ALIGN (op0
) < GET_MODE_ALIGNMENT (TYPE_MODE (type
)))
7687 tree inner_type
= TREE_TYPE (TREE_OPERAND (exp
, 0));
7688 HOST_WIDE_INT temp_size
7689 = MAX (int_size_in_bytes (inner_type
),
7690 (HOST_WIDE_INT
) GET_MODE_SIZE (TYPE_MODE (type
)));
7691 rtx
new = assign_stack_temp_for_type (TYPE_MODE (type
),
7692 temp_size
, 0, type
);
7693 rtx new_with_op0_mode
= adjust_address (new, GET_MODE (op0
), 0);
7695 if (TREE_ADDRESSABLE (exp
))
7698 if (GET_MODE (op0
) == BLKmode
)
7699 emit_block_move (new_with_op0_mode
, op0
,
7700 GEN_INT (GET_MODE_SIZE (TYPE_MODE (type
))),
7701 (modifier
== EXPAND_STACK_PARM
7702 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
7704 emit_move_insn (new_with_op0_mode
, op0
);
7709 op0
= adjust_address (op0
, TYPE_MODE (type
), 0);
7715 this_optab
= ! unsignedp
&& flag_trapv
7716 && (GET_MODE_CLASS (mode
) == MODE_INT
)
7717 ? addv_optab
: add_optab
;
7719 /* If we are adding a constant, an RTL_EXPR that is sp, fp, or ap, and
7720 something else, make sure we add the register to the constant and
7721 then to the other thing. This case can occur during strength
7722 reduction and doing it this way will produce better code if the
7723 frame pointer or argument pointer is eliminated.
7725 fold-const.c will ensure that the constant is always in the inner
7726 PLUS_EXPR, so the only case we need to do anything about is if
7727 sp, ap, or fp is our second argument, in which case we must swap
7728 the innermost first argument and our second argument. */
7730 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == PLUS_EXPR
7731 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 1)) == INTEGER_CST
7732 && TREE_CODE (TREE_OPERAND (exp
, 1)) == RTL_EXPR
7733 && (RTL_EXPR_RTL (TREE_OPERAND (exp
, 1)) == frame_pointer_rtx
7734 || RTL_EXPR_RTL (TREE_OPERAND (exp
, 1)) == stack_pointer_rtx
7735 || RTL_EXPR_RTL (TREE_OPERAND (exp
, 1)) == arg_pointer_rtx
))
7737 tree t
= TREE_OPERAND (exp
, 1);
7739 TREE_OPERAND (exp
, 1) = TREE_OPERAND (TREE_OPERAND (exp
, 0), 0);
7740 TREE_OPERAND (TREE_OPERAND (exp
, 0), 0) = t
;
7743 /* If the result is to be ptr_mode and we are adding an integer to
7744 something, we might be forming a constant. So try to use
7745 plus_constant. If it produces a sum and we can't accept it,
7746 use force_operand. This allows P = &ARR[const] to generate
7747 efficient code on machines where a SYMBOL_REF is not a valid
7750 If this is an EXPAND_SUM call, always return the sum. */
7751 if (modifier
== EXPAND_SUM
|| modifier
== EXPAND_INITIALIZER
7752 || (mode
== ptr_mode
&& (unsignedp
|| ! flag_trapv
)))
7754 if (modifier
== EXPAND_STACK_PARM
)
7756 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == INTEGER_CST
7757 && GET_MODE_BITSIZE (mode
) <= HOST_BITS_PER_WIDE_INT
7758 && TREE_CONSTANT (TREE_OPERAND (exp
, 1)))
7762 op1
= expand_expr (TREE_OPERAND (exp
, 1), subtarget
, VOIDmode
,
7764 /* Use immed_double_const to ensure that the constant is
7765 truncated according to the mode of OP1, then sign extended
7766 to a HOST_WIDE_INT. Using the constant directly can result
7767 in non-canonical RTL in a 64x32 cross compile. */
7769 = immed_double_const (TREE_INT_CST_LOW (TREE_OPERAND (exp
, 0)),
7771 TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 1))));
7772 op1
= plus_constant (op1
, INTVAL (constant_part
));
7773 if (modifier
!= EXPAND_SUM
&& modifier
!= EXPAND_INITIALIZER
)
7774 op1
= force_operand (op1
, target
);
7778 else if (TREE_CODE (TREE_OPERAND (exp
, 1)) == INTEGER_CST
7779 && GET_MODE_BITSIZE (mode
) <= HOST_BITS_PER_INT
7780 && TREE_CONSTANT (TREE_OPERAND (exp
, 0)))
7784 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
,
7785 (modifier
== EXPAND_INITIALIZER
7786 ? EXPAND_INITIALIZER
: EXPAND_SUM
));
7787 if (! CONSTANT_P (op0
))
7789 op1
= expand_expr (TREE_OPERAND (exp
, 1), NULL_RTX
,
7790 VOIDmode
, modifier
);
7791 /* Return a PLUS if modifier says it's OK. */
7792 if (modifier
== EXPAND_SUM
7793 || modifier
== EXPAND_INITIALIZER
)
7794 return simplify_gen_binary (PLUS
, mode
, op0
, op1
);
7797 /* Use immed_double_const to ensure that the constant is
7798 truncated according to the mode of OP1, then sign extended
7799 to a HOST_WIDE_INT. Using the constant directly can result
7800 in non-canonical RTL in a 64x32 cross compile. */
7802 = immed_double_const (TREE_INT_CST_LOW (TREE_OPERAND (exp
, 1)),
7804 TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0))));
7805 op0
= plus_constant (op0
, INTVAL (constant_part
));
7806 if (modifier
!= EXPAND_SUM
&& modifier
!= EXPAND_INITIALIZER
)
7807 op0
= force_operand (op0
, target
);
7812 /* No sense saving up arithmetic to be done
7813 if it's all in the wrong mode to form part of an address.
7814 And force_operand won't know whether to sign-extend or
7816 if ((modifier
!= EXPAND_SUM
&& modifier
!= EXPAND_INITIALIZER
)
7817 || mode
!= ptr_mode
)
7819 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7820 subtarget
, &op0
, &op1
, 0);
7821 if (op0
== const0_rtx
)
7823 if (op1
== const0_rtx
)
7828 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7829 subtarget
, &op0
, &op1
, modifier
);
7830 return simplify_gen_binary (PLUS
, mode
, op0
, op1
);
7833 /* For initializers, we are allowed to return a MINUS of two
7834 symbolic constants. Here we handle all cases when both operands
7836 /* Handle difference of two symbolic constants,
7837 for the sake of an initializer. */
7838 if ((modifier
== EXPAND_SUM
|| modifier
== EXPAND_INITIALIZER
)
7839 && really_constant_p (TREE_OPERAND (exp
, 0))
7840 && really_constant_p (TREE_OPERAND (exp
, 1)))
7842 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7843 NULL_RTX
, &op0
, &op1
, modifier
);
7845 /* If the last operand is a CONST_INT, use plus_constant of
7846 the negated constant. Else make the MINUS. */
7847 if (GET_CODE (op1
) == CONST_INT
)
7848 return plus_constant (op0
, - INTVAL (op1
));
7850 return gen_rtx_MINUS (mode
, op0
, op1
);
7853 this_optab
= ! unsignedp
&& flag_trapv
7854 && (GET_MODE_CLASS(mode
) == MODE_INT
)
7855 ? subv_optab
: sub_optab
;
7857 /* No sense saving up arithmetic to be done
7858 if it's all in the wrong mode to form part of an address.
7859 And force_operand won't know whether to sign-extend or
7861 if ((modifier
!= EXPAND_SUM
&& modifier
!= EXPAND_INITIALIZER
)
7862 || mode
!= ptr_mode
)
7865 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7866 subtarget
, &op0
, &op1
, modifier
);
7868 /* Convert A - const to A + (-const). */
7869 if (GET_CODE (op1
) == CONST_INT
)
7871 op1
= negate_rtx (mode
, op1
);
7872 return simplify_gen_binary (PLUS
, mode
, op0
, op1
);
7878 /* If first operand is constant, swap them.
7879 Thus the following special case checks need only
7880 check the second operand. */
7881 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == INTEGER_CST
)
7883 tree t1
= TREE_OPERAND (exp
, 0);
7884 TREE_OPERAND (exp
, 0) = TREE_OPERAND (exp
, 1);
7885 TREE_OPERAND (exp
, 1) = t1
;
7888 /* Attempt to return something suitable for generating an
7889 indexed address, for machines that support that. */
7891 if (modifier
== EXPAND_SUM
&& mode
== ptr_mode
7892 && host_integerp (TREE_OPERAND (exp
, 1), 0))
7894 tree exp1
= TREE_OPERAND (exp
, 1);
7896 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
,
7899 if (GET_CODE (op0
) != REG
)
7900 op0
= force_operand (op0
, NULL_RTX
);
7901 if (GET_CODE (op0
) != REG
)
7902 op0
= copy_to_mode_reg (mode
, op0
);
7904 return gen_rtx_MULT (mode
, op0
,
7905 gen_int_mode (tree_low_cst (exp1
, 0),
7906 TYPE_MODE (TREE_TYPE (exp1
))));
7909 if (modifier
== EXPAND_STACK_PARM
)
7912 /* Check for multiplying things that have been extended
7913 from a narrower type. If this machine supports multiplying
7914 in that narrower type with a result in the desired type,
7915 do it that way, and avoid the explicit type-conversion. */
7916 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == NOP_EXPR
7917 && TREE_CODE (type
) == INTEGER_TYPE
7918 && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))
7919 < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp
, 0))))
7920 && ((TREE_CODE (TREE_OPERAND (exp
, 1)) == INTEGER_CST
7921 && int_fits_type_p (TREE_OPERAND (exp
, 1),
7922 TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))
7923 /* Don't use a widening multiply if a shift will do. */
7924 && ((GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 1))))
7925 > HOST_BITS_PER_WIDE_INT
)
7926 || exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp
, 1))) < 0))
7928 (TREE_CODE (TREE_OPERAND (exp
, 1)) == NOP_EXPR
7929 && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 1), 0)))
7931 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0))))
7932 /* If both operands are extended, they must either both
7933 be zero-extended or both be sign-extended. */
7934 && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 1), 0)))
7936 TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))))))
7938 enum machine_mode innermode
7939 = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)));
7940 optab other_optab
= (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))
7941 ? smul_widen_optab
: umul_widen_optab
);
7942 this_optab
= (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0)))
7943 ? umul_widen_optab
: smul_widen_optab
);
7944 if (mode
== GET_MODE_WIDER_MODE (innermode
))
7946 if (this_optab
->handlers
[(int) mode
].insn_code
!= CODE_FOR_nothing
)
7948 if (TREE_CODE (TREE_OPERAND (exp
, 1)) == INTEGER_CST
)
7949 expand_operands (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0),
7950 TREE_OPERAND (exp
, 1),
7951 NULL_RTX
, &op0
, &op1
, 0);
7953 expand_operands (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0),
7954 TREE_OPERAND (TREE_OPERAND (exp
, 1), 0),
7955 NULL_RTX
, &op0
, &op1
, 0);
7958 else if (other_optab
->handlers
[(int) mode
].insn_code
!= CODE_FOR_nothing
7959 && innermode
== word_mode
)
7962 op0
= expand_expr (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0),
7963 NULL_RTX
, VOIDmode
, 0);
7964 if (TREE_CODE (TREE_OPERAND (exp
, 1)) == INTEGER_CST
)
7965 op1
= convert_modes (innermode
, mode
,
7966 expand_expr (TREE_OPERAND (exp
, 1),
7967 NULL_RTX
, VOIDmode
, 0),
7970 op1
= expand_expr (TREE_OPERAND (TREE_OPERAND (exp
, 1), 0),
7971 NULL_RTX
, VOIDmode
, 0);
7972 temp
= expand_binop (mode
, other_optab
, op0
, op1
, target
,
7973 unsignedp
, OPTAB_LIB_WIDEN
);
7974 htem
= expand_mult_highpart_adjust (innermode
,
7975 gen_highpart (innermode
, temp
),
7977 gen_highpart (innermode
, temp
),
7979 emit_move_insn (gen_highpart (innermode
, temp
), htem
);
7984 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7985 subtarget
, &op0
, &op1
, 0);
7986 return expand_mult (mode
, op0
, op1
, target
, unsignedp
);
7988 case TRUNC_DIV_EXPR
:
7989 case FLOOR_DIV_EXPR
:
7991 case ROUND_DIV_EXPR
:
7992 case EXACT_DIV_EXPR
:
7993 if (modifier
== EXPAND_STACK_PARM
)
7995 /* Possible optimization: compute the dividend with EXPAND_SUM
7996 then if the divisor is constant can optimize the case
7997 where some terms of the dividend have coeffs divisible by it. */
7998 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
7999 subtarget
, &op0
, &op1
, 0);
8000 return expand_divmod (0, code
, mode
, op0
, op1
, target
, unsignedp
);
8003 /* Emit a/b as a*(1/b). Later we may manage CSE the reciprocal saving
8004 expensive divide. If not, combine will rebuild the original
8006 if (flag_unsafe_math_optimizations
&& optimize
&& !optimize_size
8007 && TREE_CODE (type
) == REAL_TYPE
8008 && !real_onep (TREE_OPERAND (exp
, 0)))
8009 return expand_expr (build (MULT_EXPR
, type
, TREE_OPERAND (exp
, 0),
8010 build (RDIV_EXPR
, type
,
8011 build_real (type
, dconst1
),
8012 TREE_OPERAND (exp
, 1))),
8013 target
, tmode
, modifier
);
8014 this_optab
= sdiv_optab
;
8017 case TRUNC_MOD_EXPR
:
8018 case FLOOR_MOD_EXPR
:
8020 case ROUND_MOD_EXPR
:
8021 if (modifier
== EXPAND_STACK_PARM
)
8023 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
8024 subtarget
, &op0
, &op1
, 0);
8025 return expand_divmod (1, code
, mode
, op0
, op1
, target
, unsignedp
);
8027 case FIX_ROUND_EXPR
:
8028 case FIX_FLOOR_EXPR
:
8030 abort (); /* Not used for C. */
8032 case FIX_TRUNC_EXPR
:
8033 op0
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, VOIDmode
, 0);
8034 if (target
== 0 || modifier
== EXPAND_STACK_PARM
)
8035 target
= gen_reg_rtx (mode
);
8036 expand_fix (target
, op0
, unsignedp
);
8040 op0
= expand_expr (TREE_OPERAND (exp
, 0), NULL_RTX
, VOIDmode
, 0);
8041 if (target
== 0 || modifier
== EXPAND_STACK_PARM
)
8042 target
= gen_reg_rtx (mode
);
8043 /* expand_float can't figure out what to do if FROM has VOIDmode.
8044 So give it the correct mode. With -O, cse will optimize this. */
8045 if (GET_MODE (op0
) == VOIDmode
)
8046 op0
= copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0))),
8048 expand_float (target
, op0
,
8049 TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp
, 0))));
8053 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
, 0);
8054 if (modifier
== EXPAND_STACK_PARM
)
8056 temp
= expand_unop (mode
,
8057 ! unsignedp
&& flag_trapv
8058 && (GET_MODE_CLASS(mode
) == MODE_INT
)
8059 ? negv_optab
: neg_optab
, op0
, target
, 0);
8065 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
, 0);
8066 if (modifier
== EXPAND_STACK_PARM
)
8069 /* ABS_EXPR is not valid for complex arguments. */
8070 if (GET_MODE_CLASS (mode
) == MODE_COMPLEX_INT
8071 || GET_MODE_CLASS (mode
) == MODE_COMPLEX_FLOAT
)
8074 /* Unsigned abs is simply the operand. Testing here means we don't
8075 risk generating incorrect code below. */
8076 if (TREE_UNSIGNED (type
))
8079 return expand_abs (mode
, op0
, target
, unsignedp
,
8080 safe_from_p (target
, TREE_OPERAND (exp
, 0), 1));
8084 target
= original_target
;
8086 || modifier
== EXPAND_STACK_PARM
8087 || (GET_CODE (target
) == MEM
&& MEM_VOLATILE_P (target
))
8088 || GET_MODE (target
) != mode
8089 || (GET_CODE (target
) == REG
8090 && REGNO (target
) < FIRST_PSEUDO_REGISTER
))
8091 target
= gen_reg_rtx (mode
);
8092 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
8093 target
, &op0
, &op1
, 0);
8095 /* First try to do it with a special MIN or MAX instruction.
8096 If that does not win, use a conditional jump to select the proper
8098 this_optab
= (unsignedp
8099 ? (code
== MIN_EXPR
? umin_optab
: umax_optab
)
8100 : (code
== MIN_EXPR
? smin_optab
: smax_optab
));
8102 temp
= expand_binop (mode
, this_optab
, op0
, op1
, target
, unsignedp
,
8107 /* At this point, a MEM target is no longer useful; we will get better
8110 if (! REG_P (target
))
8111 target
= gen_reg_rtx (mode
);
8113 /* If op1 was placed in target, swap op0 and op1. */
8114 if (target
!= op0
&& target
== op1
)
8121 /* We generate better code and avoid problems with op1 mentioning
8122 target by forcing op1 into a pseudo if it isn't a constant. */
8123 if (! CONSTANT_P (op1
))
8124 op1
= force_reg (mode
, op1
);
8127 emit_move_insn (target
, op0
);
8129 op0
= gen_label_rtx ();
8131 /* If this mode is an integer too wide to compare properly,
8132 compare word by word. Rely on cse to optimize constant cases. */
8133 if (GET_MODE_CLASS (mode
) == MODE_INT
8134 && ! can_compare_p (GE
, mode
, ccp_jump
))
8136 if (code
== MAX_EXPR
)
8137 do_jump_by_parts_greater_rtx (mode
, unsignedp
, target
, op1
,
8140 do_jump_by_parts_greater_rtx (mode
, unsignedp
, op1
, target
,
8145 do_compare_rtx_and_jump (target
, op1
, code
== MAX_EXPR
? GE
: LE
,
8146 unsignedp
, mode
, NULL_RTX
, NULL_RTX
, op0
);
8148 emit_move_insn (target
, op1
);
8153 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
, 0);
8154 if (modifier
== EXPAND_STACK_PARM
)
8156 temp
= expand_unop (mode
, one_cmpl_optab
, op0
, target
, 1);
8161 /* ??? Can optimize bitwise operations with one arg constant.
8162 Can optimize (a bitwise1 n) bitwise2 (a bitwise3 b)
8163 and (a bitwise1 b) bitwise2 b (etc)
8164 but that is probably not worth while. */
8166 /* BIT_AND_EXPR is for bitwise anding. TRUTH_AND_EXPR is for anding two
8167 boolean values when we want in all cases to compute both of them. In
8168 general it is fastest to do TRUTH_AND_EXPR by computing both operands
8169 as actual zero-or-1 values and then bitwise anding. In cases where
8170 there cannot be any side effects, better code would be made by
8171 treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; but the question is
8172 how to recognize those cases. */
8174 case TRUTH_AND_EXPR
:
8176 this_optab
= and_optab
;
8181 this_optab
= ior_optab
;
8184 case TRUTH_XOR_EXPR
:
8186 this_optab
= xor_optab
;
8193 if (! safe_from_p (subtarget
, TREE_OPERAND (exp
, 1), 1))
8195 if (modifier
== EXPAND_STACK_PARM
)
8197 op0
= expand_expr (TREE_OPERAND (exp
, 0), subtarget
, VOIDmode
, 0);
8198 return expand_shift (code
, mode
, op0
, TREE_OPERAND (exp
, 1), target
,
8201 /* Could determine the answer when only additive constants differ. Also,
8202 the addition of one can be handled by changing the condition. */
8209 case UNORDERED_EXPR
:
8216 temp
= do_store_flag (exp
,
8217 modifier
!= EXPAND_STACK_PARM
? target
: NULL_RTX
,
8218 tmode
!= VOIDmode
? tmode
: mode
, 0);
8222 /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
8223 if (code
== NE_EXPR
&& integer_zerop (TREE_OPERAND (exp
, 1))
8225 && GET_CODE (original_target
) == REG
8226 && (GET_MODE (original_target
)
8227 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0)))))
8229 temp
= expand_expr (TREE_OPERAND (exp
, 0), original_target
,
8232 /* If temp is constant, we can just compute the result. */
8233 if (GET_CODE (temp
) == CONST_INT
)
8235 if (INTVAL (temp
) != 0)
8236 emit_move_insn (target
, const1_rtx
);
8238 emit_move_insn (target
, const0_rtx
);
8243 if (temp
!= original_target
)
8245 enum machine_mode mode1
= GET_MODE (temp
);
8246 if (mode1
== VOIDmode
)
8247 mode1
= tmode
!= VOIDmode
? tmode
: mode
;
8249 temp
= copy_to_mode_reg (mode1
, temp
);
8252 op1
= gen_label_rtx ();
8253 emit_cmp_and_jump_insns (temp
, const0_rtx
, EQ
, NULL_RTX
,
8254 GET_MODE (temp
), unsignedp
, op1
);
8255 emit_move_insn (temp
, const1_rtx
);
8260 /* If no set-flag instruction, must generate a conditional
8261 store into a temporary variable. Drop through
8262 and handle this like && and ||. */
8264 case TRUTH_ANDIF_EXPR
:
8265 case TRUTH_ORIF_EXPR
:
8268 || modifier
== EXPAND_STACK_PARM
8269 || ! safe_from_p (target
, exp
, 1)
8270 /* Make sure we don't have a hard reg (such as function's return
8271 value) live across basic blocks, if not optimizing. */
8272 || (!optimize
&& GET_CODE (target
) == REG
8273 && REGNO (target
) < FIRST_PSEUDO_REGISTER
)))
8274 target
= gen_reg_rtx (tmode
!= VOIDmode
? tmode
: mode
);
8277 emit_clr_insn (target
);
8279 op1
= gen_label_rtx ();
8280 jumpifnot (exp
, op1
);
8283 emit_0_to_1_insn (target
);
8286 return ignore
? const0_rtx
: target
;
8288 case TRUTH_NOT_EXPR
:
8289 if (modifier
== EXPAND_STACK_PARM
)
8291 op0
= expand_expr (TREE_OPERAND (exp
, 0), target
, VOIDmode
, 0);
8292 /* The parser is careful to generate TRUTH_NOT_EXPR
8293 only with operands that are always zero or one. */
8294 temp
= expand_binop (mode
, xor_optab
, op0
, const1_rtx
,
8295 target
, 1, OPTAB_LIB_WIDEN
);
8301 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
, 0);
8303 return expand_expr_real (TREE_OPERAND (exp
, 1),
8304 (ignore
? const0_rtx
: target
),
8305 VOIDmode
, modifier
, alt_rtl
);
8308 /* If we would have a "singleton" (see below) were it not for a
8309 conversion in each arm, bring that conversion back out. */
8310 if (TREE_CODE (TREE_OPERAND (exp
, 1)) == NOP_EXPR
8311 && TREE_CODE (TREE_OPERAND (exp
, 2)) == NOP_EXPR
8312 && (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 1), 0))
8313 == TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp
, 2), 0))))
8315 tree iftrue
= TREE_OPERAND (TREE_OPERAND (exp
, 1), 0);
8316 tree iffalse
= TREE_OPERAND (TREE_OPERAND (exp
, 2), 0);
8318 if ((TREE_CODE_CLASS (TREE_CODE (iftrue
)) == '2'
8319 && operand_equal_p (iffalse
, TREE_OPERAND (iftrue
, 0), 0))
8320 || (TREE_CODE_CLASS (TREE_CODE (iffalse
)) == '2'
8321 && operand_equal_p (iftrue
, TREE_OPERAND (iffalse
, 0), 0))
8322 || (TREE_CODE_CLASS (TREE_CODE (iftrue
)) == '1'
8323 && operand_equal_p (iffalse
, TREE_OPERAND (iftrue
, 0), 0))
8324 || (TREE_CODE_CLASS (TREE_CODE (iffalse
)) == '1'
8325 && operand_equal_p (iftrue
, TREE_OPERAND (iffalse
, 0), 0)))
8326 return expand_expr (build1 (NOP_EXPR
, type
,
8327 build (COND_EXPR
, TREE_TYPE (iftrue
),
8328 TREE_OPERAND (exp
, 0),
8330 target
, tmode
, modifier
);
8334 /* Note that COND_EXPRs whose type is a structure or union
8335 are required to be constructed to contain assignments of
8336 a temporary variable, so that we can evaluate them here
8337 for side effect only. If type is void, we must do likewise. */
8339 /* If an arm of the branch requires a cleanup,
8340 only that cleanup is performed. */
8343 tree binary_op
= 0, unary_op
= 0;
8345 /* If this is (A ? 1 : 0) and A is a condition, just evaluate it and
8346 convert it to our mode, if necessary. */
8347 if (integer_onep (TREE_OPERAND (exp
, 1))
8348 && integer_zerop (TREE_OPERAND (exp
, 2))
8349 && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == '<')
8353 expand_expr (TREE_OPERAND (exp
, 0), const0_rtx
, VOIDmode
,
8358 if (modifier
== EXPAND_STACK_PARM
)
8360 op0
= expand_expr (TREE_OPERAND (exp
, 0), target
, mode
, modifier
);
8361 if (GET_MODE (op0
) == mode
)
8365 target
= gen_reg_rtx (mode
);
8366 convert_move (target
, op0
, unsignedp
);
8370 /* Check for X ? A + B : A. If we have this, we can copy A to the
8371 output and conditionally add B. Similarly for unary operations.
8372 Don't do this if X has side-effects because those side effects
8373 might affect A or B and the "?" operation is a sequence point in
8374 ANSI. (operand_equal_p tests for side effects.) */
8376 if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 1))) == '2'
8377 && operand_equal_p (TREE_OPERAND (exp
, 2),
8378 TREE_OPERAND (TREE_OPERAND (exp
, 1), 0), 0))
8379 singleton
= TREE_OPERAND (exp
, 2), binary_op
= TREE_OPERAND (exp
, 1);
8380 else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 2))) == '2'
8381 && operand_equal_p (TREE_OPERAND (exp
, 1),
8382 TREE_OPERAND (TREE_OPERAND (exp
, 2), 0), 0))
8383 singleton
= TREE_OPERAND (exp
, 1), binary_op
= TREE_OPERAND (exp
, 2);
8384 else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 1))) == '1'
8385 && operand_equal_p (TREE_OPERAND (exp
, 2),
8386 TREE_OPERAND (TREE_OPERAND (exp
, 1), 0), 0))
8387 singleton
= TREE_OPERAND (exp
, 2), unary_op
= TREE_OPERAND (exp
, 1);
8388 else if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 2))) == '1'
8389 && operand_equal_p (TREE_OPERAND (exp
, 1),
8390 TREE_OPERAND (TREE_OPERAND (exp
, 2), 0), 0))
8391 singleton
= TREE_OPERAND (exp
, 1), unary_op
= TREE_OPERAND (exp
, 2);
8393 /* If we are not to produce a result, we have no target. Otherwise,
8394 if a target was specified use it; it will not be used as an
8395 intermediate target unless it is safe. If no target, use a
8400 else if (modifier
== EXPAND_STACK_PARM
)
8401 temp
= assign_temp (type
, 0, 0, 1);
8402 else if (original_target
8403 && (safe_from_p (original_target
, TREE_OPERAND (exp
, 0), 1)
8404 || (singleton
&& GET_CODE (original_target
) == REG
8405 && REGNO (original_target
) >= FIRST_PSEUDO_REGISTER
8406 && original_target
== var_rtx (singleton
)))
8407 && GET_MODE (original_target
) == mode
8408 #ifdef HAVE_conditional_move
8409 && (! can_conditionally_move_p (mode
)
8410 || GET_CODE (original_target
) == REG
8411 || TREE_ADDRESSABLE (type
))
8413 && (GET_CODE (original_target
) != MEM
8414 || TREE_ADDRESSABLE (type
)))
8415 temp
= original_target
;
8416 else if (TREE_ADDRESSABLE (type
))
8419 temp
= assign_temp (type
, 0, 0, 1);
8421 /* If we had X ? A + C : A, with C a constant power of 2, and we can
8422 do the test of X as a store-flag operation, do this as
8423 A + ((X != 0) << log C). Similarly for other simple binary
8424 operators. Only do for C == 1 if BRANCH_COST is low. */
8425 if (temp
&& singleton
&& binary_op
8426 && (TREE_CODE (binary_op
) == PLUS_EXPR
8427 || TREE_CODE (binary_op
) == MINUS_EXPR
8428 || TREE_CODE (binary_op
) == BIT_IOR_EXPR
8429 || TREE_CODE (binary_op
) == BIT_XOR_EXPR
)
8430 && (BRANCH_COST
>= 3 ? integer_pow2p (TREE_OPERAND (binary_op
, 1))
8431 : integer_onep (TREE_OPERAND (binary_op
, 1)))
8432 && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == '<')
8436 optab boptab
= (TREE_CODE (binary_op
) == PLUS_EXPR
8437 ? (TYPE_TRAP_SIGNED (TREE_TYPE (binary_op
))
8438 ? addv_optab
: add_optab
)
8439 : TREE_CODE (binary_op
) == MINUS_EXPR
8440 ? (TYPE_TRAP_SIGNED (TREE_TYPE (binary_op
))
8441 ? subv_optab
: sub_optab
)
8442 : TREE_CODE (binary_op
) == BIT_IOR_EXPR
? ior_optab
8445 /* If we had X ? A : A + 1, do this as A + (X == 0). */
8446 if (singleton
== TREE_OPERAND (exp
, 1))
8447 cond
= invert_truthvalue (TREE_OPERAND (exp
, 0));
8449 cond
= TREE_OPERAND (exp
, 0);
8451 result
= do_store_flag (cond
, (safe_from_p (temp
, singleton
, 1)
8453 mode
, BRANCH_COST
<= 1);
8455 if (result
!= 0 && ! integer_onep (TREE_OPERAND (binary_op
, 1)))
8456 result
= expand_shift (LSHIFT_EXPR
, mode
, result
,
8457 build_int_2 (tree_log2
8461 (safe_from_p (temp
, singleton
, 1)
8462 ? temp
: NULL_RTX
), 0);
8466 op1
= expand_expr (singleton
, NULL_RTX
, VOIDmode
, 0);
8467 return expand_binop (mode
, boptab
, op1
, result
, temp
,
8468 unsignedp
, OPTAB_LIB_WIDEN
);
8472 do_pending_stack_adjust ();
8474 op0
= gen_label_rtx ();
8476 if (singleton
&& ! TREE_SIDE_EFFECTS (TREE_OPERAND (exp
, 0)))
8480 /* If the target conflicts with the other operand of the
8481 binary op, we can't use it. Also, we can't use the target
8482 if it is a hard register, because evaluating the condition
8483 might clobber it. */
8485 && ! safe_from_p (temp
, TREE_OPERAND (binary_op
, 1), 1))
8486 || (GET_CODE (temp
) == REG
8487 && REGNO (temp
) < FIRST_PSEUDO_REGISTER
))
8488 temp
= gen_reg_rtx (mode
);
8489 store_expr (singleton
, temp
,
8490 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8493 expand_expr (singleton
,
8494 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8495 if (singleton
== TREE_OPERAND (exp
, 1))
8496 jumpif (TREE_OPERAND (exp
, 0), op0
);
8498 jumpifnot (TREE_OPERAND (exp
, 0), op0
);
8500 start_cleanup_deferral ();
8501 if (binary_op
&& temp
== 0)
8502 /* Just touch the other operand. */
8503 expand_expr (TREE_OPERAND (binary_op
, 1),
8504 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8506 store_expr (build (TREE_CODE (binary_op
), type
,
8507 make_tree (type
, temp
),
8508 TREE_OPERAND (binary_op
, 1)),
8509 temp
, modifier
== EXPAND_STACK_PARM
? 2 : 0);
8511 store_expr (build1 (TREE_CODE (unary_op
), type
,
8512 make_tree (type
, temp
)),
8513 temp
, modifier
== EXPAND_STACK_PARM
? 2 : 0);
8516 /* Check for A op 0 ? A : FOO and A op 0 ? FOO : A where OP is any
8517 comparison operator. If we have one of these cases, set the
8518 output to A, branch on A (cse will merge these two references),
8519 then set the output to FOO. */
8521 && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == '<'
8522 && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp
, 0), 1))
8523 && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0),
8524 TREE_OPERAND (exp
, 1), 0)
8525 && (! TREE_SIDE_EFFECTS (TREE_OPERAND (exp
, 0))
8526 || TREE_CODE (TREE_OPERAND (exp
, 1)) == SAVE_EXPR
)
8527 && safe_from_p (temp
, TREE_OPERAND (exp
, 2), 1))
8529 if (GET_CODE (temp
) == REG
8530 && REGNO (temp
) < FIRST_PSEUDO_REGISTER
)
8531 temp
= gen_reg_rtx (mode
);
8532 store_expr (TREE_OPERAND (exp
, 1), temp
,
8533 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8534 jumpif (TREE_OPERAND (exp
, 0), op0
);
8536 start_cleanup_deferral ();
8537 if (TREE_TYPE (TREE_OPERAND (exp
, 2)) != void_type_node
)
8538 store_expr (TREE_OPERAND (exp
, 2), temp
,
8539 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8541 expand_expr (TREE_OPERAND (exp
, 2),
8542 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8546 && TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0))) == '<'
8547 && integer_zerop (TREE_OPERAND (TREE_OPERAND (exp
, 0), 1))
8548 && operand_equal_p (TREE_OPERAND (TREE_OPERAND (exp
, 0), 0),
8549 TREE_OPERAND (exp
, 2), 0)
8550 && (! TREE_SIDE_EFFECTS (TREE_OPERAND (exp
, 0))
8551 || TREE_CODE (TREE_OPERAND (exp
, 2)) == SAVE_EXPR
)
8552 && safe_from_p (temp
, TREE_OPERAND (exp
, 1), 1))
8554 if (GET_CODE (temp
) == REG
8555 && REGNO (temp
) < FIRST_PSEUDO_REGISTER
)
8556 temp
= gen_reg_rtx (mode
);
8557 store_expr (TREE_OPERAND (exp
, 2), temp
,
8558 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8559 jumpifnot (TREE_OPERAND (exp
, 0), op0
);
8561 start_cleanup_deferral ();
8562 if (TREE_TYPE (TREE_OPERAND (exp
, 1)) != void_type_node
)
8563 store_expr (TREE_OPERAND (exp
, 1), temp
,
8564 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8566 expand_expr (TREE_OPERAND (exp
, 1),
8567 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8572 op1
= gen_label_rtx ();
8573 jumpifnot (TREE_OPERAND (exp
, 0), op0
);
8575 start_cleanup_deferral ();
8577 /* One branch of the cond can be void, if it never returns. For
8578 example A ? throw : E */
8580 && TREE_TYPE (TREE_OPERAND (exp
, 1)) != void_type_node
)
8581 store_expr (TREE_OPERAND (exp
, 1), temp
,
8582 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8584 expand_expr (TREE_OPERAND (exp
, 1),
8585 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8586 end_cleanup_deferral ();
8588 emit_jump_insn (gen_jump (op1
));
8591 start_cleanup_deferral ();
8593 && TREE_TYPE (TREE_OPERAND (exp
, 2)) != void_type_node
)
8594 store_expr (TREE_OPERAND (exp
, 2), temp
,
8595 modifier
== EXPAND_STACK_PARM
? 2 : 0);
8597 expand_expr (TREE_OPERAND (exp
, 2),
8598 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
, 0);
8601 end_cleanup_deferral ();
8612 /* Something needs to be initialized, but we didn't know
8613 where that thing was when building the tree. For example,
8614 it could be the return value of a function, or a parameter
8615 to a function which lays down in the stack, or a temporary
8616 variable which must be passed by reference.
8618 We guarantee that the expression will either be constructed
8619 or copied into our original target. */
8621 tree slot
= TREE_OPERAND (exp
, 0);
8622 tree cleanups
= NULL_TREE
;
8625 if (TREE_CODE (slot
) != VAR_DECL
)
8629 target
= original_target
;
8631 /* Set this here so that if we get a target that refers to a
8632 register variable that's already been used, put_reg_into_stack
8633 knows that it should fix up those uses. */
8634 TREE_USED (slot
) = 1;
8638 if (DECL_RTL_SET_P (slot
))
8640 target
= DECL_RTL (slot
);
8641 /* If we have already expanded the slot, so don't do
8643 if (TREE_OPERAND (exp
, 1) == NULL_TREE
)
8648 target
= assign_temp (type
, 2, 0, 1);
8649 SET_DECL_RTL (slot
, target
);
8650 if (TREE_ADDRESSABLE (slot
))
8651 put_var_into_stack (slot
, /*rescan=*/false);
8653 /* Since SLOT is not known to the called function
8654 to belong to its stack frame, we must build an explicit
8655 cleanup. This case occurs when we must build up a reference
8656 to pass the reference as an argument. In this case,
8657 it is very likely that such a reference need not be
8660 if (TREE_OPERAND (exp
, 2) == 0)
8661 TREE_OPERAND (exp
, 2)
8662 = (*lang_hooks
.maybe_build_cleanup
) (slot
);
8663 cleanups
= TREE_OPERAND (exp
, 2);
8668 /* This case does occur, when expanding a parameter which
8669 needs to be constructed on the stack. The target
8670 is the actual stack address that we want to initialize.
8671 The function we call will perform the cleanup in this case. */
8673 /* If we have already assigned it space, use that space,
8674 not target that we were passed in, as our target
8675 parameter is only a hint. */
8676 if (DECL_RTL_SET_P (slot
))
8678 target
= DECL_RTL (slot
);
8679 /* If we have already expanded the slot, so don't do
8681 if (TREE_OPERAND (exp
, 1) == NULL_TREE
)
8686 SET_DECL_RTL (slot
, target
);
8687 /* If we must have an addressable slot, then make sure that
8688 the RTL that we just stored in slot is OK. */
8689 if (TREE_ADDRESSABLE (slot
))
8690 put_var_into_stack (slot
, /*rescan=*/true);
8694 exp1
= TREE_OPERAND (exp
, 3) = TREE_OPERAND (exp
, 1);
8695 /* Mark it as expanded. */
8696 TREE_OPERAND (exp
, 1) = NULL_TREE
;
8698 store_expr (exp1
, target
, modifier
== EXPAND_STACK_PARM
? 2 : 0);
8700 expand_decl_cleanup_eh (NULL_TREE
, cleanups
, CLEANUP_EH_ONLY (exp
));
8707 tree lhs
= TREE_OPERAND (exp
, 0);
8708 tree rhs
= TREE_OPERAND (exp
, 1);
8710 temp
= expand_assignment (lhs
, rhs
, ! ignore
);
8716 /* If lhs is complex, expand calls in rhs before computing it.
8717 That's so we don't compute a pointer and save it over a
8718 call. If lhs is simple, compute it first so we can give it
8719 as a target if the rhs is just a call. This avoids an
8720 extra temp and copy and that prevents a partial-subsumption
8721 which makes bad code. Actually we could treat
8722 component_ref's of vars like vars. */
8724 tree lhs
= TREE_OPERAND (exp
, 0);
8725 tree rhs
= TREE_OPERAND (exp
, 1);
8729 /* Check for |= or &= of a bitfield of size one into another bitfield
8730 of size 1. In this case, (unless we need the result of the
8731 assignment) we can do this more efficiently with a
8732 test followed by an assignment, if necessary.
8734 ??? At this point, we can't get a BIT_FIELD_REF here. But if
8735 things change so we do, this code should be enhanced to
8738 && TREE_CODE (lhs
) == COMPONENT_REF
8739 && (TREE_CODE (rhs
) == BIT_IOR_EXPR
8740 || TREE_CODE (rhs
) == BIT_AND_EXPR
)
8741 && TREE_OPERAND (rhs
, 0) == lhs
8742 && TREE_CODE (TREE_OPERAND (rhs
, 1)) == COMPONENT_REF
8743 && integer_onep (DECL_SIZE (TREE_OPERAND (lhs
, 1)))
8744 && integer_onep (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs
, 1), 1))))
8746 rtx label
= gen_label_rtx ();
8748 do_jump (TREE_OPERAND (rhs
, 1),
8749 TREE_CODE (rhs
) == BIT_IOR_EXPR
? label
: 0,
8750 TREE_CODE (rhs
) == BIT_AND_EXPR
? label
: 0);
8751 expand_assignment (lhs
, convert (TREE_TYPE (rhs
),
8752 (TREE_CODE (rhs
) == BIT_IOR_EXPR
8754 : integer_zero_node
)),
8756 do_pending_stack_adjust ();
8761 temp
= expand_assignment (lhs
, rhs
, ! ignore
);
8767 if (!TREE_OPERAND (exp
, 0))
8768 expand_null_return ();
8770 expand_return (TREE_OPERAND (exp
, 0));
8773 case PREINCREMENT_EXPR
:
8774 case PREDECREMENT_EXPR
:
8775 return expand_increment (exp
, 0, ignore
);
8777 case POSTINCREMENT_EXPR
:
8778 case POSTDECREMENT_EXPR
:
8779 /* Faster to treat as pre-increment if result is not used. */
8780 return expand_increment (exp
, ! ignore
, ignore
);
8783 if (modifier
== EXPAND_STACK_PARM
)
8785 /* Are we taking the address of a nested function? */
8786 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == FUNCTION_DECL
8787 && decl_function_context (TREE_OPERAND (exp
, 0)) != 0
8788 && ! DECL_NO_STATIC_CHAIN (TREE_OPERAND (exp
, 0))
8789 && ! TREE_STATIC (exp
))
8791 op0
= trampoline_address (TREE_OPERAND (exp
, 0));
8792 op0
= force_operand (op0
, target
);
8794 /* If we are taking the address of something erroneous, just
8796 else if (TREE_CODE (TREE_OPERAND (exp
, 0)) == ERROR_MARK
)
8798 /* If we are taking the address of a constant and are at the
8799 top level, we have to use output_constant_def since we can't
8800 call force_const_mem at top level. */
8802 && (TREE_CODE (TREE_OPERAND (exp
, 0)) == CONSTRUCTOR
8803 || (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp
, 0)))
8805 op0
= XEXP (output_constant_def (TREE_OPERAND (exp
, 0), 0), 0);
8808 /* We make sure to pass const0_rtx down if we came in with
8809 ignore set, to avoid doing the cleanups twice for something. */
8810 op0
= expand_expr (TREE_OPERAND (exp
, 0),
8811 ignore
? const0_rtx
: NULL_RTX
, VOIDmode
,
8812 (modifier
== EXPAND_INITIALIZER
8813 ? modifier
: EXPAND_CONST_ADDRESS
));
8815 /* If we are going to ignore the result, OP0 will have been set
8816 to const0_rtx, so just return it. Don't get confused and
8817 think we are taking the address of the constant. */
8821 /* Pass 1 for MODIFY, so that protect_from_queue doesn't get
8822 clever and returns a REG when given a MEM. */
8823 op0
= protect_from_queue (op0
, 1);
8825 /* We would like the object in memory. If it is a constant, we can
8826 have it be statically allocated into memory. For a non-constant,
8827 we need to allocate some memory and store the value into it. */
8829 if (CONSTANT_P (op0
))
8830 op0
= force_const_mem (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp
, 0))),
8832 else if (GET_CODE (op0
) == REG
|| GET_CODE (op0
) == SUBREG
8833 || GET_CODE (op0
) == CONCAT
|| GET_CODE (op0
) == ADDRESSOF
8834 || GET_CODE (op0
) == PARALLEL
|| GET_CODE (op0
) == LO_SUM
)
8836 /* If the operand is a SAVE_EXPR, we can deal with this by
8837 forcing the SAVE_EXPR into memory. */
8838 if (TREE_CODE (TREE_OPERAND (exp
, 0)) == SAVE_EXPR
)
8840 put_var_into_stack (TREE_OPERAND (exp
, 0),
8842 op0
= SAVE_EXPR_RTL (TREE_OPERAND (exp
, 0));
8846 /* If this object is in a register, it can't be BLKmode. */
8847 tree inner_type
= TREE_TYPE (TREE_OPERAND (exp
, 0));
8848 rtx memloc
= assign_temp (inner_type
, 1, 1, 1);
8850 if (GET_CODE (op0
) == PARALLEL
)
8851 /* Handle calls that pass values in multiple
8852 non-contiguous locations. The Irix 6 ABI has examples
8854 emit_group_store (memloc
, op0
, inner_type
,
8855 int_size_in_bytes (inner_type
));
8857 emit_move_insn (memloc
, op0
);
8863 if (GET_CODE (op0
) != MEM
)
8866 mark_temp_addr_taken (op0
);
8867 if (modifier
== EXPAND_SUM
|| modifier
== EXPAND_INITIALIZER
)
8869 op0
= XEXP (op0
, 0);
8870 if (GET_MODE (op0
) == Pmode
&& mode
== ptr_mode
)
8871 op0
= convert_memory_address (ptr_mode
, op0
);
8875 /* If OP0 is not aligned as least as much as the type requires, we
8876 need to make a temporary, copy OP0 to it, and take the address of
8877 the temporary. We want to use the alignment of the type, not of
8878 the operand. Note that this is incorrect for FUNCTION_TYPE, but
8879 the test for BLKmode means that can't happen. The test for
8880 BLKmode is because we never make mis-aligned MEMs with
8883 We don't need to do this at all if the machine doesn't have
8884 strict alignment. */
8885 if (STRICT_ALIGNMENT
&& GET_MODE (op0
) == BLKmode
8886 && (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp
, 0)))
8888 && MEM_ALIGN (op0
) < BIGGEST_ALIGNMENT
)
8890 tree inner_type
= TREE_TYPE (TREE_OPERAND (exp
, 0));
8893 if (TYPE_ALIGN_OK (inner_type
))
8896 if (TREE_ADDRESSABLE (inner_type
))
8898 /* We can't make a bitwise copy of this object, so fail. */
8899 error ("cannot take the address of an unaligned member");
8903 new = assign_stack_temp_for_type
8904 (TYPE_MODE (inner_type
),
8905 MEM_SIZE (op0
) ? INTVAL (MEM_SIZE (op0
))
8906 : int_size_in_bytes (inner_type
),
8907 1, build_qualified_type (inner_type
,
8908 (TYPE_QUALS (inner_type
)
8909 | TYPE_QUAL_CONST
)));
8911 emit_block_move (new, op0
, expr_size (TREE_OPERAND (exp
, 0)),
8912 (modifier
== EXPAND_STACK_PARM
8913 ? BLOCK_OP_CALL_PARM
: BLOCK_OP_NORMAL
));
8918 op0
= force_operand (XEXP (op0
, 0), target
);
8922 && GET_CODE (op0
) != REG
8923 && modifier
!= EXPAND_CONST_ADDRESS
8924 && modifier
!= EXPAND_INITIALIZER
8925 && modifier
!= EXPAND_SUM
)
8926 op0
= force_reg (Pmode
, op0
);
8928 if (GET_CODE (op0
) == REG
8929 && ! REG_USERVAR_P (op0
))
8930 mark_reg_pointer (op0
, TYPE_ALIGN (TREE_TYPE (type
)));
8932 if (GET_MODE (op0
) == Pmode
&& mode
== ptr_mode
)
8933 op0
= convert_memory_address (ptr_mode
, op0
);
8937 case ENTRY_VALUE_EXPR
:
8940 /* COMPLEX type for Extended Pascal & Fortran */
8943 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (TREE_TYPE (exp
)));
8946 /* Get the rtx code of the operands. */
8947 op0
= expand_expr (TREE_OPERAND (exp
, 0), 0, VOIDmode
, 0);
8948 op1
= expand_expr (TREE_OPERAND (exp
, 1), 0, VOIDmode
, 0);
8951 target
= gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp
)));
8955 /* Move the real (op0) and imaginary (op1) parts to their location. */
8956 emit_move_insn (gen_realpart (mode
, target
), op0
);
8957 emit_move_insn (gen_imagpart (mode
, target
), op1
);
8959 insns
= get_insns ();
8962 /* Complex construction should appear as a single unit. */
8963 /* If TARGET is a CONCAT, we got insns like RD = RS, ID = IS,
8964 each with a separate pseudo as destination.
8965 It's not correct for flow to treat them as a unit. */
8966 if (GET_CODE (target
) != CONCAT
)
8967 emit_no_conflict_block (insns
, target
, op0
, op1
, NULL_RTX
);
8975 op0
= expand_expr (TREE_OPERAND (exp
, 0), 0, VOIDmode
, 0);
8976 return gen_realpart (mode
, op0
);
8979 op0
= expand_expr (TREE_OPERAND (exp
, 0), 0, VOIDmode
, 0);
8980 return gen_imagpart (mode
, op0
);
8984 enum machine_mode partmode
= TYPE_MODE (TREE_TYPE (TREE_TYPE (exp
)));
8988 op0
= expand_expr (TREE_OPERAND (exp
, 0), 0, VOIDmode
, 0);
8991 target
= gen_reg_rtx (mode
);
8995 /* Store the realpart and the negated imagpart to target. */
8996 emit_move_insn (gen_realpart (partmode
, target
),
8997 gen_realpart (partmode
, op0
));
8999 imag_t
= gen_imagpart (partmode
, target
);
9000 temp
= expand_unop (partmode
,
9001 ! unsignedp
&& flag_trapv
9002 && (GET_MODE_CLASS(partmode
) == MODE_INT
)
9003 ? negv_optab
: neg_optab
,
9004 gen_imagpart (partmode
, op0
), imag_t
, 0);
9006 emit_move_insn (imag_t
, temp
);
9008 insns
= get_insns ();
9011 /* Conjugate should appear as a single unit
9012 If TARGET is a CONCAT, we got insns like RD = RS, ID = - IS,
9013 each with a separate pseudo as destination.
9014 It's not correct for flow to treat them as a unit. */
9015 if (GET_CODE (target
) != CONCAT
)
9016 emit_no_conflict_block (insns
, target
, op0
, NULL_RTX
, NULL_RTX
);
9023 case TRY_CATCH_EXPR
:
9025 tree handler
= TREE_OPERAND (exp
, 1);
9027 expand_eh_region_start ();
9029 op0
= expand_expr (TREE_OPERAND (exp
, 0), 0, VOIDmode
, 0);
9031 expand_eh_region_end_cleanup (handler
);
9036 case TRY_FINALLY_EXPR
:
9038 tree try_block
= TREE_OPERAND (exp
, 0);
9039 tree finally_block
= TREE_OPERAND (exp
, 1);
9041 if (!optimize
|| unsafe_for_reeval (finally_block
) > 1)
9043 /* In this case, wrapping FINALLY_BLOCK in an UNSAVE_EXPR
9044 is not sufficient, so we cannot expand the block twice.
9045 So we play games with GOTO_SUBROUTINE_EXPR to let us
9046 expand the thing only once. */
9047 /* When not optimizing, we go ahead with this form since
9048 (1) user breakpoints operate more predictably without
9049 code duplication, and
9050 (2) we're not running any of the global optimizers
9051 that would explode in time/space with the highly
9052 connected CFG created by the indirect branching. */
9054 rtx finally_label
= gen_label_rtx ();
9055 rtx done_label
= gen_label_rtx ();
9056 rtx return_link
= gen_reg_rtx (Pmode
);
9057 tree cleanup
= build (GOTO_SUBROUTINE_EXPR
, void_type_node
,
9058 (tree
) finally_label
, (tree
) return_link
);
9059 TREE_SIDE_EFFECTS (cleanup
) = 1;
9061 /* Start a new binding layer that will keep track of all cleanup
9062 actions to be performed. */
9063 expand_start_bindings (2);
9064 target_temp_slot_level
= temp_slot_level
;
9066 expand_decl_cleanup (NULL_TREE
, cleanup
);
9067 op0
= expand_expr (try_block
, target
, tmode
, modifier
);
9069 preserve_temp_slots (op0
);
9070 expand_end_bindings (NULL_TREE
, 0, 0);
9071 emit_jump (done_label
);
9072 emit_label (finally_label
);
9073 expand_expr (finally_block
, const0_rtx
, VOIDmode
, 0);
9074 emit_indirect_jump (return_link
);
9075 emit_label (done_label
);
9079 expand_start_bindings (2);
9080 target_temp_slot_level
= temp_slot_level
;
9082 expand_decl_cleanup (NULL_TREE
, finally_block
);
9083 op0
= expand_expr (try_block
, target
, tmode
, modifier
);
9085 preserve_temp_slots (op0
);
9086 expand_end_bindings (NULL_TREE
, 0, 0);
9092 case GOTO_SUBROUTINE_EXPR
:
9094 rtx subr
= (rtx
) TREE_OPERAND (exp
, 0);
9095 rtx return_link
= *(rtx
*) &TREE_OPERAND (exp
, 1);
9096 rtx return_address
= gen_label_rtx ();
9097 emit_move_insn (return_link
,
9098 gen_rtx_LABEL_REF (Pmode
, return_address
));
9100 emit_label (return_address
);
9105 return expand_builtin_va_arg (TREE_OPERAND (exp
, 0), type
);
9108 return get_exception_pointer (cfun
);
9111 /* Function descriptors are not valid except for as
9112 initialization constants, and should not be expanded. */
9116 return (*lang_hooks
.expand_expr
) (exp
, original_target
, tmode
, modifier
,
9120 /* Here to do an ordinary binary operator, generating an instruction
9121 from the optab already placed in `this_optab'. */
9123 expand_operands (TREE_OPERAND (exp
, 0), TREE_OPERAND (exp
, 1),
9124 subtarget
, &op0
, &op1
, 0);
9126 if (modifier
== EXPAND_STACK_PARM
)
9128 temp
= expand_binop (mode
, this_optab
, op0
, op1
, target
,
9129 unsignedp
, OPTAB_LIB_WIDEN
);
9135 /* Subroutine of above: returns 1 if OFFSET corresponds to an offset that
9136 when applied to the address of EXP produces an address known to be
9137 aligned more than BIGGEST_ALIGNMENT. */
9140 is_aligning_offset (tree offset
, tree exp
)
9142 /* Strip off any conversions and WITH_RECORD_EXPR nodes. */
9143 while (TREE_CODE (offset
) == NON_LVALUE_EXPR
9144 || TREE_CODE (offset
) == NOP_EXPR
9145 || TREE_CODE (offset
) == CONVERT_EXPR
9146 || TREE_CODE (offset
) == WITH_RECORD_EXPR
)
9147 offset
= TREE_OPERAND (offset
, 0);
9149 /* We must now have a BIT_AND_EXPR with a constant that is one less than
9150 power of 2 and which is larger than BIGGEST_ALIGNMENT. */
9151 if (TREE_CODE (offset
) != BIT_AND_EXPR
9152 || !host_integerp (TREE_OPERAND (offset
, 1), 1)
9153 || compare_tree_int (TREE_OPERAND (offset
, 1),
9154 BIGGEST_ALIGNMENT
/ BITS_PER_UNIT
) <= 0
9155 || !exact_log2 (tree_low_cst (TREE_OPERAND (offset
, 1), 1) + 1) < 0)
9158 /* Look at the first operand of BIT_AND_EXPR and strip any conversion.
9159 It must be NEGATE_EXPR. Then strip any more conversions. */
9160 offset
= TREE_OPERAND (offset
, 0);
9161 while (TREE_CODE (offset
) == NON_LVALUE_EXPR
9162 || TREE_CODE (offset
) == NOP_EXPR
9163 || TREE_CODE (offset
) == CONVERT_EXPR
)
9164 offset
= TREE_OPERAND (offset
, 0);
9166 if (TREE_CODE (offset
) != NEGATE_EXPR
)
9169 offset
= TREE_OPERAND (offset
, 0);
9170 while (TREE_CODE (offset
) == NON_LVALUE_EXPR
9171 || TREE_CODE (offset
) == NOP_EXPR
9172 || TREE_CODE (offset
) == CONVERT_EXPR
)
9173 offset
= TREE_OPERAND (offset
, 0);
9175 /* This must now be the address either of EXP or of a PLACEHOLDER_EXPR
9176 whose type is the same as EXP. */
9177 return (TREE_CODE (offset
) == ADDR_EXPR
9178 && (TREE_OPERAND (offset
, 0) == exp
9179 || (TREE_CODE (TREE_OPERAND (offset
, 0)) == PLACEHOLDER_EXPR
9180 && (TREE_TYPE (TREE_OPERAND (offset
, 0))
9181 == TREE_TYPE (exp
)))));
9184 /* Return the tree node if an ARG corresponds to a string constant or zero
9185 if it doesn't. If we return nonzero, set *PTR_OFFSET to the offset
9186 in bytes within the string that ARG is accessing. The type of the
9187 offset will be `sizetype'. */
9190 string_constant (tree arg
, tree
*ptr_offset
)
9194 if (TREE_CODE (arg
) == ADDR_EXPR
9195 && TREE_CODE (TREE_OPERAND (arg
, 0)) == STRING_CST
)
9197 *ptr_offset
= size_zero_node
;
9198 return TREE_OPERAND (arg
, 0);
9200 else if (TREE_CODE (arg
) == PLUS_EXPR
)
9202 tree arg0
= TREE_OPERAND (arg
, 0);
9203 tree arg1
= TREE_OPERAND (arg
, 1);
9208 if (TREE_CODE (arg0
) == ADDR_EXPR
9209 && TREE_CODE (TREE_OPERAND (arg0
, 0)) == STRING_CST
)
9211 *ptr_offset
= convert (sizetype
, arg1
);
9212 return TREE_OPERAND (arg0
, 0);
9214 else if (TREE_CODE (arg1
) == ADDR_EXPR
9215 && TREE_CODE (TREE_OPERAND (arg1
, 0)) == STRING_CST
)
9217 *ptr_offset
= convert (sizetype
, arg0
);
9218 return TREE_OPERAND (arg1
, 0);
9225 /* Expand code for a post- or pre- increment or decrement
9226 and return the RTX for the result.
9227 POST is 1 for postinc/decrements and 0 for preinc/decrements. */
9230 expand_increment (tree exp
, int post
, int ignore
)
9234 tree incremented
= TREE_OPERAND (exp
, 0);
9235 optab this_optab
= add_optab
;
9237 enum machine_mode mode
= TYPE_MODE (TREE_TYPE (exp
));
9238 int op0_is_copy
= 0;
9239 int single_insn
= 0;
9240 /* 1 means we can't store into OP0 directly,
9241 because it is a subreg narrower than a word,
9242 and we don't dare clobber the rest of the word. */
9245 /* Stabilize any component ref that might need to be
9246 evaluated more than once below. */
9248 || TREE_CODE (incremented
) == BIT_FIELD_REF
9249 || (TREE_CODE (incremented
) == COMPONENT_REF
9250 && (TREE_CODE (TREE_OPERAND (incremented
, 0)) != INDIRECT_REF
9251 || DECL_BIT_FIELD (TREE_OPERAND (incremented
, 1)))))
9252 incremented
= stabilize_reference (incremented
);
9253 /* Nested *INCREMENT_EXPRs can happen in C++. We must force innermost
9254 ones into save exprs so that they don't accidentally get evaluated
9255 more than once by the code below. */
9256 if (TREE_CODE (incremented
) == PREINCREMENT_EXPR
9257 || TREE_CODE (incremented
) == PREDECREMENT_EXPR
)
9258 incremented
= save_expr (incremented
);
9260 /* Compute the operands as RTX.
9261 Note whether OP0 is the actual lvalue or a copy of it:
9262 I believe it is a copy iff it is a register or subreg
9263 and insns were generated in computing it. */
9265 temp
= get_last_insn ();
9266 op0
= expand_expr (incremented
, NULL_RTX
, VOIDmode
, 0);
9268 /* If OP0 is a SUBREG made for a promoted variable, we cannot increment
9269 in place but instead must do sign- or zero-extension during assignment,
9270 so we copy it into a new register and let the code below use it as
9273 Note that we can safely modify this SUBREG since it is know not to be
9274 shared (it was made by the expand_expr call above). */
9276 if (GET_CODE (op0
) == SUBREG
&& SUBREG_PROMOTED_VAR_P (op0
))
9279 SUBREG_REG (op0
) = copy_to_reg (SUBREG_REG (op0
));
9283 else if (GET_CODE (op0
) == SUBREG
9284 && GET_MODE_BITSIZE (GET_MODE (op0
)) < BITS_PER_WORD
)
9286 /* We cannot increment this SUBREG in place. If we are
9287 post-incrementing, get a copy of the old value. Otherwise,
9288 just mark that we cannot increment in place. */
9290 op0
= copy_to_reg (op0
);
9295 op0_is_copy
= ((GET_CODE (op0
) == SUBREG
|| GET_CODE (op0
) == REG
)
9296 && temp
!= get_last_insn ());
9297 op1
= expand_expr (TREE_OPERAND (exp
, 1), NULL_RTX
, VOIDmode
, 0);
9299 /* Decide whether incrementing or decrementing. */
9300 if (TREE_CODE (exp
) == POSTDECREMENT_EXPR
9301 || TREE_CODE (exp
) == PREDECREMENT_EXPR
)
9302 this_optab
= sub_optab
;
9304 /* Convert decrement by a constant into a negative increment. */
9305 if (this_optab
== sub_optab
9306 && GET_CODE (op1
) == CONST_INT
)
9308 op1
= GEN_INT (-INTVAL (op1
));
9309 this_optab
= add_optab
;
9312 if (TYPE_TRAP_SIGNED (TREE_TYPE (exp
)))
9313 this_optab
= this_optab
== add_optab
? addv_optab
: subv_optab
;
9315 /* For a preincrement, see if we can do this with a single instruction. */
9318 icode
= (int) this_optab
->handlers
[(int) mode
].insn_code
;
9319 if (icode
!= (int) CODE_FOR_nothing
9320 /* Make sure that OP0 is valid for operands 0 and 1
9321 of the insn we want to queue. */
9322 && (*insn_data
[icode
].operand
[0].predicate
) (op0
, mode
)
9323 && (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode
)
9324 && (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode
))
9328 /* If OP0 is not the actual lvalue, but rather a copy in a register,
9329 then we cannot just increment OP0. We must therefore contrive to
9330 increment the original value. Then, for postincrement, we can return
9331 OP0 since it is a copy of the old value. For preincrement, expand here
9332 unless we can do it with a single insn.
9334 Likewise if storing directly into OP0 would clobber high bits
9335 we need to preserve (bad_subreg). */
9336 if (op0_is_copy
|| (!post
&& !single_insn
) || bad_subreg
)
9338 /* This is the easiest way to increment the value wherever it is.
9339 Problems with multiple evaluation of INCREMENTED are prevented
9340 because either (1) it is a component_ref or preincrement,
9341 in which case it was stabilized above, or (2) it is an array_ref
9342 with constant index in an array in a register, which is
9343 safe to reevaluate. */
9344 tree newexp
= build (((TREE_CODE (exp
) == POSTDECREMENT_EXPR
9345 || TREE_CODE (exp
) == PREDECREMENT_EXPR
)
9346 ? MINUS_EXPR
: PLUS_EXPR
),
9349 TREE_OPERAND (exp
, 1));
9351 while (TREE_CODE (incremented
) == NOP_EXPR
9352 || TREE_CODE (incremented
) == CONVERT_EXPR
)
9354 newexp
= convert (TREE_TYPE (incremented
), newexp
);
9355 incremented
= TREE_OPERAND (incremented
, 0);
9358 temp
= expand_assignment (incremented
, newexp
, ! post
&& ! ignore
);
9359 return post
? op0
: temp
;
9364 /* We have a true reference to the value in OP0.
9365 If there is an insn to add or subtract in this mode, queue it.
9366 Queuing the increment insn avoids the register shuffling
9367 that often results if we must increment now and first save
9368 the old value for subsequent use. */
9370 #if 0 /* Turned off to avoid making extra insn for indexed memref. */
9371 op0
= stabilize (op0
);
9374 icode
= (int) this_optab
->handlers
[(int) mode
].insn_code
;
9375 if (icode
!= (int) CODE_FOR_nothing
9376 /* Make sure that OP0 is valid for operands 0 and 1
9377 of the insn we want to queue. */
9378 && (*insn_data
[icode
].operand
[0].predicate
) (op0
, mode
)
9379 && (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode
))
9381 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode
))
9382 op1
= force_reg (mode
, op1
);
9384 return enqueue_insn (op0
, GEN_FCN (icode
) (op0
, op0
, op1
));
9386 if (icode
!= (int) CODE_FOR_nothing
&& GET_CODE (op0
) == MEM
)
9388 rtx addr
= (general_operand (XEXP (op0
, 0), mode
)
9389 ? force_reg (Pmode
, XEXP (op0
, 0))
9390 : copy_to_reg (XEXP (op0
, 0)));
9393 op0
= replace_equiv_address (op0
, addr
);
9394 temp
= force_reg (GET_MODE (op0
), op0
);
9395 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode
))
9396 op1
= force_reg (mode
, op1
);
9398 /* The increment queue is LIFO, thus we have to `queue'
9399 the instructions in reverse order. */
9400 enqueue_insn (op0
, gen_move_insn (op0
, temp
));
9401 result
= enqueue_insn (temp
, GEN_FCN (icode
) (temp
, temp
, op1
));
9406 /* Preincrement, or we can't increment with one simple insn. */
9408 /* Save a copy of the value before inc or dec, to return it later. */
9409 temp
= value
= copy_to_reg (op0
);
9411 /* Arrange to return the incremented value. */
9412 /* Copy the rtx because expand_binop will protect from the queue,
9413 and the results of that would be invalid for us to return
9414 if our caller does emit_queue before using our result. */
9415 temp
= copy_rtx (value
= op0
);
9417 /* Increment however we can. */
9418 op1
= expand_binop (mode
, this_optab
, value
, op1
, op0
,
9419 TREE_UNSIGNED (TREE_TYPE (exp
)), OPTAB_LIB_WIDEN
);
9421 /* Make sure the value is stored into OP0. */
9423 emit_move_insn (op0
, op1
);
9428 /* Generate code to calculate EXP using a store-flag instruction
9429 and return an rtx for the result. EXP is either a comparison
9430 or a TRUTH_NOT_EXPR whose operand is a comparison.
9432 If TARGET is nonzero, store the result there if convenient.
9434 If ONLY_CHEAP is nonzero, only do this if it is likely to be very
9437 Return zero if there is no suitable set-flag instruction
9438 available on this machine.
9440 Once expand_expr has been called on the arguments of the comparison,
9441 we are committed to doing the store flag, since it is not safe to
9442 re-evaluate the expression. We emit the store-flag insn by calling
9443 emit_store_flag, but only expand the arguments if we have a reason
9444 to believe that emit_store_flag will be successful. If we think that
9445 it will, but it isn't, we have to simulate the store-flag with a
9446 set/jump/set sequence. */
9449 do_store_flag (tree exp
, rtx target
, enum machine_mode mode
, int only_cheap
)
9452 tree arg0
, arg1
, type
;
9454 enum machine_mode operand_mode
;
9458 enum insn_code icode
;
9459 rtx subtarget
= target
;
9462 /* If this is a TRUTH_NOT_EXPR, set a flag indicating we must invert the
9463 result at the end. We can't simply invert the test since it would
9464 have already been inverted if it were valid. This case occurs for
9465 some floating-point comparisons. */
9467 if (TREE_CODE (exp
) == TRUTH_NOT_EXPR
)
9468 invert
= 1, exp
= TREE_OPERAND (exp
, 0);
9470 arg0
= TREE_OPERAND (exp
, 0);
9471 arg1
= TREE_OPERAND (exp
, 1);
9473 /* Don't crash if the comparison was erroneous. */
9474 if (arg0
== error_mark_node
|| arg1
== error_mark_node
)
9477 type
= TREE_TYPE (arg0
);
9478 operand_mode
= TYPE_MODE (type
);
9479 unsignedp
= TREE_UNSIGNED (type
);
9481 /* We won't bother with BLKmode store-flag operations because it would mean
9482 passing a lot of information to emit_store_flag. */
9483 if (operand_mode
== BLKmode
)
9486 /* We won't bother with store-flag operations involving function pointers
9487 when function pointers must be canonicalized before comparisons. */
9488 #ifdef HAVE_canonicalize_funcptr_for_compare
9489 if (HAVE_canonicalize_funcptr_for_compare
9490 && ((TREE_CODE (TREE_TYPE (TREE_OPERAND (exp
, 0))) == POINTER_TYPE
9491 && (TREE_CODE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp
, 0))))
9493 || (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp
, 1))) == POINTER_TYPE
9494 && (TREE_CODE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp
, 1))))
9495 == FUNCTION_TYPE
))))
9502 /* Get the rtx comparison code to use. We know that EXP is a comparison
9503 operation of some type. Some comparisons against 1 and -1 can be
9504 converted to comparisons with zero. Do so here so that the tests
9505 below will be aware that we have a comparison with zero. These
9506 tests will not catch constants in the first operand, but constants
9507 are rarely passed as the first operand. */
9509 switch (TREE_CODE (exp
))
9518 if (integer_onep (arg1
))
9519 arg1
= integer_zero_node
, code
= unsignedp
? LEU
: LE
;
9521 code
= unsignedp
? LTU
: LT
;
9524 if (! unsignedp
&& integer_all_onesp (arg1
))
9525 arg1
= integer_zero_node
, code
= LT
;
9527 code
= unsignedp
? LEU
: LE
;
9530 if (! unsignedp
&& integer_all_onesp (arg1
))
9531 arg1
= integer_zero_node
, code
= GE
;
9533 code
= unsignedp
? GTU
: GT
;
9536 if (integer_onep (arg1
))
9537 arg1
= integer_zero_node
, code
= unsignedp
? GTU
: GT
;
9539 code
= unsignedp
? GEU
: GE
;
9542 case UNORDERED_EXPR
:
9568 /* Put a constant second. */
9569 if (TREE_CODE (arg0
) == REAL_CST
|| TREE_CODE (arg0
) == INTEGER_CST
)
9571 tem
= arg0
; arg0
= arg1
; arg1
= tem
;
9572 code
= swap_condition (code
);
9575 /* If this is an equality or inequality test of a single bit, we can
9576 do this by shifting the bit being tested to the low-order bit and
9577 masking the result with the constant 1. If the condition was EQ,
9578 we xor it with 1. This does not require an scc insn and is faster
9579 than an scc insn even if we have it.
9581 The code to make this transformation was moved into fold_single_bit_test,
9582 so we just call into the folder and expand its result. */
9584 if ((code
== NE
|| code
== EQ
)
9585 && TREE_CODE (arg0
) == BIT_AND_EXPR
&& integer_zerop (arg1
)
9586 && integer_pow2p (TREE_OPERAND (arg0
, 1)))
9588 tree type
= (*lang_hooks
.types
.type_for_mode
) (mode
, unsignedp
);
9589 return expand_expr (fold_single_bit_test (code
== NE
? NE_EXPR
: EQ_EXPR
,
9591 target
, VOIDmode
, EXPAND_NORMAL
);
9594 /* Now see if we are likely to be able to do this. Return if not. */
9595 if (! can_compare_p (code
, operand_mode
, ccp_store_flag
))
9598 icode
= setcc_gen_code
[(int) code
];
9599 if (icode
== CODE_FOR_nothing
9600 || (only_cheap
&& insn_data
[(int) icode
].operand
[0].mode
!= mode
))
9602 /* We can only do this if it is one of the special cases that
9603 can be handled without an scc insn. */
9604 if ((code
== LT
&& integer_zerop (arg1
))
9605 || (! only_cheap
&& code
== GE
&& integer_zerop (arg1
)))
9607 else if (BRANCH_COST
>= 0
9608 && ! only_cheap
&& (code
== NE
|| code
== EQ
)
9609 && TREE_CODE (type
) != REAL_TYPE
9610 && ((abs_optab
->handlers
[(int) operand_mode
].insn_code
9611 != CODE_FOR_nothing
)
9612 || (ffs_optab
->handlers
[(int) operand_mode
].insn_code
9613 != CODE_FOR_nothing
)))
9619 if (! get_subtarget (target
)
9620 || GET_MODE (subtarget
) != operand_mode
)
9623 expand_operands (arg0
, arg1
, subtarget
, &op0
, &op1
, 0);
9626 target
= gen_reg_rtx (mode
);
9628 /* Pass copies of OP0 and OP1 in case they contain a QUEUED. This is safe
9629 because, if the emit_store_flag does anything it will succeed and
9630 OP0 and OP1 will not be used subsequently. */
9632 result
= emit_store_flag (target
, code
,
9633 queued_subexp_p (op0
) ? copy_rtx (op0
) : op0
,
9634 queued_subexp_p (op1
) ? copy_rtx (op1
) : op1
,
9635 operand_mode
, unsignedp
, 1);
9640 result
= expand_binop (mode
, xor_optab
, result
, const1_rtx
,
9641 result
, 0, OPTAB_LIB_WIDEN
);
9645 /* If this failed, we have to do this with set/compare/jump/set code. */
9646 if (GET_CODE (target
) != REG
9647 || reg_mentioned_p (target
, op0
) || reg_mentioned_p (target
, op1
))
9648 target
= gen_reg_rtx (GET_MODE (target
));
9650 emit_move_insn (target
, invert
? const0_rtx
: const1_rtx
);
9651 result
= compare_from_rtx (op0
, op1
, code
, unsignedp
,
9652 operand_mode
, NULL_RTX
);
9653 if (GET_CODE (result
) == CONST_INT
)
9654 return (((result
== const0_rtx
&& ! invert
)
9655 || (result
!= const0_rtx
&& invert
))
9656 ? const0_rtx
: const1_rtx
);
9658 /* The code of RESULT may not match CODE if compare_from_rtx
9659 decided to swap its operands and reverse the original code.
9661 We know that compare_from_rtx returns either a CONST_INT or
9662 a new comparison code, so it is safe to just extract the
9663 code from RESULT. */
9664 code
= GET_CODE (result
);
9666 label
= gen_label_rtx ();
9667 if (bcc_gen_fctn
[(int) code
] == 0)
9670 emit_jump_insn ((*bcc_gen_fctn
[(int) code
]) (label
));
9671 emit_move_insn (target
, invert
? const1_rtx
: const0_rtx
);
9678 /* Stubs in case we haven't got a casesi insn. */
9680 # define HAVE_casesi 0
9681 # define gen_casesi(a, b, c, d, e) (0)
9682 # define CODE_FOR_casesi CODE_FOR_nothing
9685 /* If the machine does not have a case insn that compares the bounds,
9686 this means extra overhead for dispatch tables, which raises the
9687 threshold for using them. */
9688 #ifndef CASE_VALUES_THRESHOLD
9689 #define CASE_VALUES_THRESHOLD (HAVE_casesi ? 4 : 5)
9690 #endif /* CASE_VALUES_THRESHOLD */
9693 case_values_threshold (void)
9695 return CASE_VALUES_THRESHOLD
;
9698 /* Attempt to generate a casesi instruction. Returns 1 if successful,
9699 0 otherwise (i.e. if there is no casesi instruction). */
9701 try_casesi (tree index_type
, tree index_expr
, tree minval
, tree range
,
9702 rtx table_label ATTRIBUTE_UNUSED
, rtx default_label
)
9704 enum machine_mode index_mode
= SImode
;
9705 int index_bits
= GET_MODE_BITSIZE (index_mode
);
9706 rtx op1
, op2
, index
;
9707 enum machine_mode op_mode
;
9712 /* Convert the index to SImode. */
9713 if (GET_MODE_BITSIZE (TYPE_MODE (index_type
)) > GET_MODE_BITSIZE (index_mode
))
9715 enum machine_mode omode
= TYPE_MODE (index_type
);
9716 rtx rangertx
= expand_expr (range
, NULL_RTX
, VOIDmode
, 0);
9718 /* We must handle the endpoints in the original mode. */
9719 index_expr
= build (MINUS_EXPR
, index_type
,
9720 index_expr
, minval
);
9721 minval
= integer_zero_node
;
9722 index
= expand_expr (index_expr
, NULL_RTX
, VOIDmode
, 0);
9723 emit_cmp_and_jump_insns (rangertx
, index
, LTU
, NULL_RTX
,
9724 omode
, 1, default_label
);
9725 /* Now we can safely truncate. */
9726 index
= convert_to_mode (index_mode
, index
, 0);
9730 if (TYPE_MODE (index_type
) != index_mode
)
9732 index_expr
= convert ((*lang_hooks
.types
.type_for_size
)
9733 (index_bits
, 0), index_expr
);
9734 index_type
= TREE_TYPE (index_expr
);
9737 index
= expand_expr (index_expr
, NULL_RTX
, VOIDmode
, 0);
9740 index
= protect_from_queue (index
, 0);
9741 do_pending_stack_adjust ();
9743 op_mode
= insn_data
[(int) CODE_FOR_casesi
].operand
[0].mode
;
9744 if (! (*insn_data
[(int) CODE_FOR_casesi
].operand
[0].predicate
)
9746 index
= copy_to_mode_reg (op_mode
, index
);
9748 op1
= expand_expr (minval
, NULL_RTX
, VOIDmode
, 0);
9750 op_mode
= insn_data
[(int) CODE_FOR_casesi
].operand
[1].mode
;
9751 op1
= convert_modes (op_mode
, TYPE_MODE (TREE_TYPE (minval
)),
9752 op1
, TREE_UNSIGNED (TREE_TYPE (minval
)));
9753 if (! (*insn_data
[(int) CODE_FOR_casesi
].operand
[1].predicate
)
9755 op1
= copy_to_mode_reg (op_mode
, op1
);
9757 op2
= expand_expr (range
, NULL_RTX
, VOIDmode
, 0);
9759 op_mode
= insn_data
[(int) CODE_FOR_casesi
].operand
[2].mode
;
9760 op2
= convert_modes (op_mode
, TYPE_MODE (TREE_TYPE (range
)),
9761 op2
, TREE_UNSIGNED (TREE_TYPE (range
)));
9762 if (! (*insn_data
[(int) CODE_FOR_casesi
].operand
[2].predicate
)
9764 op2
= copy_to_mode_reg (op_mode
, op2
);
9766 emit_jump_insn (gen_casesi (index
, op1
, op2
,
9767 table_label
, default_label
));
9771 /* Attempt to generate a tablejump instruction; same concept. */
9772 #ifndef HAVE_tablejump
9773 #define HAVE_tablejump 0
9774 #define gen_tablejump(x, y) (0)
9777 /* Subroutine of the next function.
9779 INDEX is the value being switched on, with the lowest value
9780 in the table already subtracted.
9781 MODE is its expected mode (needed if INDEX is constant).
9782 RANGE is the length of the jump table.
9783 TABLE_LABEL is a CODE_LABEL rtx for the table itself.
9785 DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
9786 index value is out of range. */
9789 do_tablejump (rtx index
, enum machine_mode mode
, rtx range
, rtx table_label
,
9794 if (INTVAL (range
) > cfun
->max_jumptable_ents
)
9795 cfun
->max_jumptable_ents
= INTVAL (range
);
9797 /* Do an unsigned comparison (in the proper mode) between the index
9798 expression and the value which represents the length of the range.
9799 Since we just finished subtracting the lower bound of the range
9800 from the index expression, this comparison allows us to simultaneously
9801 check that the original index expression value is both greater than
9802 or equal to the minimum value of the range and less than or equal to
9803 the maximum value of the range. */
9805 emit_cmp_and_jump_insns (index
, range
, GTU
, NULL_RTX
, mode
, 1,
9808 /* If index is in range, it must fit in Pmode.
9809 Convert to Pmode so we can index with it. */
9811 index
= convert_to_mode (Pmode
, index
, 1);
9813 /* Don't let a MEM slip through, because then INDEX that comes
9814 out of PIC_CASE_VECTOR_ADDRESS won't be a valid address,
9815 and break_out_memory_refs will go to work on it and mess it up. */
9816 #ifdef PIC_CASE_VECTOR_ADDRESS
9817 if (flag_pic
&& GET_CODE (index
) != REG
)
9818 index
= copy_to_mode_reg (Pmode
, index
);
9821 /* If flag_force_addr were to affect this address
9822 it could interfere with the tricky assumptions made
9823 about addresses that contain label-refs,
9824 which may be valid only very near the tablejump itself. */
9825 /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
9826 GET_MODE_SIZE, because this indicates how large insns are. The other
9827 uses should all be Pmode, because they are addresses. This code
9828 could fail if addresses and insns are not the same size. */
9829 index
= gen_rtx_PLUS (Pmode
,
9830 gen_rtx_MULT (Pmode
, index
,
9831 GEN_INT (GET_MODE_SIZE (CASE_VECTOR_MODE
))),
9832 gen_rtx_LABEL_REF (Pmode
, table_label
));
9833 #ifdef PIC_CASE_VECTOR_ADDRESS
9835 index
= PIC_CASE_VECTOR_ADDRESS (index
);
9838 index
= memory_address_noforce (CASE_VECTOR_MODE
, index
);
9839 temp
= gen_reg_rtx (CASE_VECTOR_MODE
);
9840 vector
= gen_rtx_MEM (CASE_VECTOR_MODE
, index
);
9841 RTX_UNCHANGING_P (vector
) = 1;
9842 MEM_NOTRAP_P (vector
) = 1;
9843 convert_move (temp
, vector
, 0);
9845 emit_jump_insn (gen_tablejump (temp
, table_label
));
9847 /* If we are generating PIC code or if the table is PC-relative, the
9848 table and JUMP_INSN must be adjacent, so don't output a BARRIER. */
9849 if (! CASE_VECTOR_PC_RELATIVE
&& ! flag_pic
)
9854 try_tablejump (tree index_type
, tree index_expr
, tree minval
, tree range
,
9855 rtx table_label
, rtx default_label
)
9859 if (! HAVE_tablejump
)
9862 index_expr
= fold (build (MINUS_EXPR
, index_type
,
9863 convert (index_type
, index_expr
),
9864 convert (index_type
, minval
)));
9865 index
= expand_expr (index_expr
, NULL_RTX
, VOIDmode
, 0);
9867 index
= protect_from_queue (index
, 0);
9868 do_pending_stack_adjust ();
9870 do_tablejump (index
, TYPE_MODE (index_type
),
9871 convert_modes (TYPE_MODE (index_type
),
9872 TYPE_MODE (TREE_TYPE (range
)),
9873 expand_expr (range
, NULL_RTX
,
9875 TREE_UNSIGNED (TREE_TYPE (range
))),
9876 table_label
, default_label
);
9880 /* Nonzero if the mode is a valid vector mode for this architecture.
9881 This returns nonzero even if there is no hardware support for the
9882 vector mode, but we can emulate with narrower modes. */
9885 vector_mode_valid_p (enum machine_mode mode
)
9887 enum mode_class
class = GET_MODE_CLASS (mode
);
9888 enum machine_mode innermode
;
9890 /* Doh! What's going on? */
9891 if (class != MODE_VECTOR_INT
9892 && class != MODE_VECTOR_FLOAT
)
9895 /* Hardware support. Woo hoo! */
9896 if (VECTOR_MODE_SUPPORTED_P (mode
))
9899 innermode
= GET_MODE_INNER (mode
);
9901 /* We should probably return 1 if requesting V4DI and we have no DI,
9902 but we have V2DI, but this is probably very unlikely. */
9904 /* If we have support for the inner mode, we can safely emulate it.
9905 We may not have V2DI, but me can emulate with a pair of DIs. */
9906 return mov_optab
->handlers
[innermode
].insn_code
!= CODE_FOR_nothing
;
9909 /* Return a CONST_VECTOR rtx for a VECTOR_CST tree. */
9911 const_vector_from_tree (tree exp
)
9916 enum machine_mode inner
, mode
;
9918 mode
= TYPE_MODE (TREE_TYPE (exp
));
9920 if (is_zeros_p (exp
))
9921 return CONST0_RTX (mode
);
9923 units
= GET_MODE_NUNITS (mode
);
9924 inner
= GET_MODE_INNER (mode
);
9926 v
= rtvec_alloc (units
);
9928 link
= TREE_VECTOR_CST_ELTS (exp
);
9929 for (i
= 0; link
; link
= TREE_CHAIN (link
), ++i
)
9931 elt
= TREE_VALUE (link
);
9933 if (TREE_CODE (elt
) == REAL_CST
)
9934 RTVEC_ELT (v
, i
) = CONST_DOUBLE_FROM_REAL_VALUE (TREE_REAL_CST (elt
),
9937 RTVEC_ELT (v
, i
) = immed_double_const (TREE_INT_CST_LOW (elt
),
9938 TREE_INT_CST_HIGH (elt
),
9942 /* Initialize remaining elements to 0. */
9943 for (; i
< units
; ++i
)
9944 RTVEC_ELT (v
, i
) = CONST0_RTX (inner
);
9946 return gen_rtx_raw_CONST_VECTOR (mode
, v
);
9949 #include "gt-expr.h"