1 /* Definitions for GCC. Part of the machine description for CRIS.
2 Copyright (C) 1998-2018 Free Software Foundation, Inc.
3 Contributed by Axis Communications. Written by Hans-Peter Nilsson.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #define IN_TARGET_CODE 1
25 #include "coretypes.h"
30 #include "stringpool.h"
41 #include "diagnostic-core.h"
42 #include "conditions.h"
43 #include "insn-attr.h"
46 #include "stor-layout.h"
52 #include "tm-constrs.h"
55 /* This file should be included last. */
56 #include "target-def.h"
58 /* Usable when we have an amount to add or subtract, and want the
59 optimal size of the insn. */
60 #define ADDITIVE_SIZE_MODIFIER(size) \
61 ((size) <= 63 ? "q" : (size) <= 255 ? "u.b" : (size) <= 65535 ? "u.w" : ".d")
63 #define LOSE_AND_RETURN(msgid, x) \
66 cris_operand_lossage (msgid, x); \
70 enum cris_retinsn_type
71 { CRIS_RETINSN_UNKNOWN
= 0, CRIS_RETINSN_RET
, CRIS_RETINSN_JUMP
};
73 /* Per-function machine data. */
74 struct GTY(()) machine_function
76 int needs_return_address_on_stack
;
78 /* This is the number of registers we save in the prologue due to
82 enum cris_retinsn_type return_type
;
85 /* This little fix suppresses the 'u' or 's' when '%e' in assembly
87 static char cris_output_insn_is_bound
= 0;
89 /* In code for output macros, this is how we know whether e.g. constant
90 goes in code or in a static initializer. */
91 static int in_code
= 0;
93 /* Fix for reg_overlap_mentioned_p. */
94 static int cris_reg_overlap_mentioned_p (rtx
, rtx
);
96 static machine_mode
cris_promote_function_mode (const_tree
, machine_mode
,
97 int *, const_tree
, int);
99 static unsigned int cris_atomic_align_for_mode (machine_mode
);
101 static void cris_print_base (rtx
, FILE *);
103 static void cris_print_index (rtx
, FILE *);
105 static void cris_output_addr_const (FILE *, rtx
);
107 static struct machine_function
* cris_init_machine_status (void);
109 static rtx
cris_struct_value_rtx (tree
, int);
111 static void cris_setup_incoming_varargs (cumulative_args_t
, machine_mode
,
112 tree type
, int *, int);
114 static int cris_initial_frame_pointer_offset (void);
116 static void cris_operand_lossage (const char *, rtx
);
118 static int cris_reg_saved_in_regsave_area (unsigned int, bool);
120 static void cris_print_operand (FILE *, rtx
, int);
122 static void cris_print_operand_address (FILE *, machine_mode
, rtx
);
124 static bool cris_print_operand_punct_valid_p (unsigned char code
);
126 static bool cris_output_addr_const_extra (FILE *, rtx
);
128 static void cris_conditional_register_usage (void);
130 static void cris_asm_output_mi_thunk
131 (FILE *, tree
, HOST_WIDE_INT
, HOST_WIDE_INT
, tree
);
133 static void cris_file_start (void);
134 static void cris_init_libfuncs (void);
136 static reg_class_t
cris_preferred_reload_class (rtx
, reg_class_t
);
138 static int cris_register_move_cost (machine_mode
, reg_class_t
, reg_class_t
);
139 static int cris_memory_move_cost (machine_mode
, reg_class_t
, bool);
140 static bool cris_rtx_costs (rtx
, machine_mode
, int, int, int *, bool);
141 static int cris_address_cost (rtx
, machine_mode
, addr_space_t
, bool);
142 static bool cris_pass_by_reference (cumulative_args_t
, machine_mode
,
144 static int cris_arg_partial_bytes (cumulative_args_t
, machine_mode
,
146 static rtx
cris_function_arg (cumulative_args_t
, machine_mode
,
148 static rtx
cris_function_incoming_arg (cumulative_args_t
,
149 machine_mode
, const_tree
, bool);
150 static void cris_function_arg_advance (cumulative_args_t
, machine_mode
,
152 static rtx_insn
*cris_md_asm_adjust (vec
<rtx
> &, vec
<rtx
> &,
154 vec
<rtx
> &, HARD_REG_SET
&);
155 static bool cris_cannot_force_const_mem (machine_mode
, rtx
);
157 static void cris_option_override (void);
159 static bool cris_frame_pointer_required (void);
161 static void cris_asm_trampoline_template (FILE *);
162 static void cris_trampoline_init (rtx
, tree
, rtx
);
164 static rtx
cris_function_value(const_tree
, const_tree
, bool);
165 static rtx
cris_libcall_value (machine_mode
, const_rtx
);
166 static bool cris_function_value_regno_p (const unsigned int);
167 static void cris_file_end (void);
168 static unsigned int cris_hard_regno_nregs (unsigned int, machine_mode
);
169 static bool cris_hard_regno_mode_ok (unsigned int, machine_mode
);
170 static HOST_WIDE_INT
cris_static_rtx_alignment (machine_mode
);
171 static HOST_WIDE_INT
cris_constant_alignment (const_tree
, HOST_WIDE_INT
);
173 /* This is the parsed result of the "-max-stack-stackframe=" option. If
174 it (still) is zero, then there was no such option given. */
175 int cris_max_stackframe
= 0;
177 /* This is the parsed result of the "-march=" option, if given. */
178 int cris_cpu_version
= CRIS_DEFAULT_CPU_VERSION
;
180 #undef TARGET_ASM_ALIGNED_HI_OP
181 #define TARGET_ASM_ALIGNED_HI_OP "\t.word\t"
182 #undef TARGET_ASM_ALIGNED_SI_OP
183 #define TARGET_ASM_ALIGNED_SI_OP "\t.dword\t"
184 #undef TARGET_ASM_ALIGNED_DI_OP
185 #define TARGET_ASM_ALIGNED_DI_OP "\t.quad\t"
187 /* We need to define these, since the 2byte, 4byte, 8byte op:s are only
188 available in ELF. These "normal" pseudos do not have any alignment
189 constraints or side-effects. */
190 #undef TARGET_ASM_UNALIGNED_HI_OP
191 #define TARGET_ASM_UNALIGNED_HI_OP TARGET_ASM_ALIGNED_HI_OP
193 #undef TARGET_ASM_UNALIGNED_SI_OP
194 #define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
196 #undef TARGET_ASM_UNALIGNED_DI_OP
197 #define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
199 #undef TARGET_PRINT_OPERAND
200 #define TARGET_PRINT_OPERAND cris_print_operand
201 #undef TARGET_PRINT_OPERAND_ADDRESS
202 #define TARGET_PRINT_OPERAND_ADDRESS cris_print_operand_address
203 #undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
204 #define TARGET_PRINT_OPERAND_PUNCT_VALID_P cris_print_operand_punct_valid_p
205 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
206 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA cris_output_addr_const_extra
208 #undef TARGET_CONDITIONAL_REGISTER_USAGE
209 #define TARGET_CONDITIONAL_REGISTER_USAGE cris_conditional_register_usage
211 #undef TARGET_ASM_OUTPUT_MI_THUNK
212 #define TARGET_ASM_OUTPUT_MI_THUNK cris_asm_output_mi_thunk
213 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
214 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK default_can_output_mi_thunk_no_vcall
216 #undef TARGET_ASM_FILE_START
217 #define TARGET_ASM_FILE_START cris_file_start
218 #undef TARGET_ASM_FILE_END
219 #define TARGET_ASM_FILE_END cris_file_end
221 #undef TARGET_INIT_LIBFUNCS
222 #define TARGET_INIT_LIBFUNCS cris_init_libfuncs
225 #define TARGET_LRA_P hook_bool_void_false
227 #undef TARGET_LEGITIMATE_ADDRESS_P
228 #define TARGET_LEGITIMATE_ADDRESS_P cris_legitimate_address_p
230 #undef TARGET_LEGITIMATE_CONSTANT_P
231 #define TARGET_LEGITIMATE_CONSTANT_P cris_legitimate_constant_p
233 #undef TARGET_PREFERRED_RELOAD_CLASS
234 #define TARGET_PREFERRED_RELOAD_CLASS cris_preferred_reload_class
236 #undef TARGET_REGISTER_MOVE_COST
237 #define TARGET_REGISTER_MOVE_COST cris_register_move_cost
238 #undef TARGET_MEMORY_MOVE_COST
239 #define TARGET_MEMORY_MOVE_COST cris_memory_move_cost
240 #undef TARGET_RTX_COSTS
241 #define TARGET_RTX_COSTS cris_rtx_costs
242 #undef TARGET_ADDRESS_COST
243 #define TARGET_ADDRESS_COST cris_address_cost
245 #undef TARGET_PROMOTE_FUNCTION_MODE
246 #define TARGET_PROMOTE_FUNCTION_MODE cris_promote_function_mode
248 #undef TARGET_ATOMIC_ALIGN_FOR_MODE
249 #define TARGET_ATOMIC_ALIGN_FOR_MODE cris_atomic_align_for_mode
251 #undef TARGET_STRUCT_VALUE_RTX
252 #define TARGET_STRUCT_VALUE_RTX cris_struct_value_rtx
253 #undef TARGET_SETUP_INCOMING_VARARGS
254 #define TARGET_SETUP_INCOMING_VARARGS cris_setup_incoming_varargs
255 #undef TARGET_PASS_BY_REFERENCE
256 #define TARGET_PASS_BY_REFERENCE cris_pass_by_reference
257 #undef TARGET_ARG_PARTIAL_BYTES
258 #define TARGET_ARG_PARTIAL_BYTES cris_arg_partial_bytes
259 #undef TARGET_FUNCTION_ARG
260 #define TARGET_FUNCTION_ARG cris_function_arg
261 #undef TARGET_FUNCTION_INCOMING_ARG
262 #define TARGET_FUNCTION_INCOMING_ARG cris_function_incoming_arg
263 #undef TARGET_FUNCTION_ARG_ADVANCE
264 #define TARGET_FUNCTION_ARG_ADVANCE cris_function_arg_advance
265 #undef TARGET_MD_ASM_ADJUST
266 #define TARGET_MD_ASM_ADJUST cris_md_asm_adjust
268 #undef TARGET_CANNOT_FORCE_CONST_MEM
269 #define TARGET_CANNOT_FORCE_CONST_MEM cris_cannot_force_const_mem
271 #undef TARGET_FRAME_POINTER_REQUIRED
272 #define TARGET_FRAME_POINTER_REQUIRED cris_frame_pointer_required
274 #undef TARGET_OPTION_OVERRIDE
275 #define TARGET_OPTION_OVERRIDE cris_option_override
277 #undef TARGET_ASM_TRAMPOLINE_TEMPLATE
278 #define TARGET_ASM_TRAMPOLINE_TEMPLATE cris_asm_trampoline_template
279 #undef TARGET_TRAMPOLINE_INIT
280 #define TARGET_TRAMPOLINE_INIT cris_trampoline_init
282 #undef TARGET_FUNCTION_VALUE
283 #define TARGET_FUNCTION_VALUE cris_function_value
284 #undef TARGET_LIBCALL_VALUE
285 #define TARGET_LIBCALL_VALUE cris_libcall_value
286 #undef TARGET_FUNCTION_VALUE_REGNO_P
287 #define TARGET_FUNCTION_VALUE_REGNO_P cris_function_value_regno_p
289 #undef TARGET_HARD_REGNO_NREGS
290 #define TARGET_HARD_REGNO_NREGS cris_hard_regno_nregs
291 #undef TARGET_HARD_REGNO_MODE_OK
292 #define TARGET_HARD_REGNO_MODE_OK cris_hard_regno_mode_ok
294 #undef TARGET_STATIC_RTX_ALIGNMENT
295 #define TARGET_STATIC_RTX_ALIGNMENT cris_static_rtx_alignment
296 #undef TARGET_CONSTANT_ALIGNMENT
297 #define TARGET_CONSTANT_ALIGNMENT cris_constant_alignment
299 struct gcc_target targetm
= TARGET_INITIALIZER
;
301 /* Helper for cris_load_multiple_op and cris_ret_movem_op. */
304 cris_movem_load_rest_p (rtx op
, int offs
)
306 unsigned int reg_count
= XVECLEN (op
, 0) - offs
;
312 unsigned int regno
= 0;
314 /* Perform a quick check so we don't blow up below. FIXME: Adjust for
315 other than (MEM reg). */
317 || GET_CODE (XVECEXP (op
, 0, offs
)) != SET
318 || !REG_P (SET_DEST (XVECEXP (op
, 0, offs
)))
319 || !MEM_P (SET_SRC (XVECEXP (op
, 0, offs
))))
322 /* Check a possible post-inc indicator. */
323 if (GET_CODE (SET_SRC (XVECEXP (op
, 0, offs
+ 1))) == PLUS
)
325 rtx reg
= XEXP (SET_SRC (XVECEXP (op
, 0, offs
+ 1)), 0);
326 rtx inc
= XEXP (SET_SRC (XVECEXP (op
, 0, offs
+ 1)), 1);
332 || !REG_P (SET_DEST (XVECEXP (op
, 0, offs
+ 1)))
333 || REGNO (reg
) != REGNO (SET_DEST (XVECEXP (op
, 0, offs
+ 1)))
334 || !CONST_INT_P (inc
)
335 || INTVAL (inc
) != (HOST_WIDE_INT
) reg_count
* 4)
345 regno
= reg_count
- 1;
348 elt
= XVECEXP (op
, 0, offs
);
349 src_addr
= XEXP (SET_SRC (elt
), 0);
351 if (GET_CODE (elt
) != SET
352 || !REG_P (SET_DEST (elt
))
353 || GET_MODE (SET_DEST (elt
)) != SImode
354 || REGNO (SET_DEST (elt
)) != regno
355 || !MEM_P (SET_SRC (elt
))
356 || GET_MODE (SET_SRC (elt
)) != SImode
357 || !memory_address_p (SImode
, src_addr
))
360 for (setno
= 1; i
< XVECLEN (op
, 0); setno
++, i
++)
362 rtx elt
= XVECEXP (op
, 0, i
);
365 if (GET_CODE (elt
) != SET
366 || !REG_P (SET_DEST (elt
))
367 || GET_MODE (SET_DEST (elt
)) != SImode
368 || REGNO (SET_DEST (elt
)) != regno
369 || !MEM_P (SET_SRC (elt
))
370 || GET_MODE (SET_SRC (elt
)) != SImode
371 || GET_CODE (XEXP (SET_SRC (elt
), 0)) != PLUS
372 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt
), 0), 0), src_addr
)
373 || !CONST_INT_P (XEXP (XEXP (SET_SRC (elt
), 0), 1))
374 || INTVAL (XEXP (XEXP (SET_SRC (elt
), 0), 1)) != setno
* 4)
381 /* Worker function for predicate for the parallel contents in a movem
385 cris_store_multiple_op_p (rtx op
)
387 int reg_count
= XVECLEN (op
, 0);
398 /* Perform a quick check so we don't blow up below. FIXME: Adjust for
399 other than (MEM reg) and (MEM (PLUS reg const)). */
403 elt
= XVECEXP (op
, 0, 0);
405 if (GET_CODE (elt
) != SET
)
408 dest
= SET_DEST (elt
);
410 if (!REG_P (SET_SRC (elt
)) || !MEM_P (dest
))
413 dest_addr
= XEXP (dest
, 0);
415 /* Check a possible post-inc indicator. */
416 if (GET_CODE (SET_SRC (XVECEXP (op
, 0, 1))) == PLUS
)
418 rtx reg
= XEXP (SET_SRC (XVECEXP (op
, 0, 1)), 0);
419 rtx inc
= XEXP (SET_SRC (XVECEXP (op
, 0, 1)), 1);
425 || !REG_P (SET_DEST (XVECEXP (op
, 0, 1)))
426 || REGNO (reg
) != REGNO (SET_DEST (XVECEXP (op
, 0, 1)))
427 || !CONST_INT_P (inc
)
428 /* Support increment by number of registers, and by the offset
429 of the destination, if it has the form (MEM (PLUS reg
431 || !((REG_P (dest_addr
)
432 && REGNO (dest_addr
) == REGNO (reg
)
433 && INTVAL (inc
) == (HOST_WIDE_INT
) reg_count
* 4)
434 || (GET_CODE (dest_addr
) == PLUS
435 && REG_P (XEXP (dest_addr
, 0))
436 && REGNO (XEXP (dest_addr
, 0)) == REGNO (reg
)
437 && CONST_INT_P (XEXP (dest_addr
, 1))
438 && INTVAL (XEXP (dest_addr
, 1)) == INTVAL (inc
))))
449 regno
= reg_count
- 1;
452 if (GET_CODE (elt
) != SET
453 || !REG_P (SET_SRC (elt
))
454 || GET_MODE (SET_SRC (elt
)) != SImode
455 || REGNO (SET_SRC (elt
)) != (unsigned int) regno
456 || !MEM_P (SET_DEST (elt
))
457 || GET_MODE (SET_DEST (elt
)) != SImode
)
460 if (REG_P (dest_addr
))
462 dest_base
= dest_addr
;
465 else if (GET_CODE (dest_addr
) == PLUS
466 && REG_P (XEXP (dest_addr
, 0))
467 && CONST_INT_P (XEXP (dest_addr
, 1)))
469 dest_base
= XEXP (dest_addr
, 0);
470 offset
= INTVAL (XEXP (dest_addr
, 1));
475 for (setno
= 1; i
< XVECLEN (op
, 0); setno
++, i
++)
477 rtx elt
= XVECEXP (op
, 0, i
);
480 if (GET_CODE (elt
) != SET
481 || !REG_P (SET_SRC (elt
))
482 || GET_MODE (SET_SRC (elt
)) != SImode
483 || REGNO (SET_SRC (elt
)) != (unsigned int) regno
484 || !MEM_P (SET_DEST (elt
))
485 || GET_MODE (SET_DEST (elt
)) != SImode
486 || GET_CODE (XEXP (SET_DEST (elt
), 0)) != PLUS
487 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt
), 0), 0), dest_base
)
488 || !CONST_INT_P (XEXP (XEXP (SET_DEST (elt
), 0), 1))
489 || INTVAL (XEXP (XEXP (SET_DEST (elt
), 0), 1)) != setno
* 4 + offset
)
496 /* The TARGET_CONDITIONAL_REGISTER_USAGE worker. */
499 cris_conditional_register_usage (void)
501 /* FIXME: This isn't nice. We should be able to use that register for
502 something else if the PIC table isn't needed. */
504 fixed_regs
[PIC_OFFSET_TABLE_REGNUM
]
505 = call_used_regs
[PIC_OFFSET_TABLE_REGNUM
] = 1;
507 /* Allow use of ACR (PC in pre-V32) and tweak order. */
510 static const int reg_alloc_order_v32
[] = REG_ALLOC_ORDER_V32
;
513 fixed_regs
[CRIS_ACR_REGNUM
] = 0;
516 i
< sizeof (reg_alloc_order_v32
)/sizeof (reg_alloc_order_v32
[0]);
518 reg_alloc_order
[i
] = reg_alloc_order_v32
[i
];
521 if (TARGET_HAS_MUL_INSNS
)
522 fixed_regs
[CRIS_MOF_REGNUM
] = 0;
524 /* On early versions, we must use the 16-bit condition-code register,
525 which has another name. */
526 if (cris_cpu_version
< 8)
527 reg_names
[CRIS_CC0_REGNUM
] = "ccr";
530 /* Return crtl->uses_pic_offset_table. For use in cris.md,
531 since some generated files do not include function.h. */
534 cris_cfun_uses_pic_table (void)
536 return crtl
->uses_pic_offset_table
;
539 /* Worker function for TARGET_CANNOT_FORCE_CONST_MEM.
540 We can't put PIC addresses in the constant pool, not even the ones that
541 can be reached as pc-relative as we can't tell when or how to do that. */
544 cris_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED
, rtx x
)
546 enum cris_symbol_type t
= cris_symbol_type_of (x
);
550 || t
== cris_got_symbol
551 || t
== cris_rel_symbol
;
554 /* Given an rtx, return the text string corresponding to the CODE of X.
555 Intended for use in the assembly language output section of a
561 cris_output_insn_is_bound
= 0;
562 switch (GET_CODE (x
))
571 /* This function is for retrieving a part of an instruction name for
572 an operator, for immediate output. If that ever happens for
573 MULT, we need to apply TARGET_MUL_BUG in the caller. Make sure
575 internal_error ("MULT case in cris_op_str");
603 /* Used to control the sign/zero-extend character for the 'E' modifier.
605 cris_output_insn_is_bound
= 1;
609 return "Unknown operator";
613 /* Emit an error message when we're in an asm, and a fatal error for
614 "normal" insns. Formatted output isn't easily implemented, since we
615 use output_operand_lossage to output the actual message and handle the
616 categorization of the error. */
619 cris_operand_lossage (const char *msgid
, rtx op
)
622 output_operand_lossage ("%s", msgid
);
625 /* Print an index part of an address to file. */
628 cris_print_index (rtx index
, FILE *file
)
630 /* Make the index "additive" unless we'll output a negative number, in
631 which case the sign character is free (as in free beer). */
632 if (!CONST_INT_P (index
) || INTVAL (index
) >= 0)
636 fprintf (file
, "$%s.b", reg_names
[REGNO (index
)]);
637 else if (CRIS_CONSTANT_P (index
))
638 cris_output_addr_const (file
, index
);
639 else if (GET_CODE (index
) == MULT
)
641 fprintf (file
, "$%s.",
642 reg_names
[REGNO (XEXP (index
, 0))]);
644 putc (INTVAL (XEXP (index
, 1)) == 2 ? 'w' : 'd', file
);
646 else if (GET_CODE (index
) == SIGN_EXTEND
&& MEM_P (XEXP (index
, 0)))
648 rtx inner
= XEXP (index
, 0);
649 rtx inner_inner
= XEXP (inner
, 0);
651 if (GET_CODE (inner_inner
) == POST_INC
)
653 fprintf (file
, "[$%s+].",
654 reg_names
[REGNO (XEXP (inner_inner
, 0))]);
655 putc (GET_MODE (inner
) == HImode
? 'w' : 'b', file
);
659 fprintf (file
, "[$%s].", reg_names
[REGNO (inner_inner
)]);
661 putc (GET_MODE (inner
) == HImode
? 'w' : 'b', file
);
664 else if (MEM_P (index
))
666 rtx inner
= XEXP (index
, 0);
667 if (GET_CODE (inner
) == POST_INC
)
668 fprintf (file
, "[$%s+].d", reg_names
[REGNO (XEXP (inner
, 0))]);
670 fprintf (file
, "[$%s].d", reg_names
[REGNO (inner
)]);
673 cris_operand_lossage ("unexpected index-type in cris_print_index",
677 /* Print a base rtx of an address to file. */
680 cris_print_base (rtx base
, FILE *file
)
683 fprintf (file
, "$%s", reg_names
[REGNO (base
)]);
684 else if (GET_CODE (base
) == POST_INC
)
686 gcc_assert (REGNO (XEXP (base
, 0)) != CRIS_ACR_REGNUM
);
687 fprintf (file
, "$%s+", reg_names
[REGNO (XEXP (base
, 0))]);
690 cris_operand_lossage ("unexpected base-type in cris_print_base",
694 /* Usable as a guard in expressions. */
697 cris_fatal (char *arg
)
699 internal_error (arg
);
701 /* We'll never get here; this is just to appease compilers. */
705 /* Return nonzero if REGNO is an ordinary register that *needs* to be
706 saved together with other registers, possibly by a MOVEM instruction,
707 or is saved for target-independent reasons. There may be
708 target-dependent reasons to save the register anyway; this is just a
709 wrapper for a complicated conditional. */
712 cris_reg_saved_in_regsave_area (unsigned int regno
, bool got_really_used
)
715 (((df_regs_ever_live_p (regno
)
716 && !call_used_regs
[regno
])
717 || (regno
== PIC_OFFSET_TABLE_REGNUM
719 /* It is saved anyway, if there would be a gap. */
721 && df_regs_ever_live_p (regno
+ 1)
722 && !call_used_regs
[regno
+ 1]))))
723 && (regno
!= FRAME_POINTER_REGNUM
|| !frame_pointer_needed
)
724 && regno
!= CRIS_SRP_REGNUM
)
725 || (crtl
->calls_eh_return
726 && (regno
== EH_RETURN_DATA_REGNO (0)
727 || regno
== EH_RETURN_DATA_REGNO (1)
728 || regno
== EH_RETURN_DATA_REGNO (2)
729 || regno
== EH_RETURN_DATA_REGNO (3)));
732 /* The PRINT_OPERAND worker. */
735 cris_print_operand (FILE *file
, rtx x
, int code
)
739 /* Size-strings corresponding to MULT expressions. */
740 static const char *const mults
[] = { "BAD:0", ".b", ".w", "BAD:3", ".d" };
742 /* New code entries should just be added to the switch below. If
743 handling is finished, just return. If handling was just a
744 modification of the operand, the modified operand should be put in
745 "operand", and then do a break to let default handling
746 (zero-modifier) output the operand. */
751 /* Print the unsigned supplied integer as if it were signed
752 and < 0, i.e print 255 or 65535 as -1, 254, 65534 as -2, etc. */
753 if (!satisfies_constraint_O (x
))
754 LOSE_AND_RETURN ("invalid operand for 'b' modifier", x
);
755 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
756 INTVAL (x
)| (INTVAL (x
) <= 255 ? ~255 : ~65535));
760 /* Print assembler code for operator. */
761 fprintf (file
, "%s", cris_op_str (operand
));
766 /* A movem modifier working on a parallel; output the register
770 if (GET_CODE (x
) != PARALLEL
)
771 LOSE_AND_RETURN ("invalid operand for 'o' modifier", x
);
773 /* The second item can be (set reg (plus reg const)) to denote a
776 = (GET_CODE (SET_SRC (XVECEXP (x
, 0, 1))) == PLUS
778 : XVECLEN (x
, 0) - 1);
780 fprintf (file
, "$%s", reg_names
[regno
]);
786 /* A similar movem modifier; output the memory operand. */
789 if (GET_CODE (x
) != PARALLEL
)
790 LOSE_AND_RETURN ("invalid operand for 'O' modifier", x
);
792 /* The lowest mem operand is in the first item, but perhaps it
793 needs to be output as postincremented. */
794 addr
= MEM_P (SET_SRC (XVECEXP (x
, 0, 0)))
795 ? XEXP (SET_SRC (XVECEXP (x
, 0, 0)), 0)
796 : XEXP (SET_DEST (XVECEXP (x
, 0, 0)), 0);
798 /* The second item can be a (set reg (plus reg const)) to denote
800 if (GET_CODE (SET_SRC (XVECEXP (x
, 0, 1))) == PLUS
)
802 /* It's a post-increment, if the address is a naked (reg). */
804 addr
= gen_rtx_POST_INC (SImode
, addr
);
807 /* Otherwise, it's a side-effect; RN=RN+M. */
808 fprintf (file
, "[$%s=$%s%s%d]",
809 reg_names
[REGNO (SET_DEST (XVECEXP (x
, 0, 1)))],
810 reg_names
[REGNO (XEXP (addr
, 0))],
811 INTVAL (XEXP (addr
, 1)) < 0 ? "" : "+",
812 (int) INTVAL (XEXP (addr
, 1)));
816 output_address (VOIDmode
, addr
);
821 /* Adjust a power of two to its log2. */
822 if (!CONST_INT_P (x
) || exact_log2 (INTVAL (x
)) < 0 )
823 LOSE_AND_RETURN ("invalid operand for 'p' modifier", x
);
824 fprintf (file
, "%d", exact_log2 (INTVAL (x
)));
828 /* For an integer, print 'b' or 'w' if <= 255 or <= 65535
829 respectively. This modifier also terminates the inhibiting
830 effects of the 'x' modifier. */
831 cris_output_insn_is_bound
= 0;
832 if (GET_MODE (x
) == VOIDmode
&& CONST_INT_P (x
))
836 if (INTVAL (x
) <= 255)
838 else if (INTVAL (x
) <= 65535)
848 /* For a non-integer, print the size of the operand. */
849 putc ((GET_MODE (x
) == SImode
|| GET_MODE (x
) == SFmode
)
850 ? 'd' : GET_MODE (x
) == HImode
? 'w'
851 : GET_MODE (x
) == QImode
? 'b'
852 /* If none of the above, emit an erroneous size letter. */
858 /* Const_int: print b for -127 <= x <= 255,
859 w for -32768 <= x <= 65535, else die. */
861 || INTVAL (x
) < -32768 || INTVAL (x
) > 65535)
862 LOSE_AND_RETURN ("invalid operand for 'z' modifier", x
);
863 putc (INTVAL (x
) >= -128 && INTVAL (x
) <= 255 ? 'b' : 'w', file
);
867 /* If this is a GOT-symbol, print the size-letter corresponding to
868 -fpic/-fPIC. For everything else, print "d". */
870 && GET_CODE (x
) == CONST
871 && GET_CODE (XEXP (x
, 0)) == UNSPEC
872 && XINT (XEXP (x
, 0), 1) == CRIS_UNSPEC_GOTREAD
)
877 /* Output a 'nop' if there's nothing for the delay slot.
878 This method stolen from the sparc files. */
879 if (dbr_sequence_length () == 0)
880 fputs ("\n\tnop", file
);
884 /* Output directive for alignment padded with "nop" insns.
885 Optimizing for size, it's plain 4-byte alignment, otherwise we
886 align the section to a cache-line (32 bytes) and skip at max 2
887 bytes, i.e. we skip if it's the last insn on a cache-line. The
888 latter is faster by a small amount (for two test-programs 99.6%
889 and 99.9%) and larger by a small amount (ditto 100.1% and
890 100.2%). This is supposed to be the simplest yet performance-
891 wise least intrusive way to make sure the immediately following
892 (supposed) muls/mulu insn isn't located at the end of a
896 ? ".p2alignw 2,0x050f\n\t"
897 : ".p2alignw 5,0x050f,2\n\t", file
);
901 /* The PIC register. */
903 internal_error ("invalid use of ':' modifier");
904 fprintf (file
, "$%s", reg_names
[PIC_OFFSET_TABLE_REGNUM
]);
908 /* Print high (most significant) part of something. */
909 switch (GET_CODE (operand
))
912 /* If we're having 64-bit HOST_WIDE_INTs, the whole (DImode)
913 value is kept here, and so may be other than 0 or -1. */
914 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
,
915 INTVAL (operand_subword (operand
, 1, 0, DImode
)));
919 /* High part of a long long constant. */
920 if (GET_MODE (operand
) == VOIDmode
)
922 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_HIGH (x
));
926 LOSE_AND_RETURN ("invalid operand for 'H' modifier", x
);
929 /* Print reg + 1. Check that there's not an attempt to print
930 high-parts of registers like stack-pointer or higher, except
931 for SRP (where the "high part" is MOF). */
932 if (REGNO (operand
) > STACK_POINTER_REGNUM
- 2
933 && (REGNO (operand
) != CRIS_SRP_REGNUM
934 || CRIS_SRP_REGNUM
+ 1 != CRIS_MOF_REGNUM
935 || fixed_regs
[CRIS_MOF_REGNUM
] != 0))
936 LOSE_AND_RETURN ("bad register", operand
);
937 fprintf (file
, "$%s", reg_names
[REGNO (operand
) + 1]);
941 /* Adjust memory address to high part. */
943 rtx adj_mem
= operand
;
945 = GET_MODE_BITSIZE (GET_MODE (operand
)) / BITS_PER_UNIT
;
947 /* Adjust so we can use two SImode in DImode.
948 Calling adj_offsettable_operand will make sure it is an
949 offsettable address. Don't do this for a postincrement
950 though; it should remain as it was. */
951 if (GET_CODE (XEXP (adj_mem
, 0)) != POST_INC
)
953 = adjust_address (adj_mem
, GET_MODE (adj_mem
), size
/ 2);
955 output_address (VOIDmode
, XEXP (adj_mem
, 0));
960 LOSE_AND_RETURN ("invalid operand for 'H' modifier", x
);
964 /* Strip the MEM expression. */
965 operand
= XEXP (operand
, 0);
969 /* Like 'E', but ignore state set by 'x'. FIXME: Use code
970 iterators and attributes in cris.md to avoid the need for %x
971 and %E (and %e) and state passed between those modifiers. */
972 cris_output_insn_is_bound
= 0;
975 /* Print 's' if operand is SIGN_EXTEND or 'u' if ZERO_EXTEND unless
976 cris_output_insn_is_bound is nonzero. */
977 if (GET_CODE (operand
) != SIGN_EXTEND
978 && GET_CODE (operand
) != ZERO_EXTEND
979 && !CONST_INT_P (operand
))
980 LOSE_AND_RETURN ("invalid operand for 'e' modifier", x
);
982 if (cris_output_insn_is_bound
)
984 cris_output_insn_is_bound
= 0;
988 putc (GET_CODE (operand
) == SIGN_EXTEND
989 || (CONST_INT_P (operand
) && INTVAL (operand
) < 0)
994 /* Print the size letter of the inner element. We can do it by
995 calling ourselves with the 's' modifier. */
996 if (GET_CODE (operand
) != SIGN_EXTEND
&& GET_CODE (operand
) != ZERO_EXTEND
)
997 LOSE_AND_RETURN ("invalid operand for 'm' modifier", x
);
998 cris_print_operand (file
, XEXP (operand
, 0), 's');
1002 /* Print the least significant part of operand. */
1003 if (GET_CODE (operand
) == CONST_DOUBLE
)
1005 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
1008 else if (HOST_BITS_PER_WIDE_INT
> 32 && CONST_INT_P (operand
))
1010 fprintf (file
, HOST_WIDE_INT_PRINT_HEX
,
1011 INTVAL (x
) & ((unsigned int) 0x7fffffff * 2 + 1));
1014 /* Otherwise the least significant part equals the normal part,
1015 so handle it normally. */
1019 /* When emitting an add for the high part of a DImode constant, we
1020 want to use addq for 0 and adds.w for -1. */
1021 if (!CONST_INT_P (operand
))
1022 LOSE_AND_RETURN ("invalid operand for 'A' modifier", x
);
1023 fprintf (file
, INTVAL (operand
) < 0 ? "adds.w" : "addq");
1027 /* For const_int operands, print the additive mnemonic and the
1028 modified operand (byte-sized operands don't save anything):
1029 N=MIN_INT..-65536: add.d N
1030 -65535..-64: subu.w -N
1034 65536..MAX_INT: add.d N.
1035 (Emitted mnemonics are capitalized to simplify testing.)
1036 For anything else (N.B: only register is valid), print "add.d". */
1037 if (REG_P (operand
))
1039 fprintf (file
, "Add.d ");
1041 /* Deal with printing the operand by dropping through to the
1048 gcc_assert (CONST_INT_P (operand
));
1050 val
= INTVAL (operand
);
1051 if (!IN_RANGE (val
, -65535, 65535))
1052 fprintf (file
, "Add.d %d", val
);
1053 else if (val
<= -64)
1054 fprintf (file
, "Subu.w %d", -val
);
1056 fprintf (file
, "Subq %d", -val
);
1058 fprintf (file
, "Addq %d", val
);
1059 else if (val
<= 65535)
1060 fprintf (file
, "Addu.w %d", val
);
1066 /* If the operand is an integer -31..31, print "q" else ".d". */
1067 if (CONST_INT_P (operand
) && IN_RANGE (INTVAL (operand
), -31, 31))
1068 fprintf (file
, "q");
1070 fprintf (file
, ".d");
1074 /* If this is a GOT symbol, force it to be emitted as :GOT and
1075 :GOTPLT regardless of -fpic (i.e. not as :GOT16, :GOTPLT16).
1076 Avoid making this too much of a special case. */
1077 if (flag_pic
== 1 && CRIS_CONSTANT_P (operand
))
1079 int flag_pic_save
= flag_pic
;
1082 cris_output_addr_const (file
, operand
);
1083 flag_pic
= flag_pic_save
;
1089 /* When emitting an sub for the high part of a DImode constant, we
1090 want to use subq for 0 and subs.w for -1. */
1091 if (!CONST_INT_P (operand
))
1092 LOSE_AND_RETURN ("invalid operand for 'D' modifier", x
);
1093 fprintf (file
, INTVAL (operand
) < 0 ? "subs.w" : "subq");
1097 /* Print the operand as the index-part of an address.
1098 Easiest way out is to use cris_print_index. */
1099 cris_print_index (operand
, file
);
1103 /* Print the size letter for an operand to a MULT, which must be a
1104 const_int with a suitable value. */
1105 if (!CONST_INT_P (operand
) || INTVAL (operand
) > 4)
1106 LOSE_AND_RETURN ("invalid operand for 'T' modifier", x
);
1107 fprintf (file
, "%s", mults
[INTVAL (operand
)]);
1111 /* Print "u.w" if a GOT symbol and flag_pic == 1, else ".d". */
1113 && GET_CODE (operand
) == CONST
1114 && GET_CODE (XEXP (operand
, 0)) == UNSPEC
1115 && XINT (XEXP (operand
, 0), 1) == CRIS_UNSPEC_GOTREAD
)
1116 fprintf (file
, "u.w");
1118 fprintf (file
, ".d");
1122 /* No code, print as usual. */
1126 LOSE_AND_RETURN ("invalid operand modifier letter", x
);
1129 /* Print an operand as without a modifier letter. */
1130 switch (GET_CODE (operand
))
1133 if (REGNO (operand
) > 15
1134 && REGNO (operand
) != CRIS_MOF_REGNUM
1135 && REGNO (operand
) != CRIS_SRP_REGNUM
1136 && REGNO (operand
) != CRIS_CC0_REGNUM
)
1137 internal_error ("internal error: bad register: %d", REGNO (operand
));
1138 fprintf (file
, "$%s", reg_names
[REGNO (operand
)]);
1142 output_address (GET_MODE (operand
), XEXP (operand
, 0));
1146 if (GET_MODE (operand
) == VOIDmode
)
1147 /* A long long constant. */
1148 output_addr_const (file
, operand
);
1151 /* Only single precision is allowed as plain operands the
1155 /* FIXME: Perhaps check overflow of the "single". */
1156 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (operand
), l
);
1158 fprintf (file
, "0x%lx", l
);
1165 cris_output_addr_const (file
, operand
);
1171 /* For a (MULT (reg X) const_int) we output "rX.S". */
1172 int i
= CONST_INT_P (XEXP (operand
, 1))
1173 ? INTVAL (XEXP (operand
, 1)) : INTVAL (XEXP (operand
, 0));
1174 rtx reg
= CONST_INT_P (XEXP (operand
, 1))
1175 ? XEXP (operand
, 0) : XEXP (operand
, 1);
1178 || (!CONST_INT_P (XEXP (operand
, 0))
1179 && !CONST_INT_P (XEXP (operand
, 1))))
1180 LOSE_AND_RETURN ("unexpected multiplicative operand", x
);
1182 cris_print_base (reg
, file
);
1183 fprintf (file
, ".%c",
1184 i
== 0 || (i
== 1 && GET_CODE (operand
) == MULT
) ? 'b'
1186 : (i
== 2 && GET_CODE (operand
) == MULT
) || i
== 1 ? 'w'
1192 /* No need to handle all strange variants, let output_addr_const
1194 if (CRIS_CONSTANT_P (operand
))
1196 cris_output_addr_const (file
, operand
);
1200 LOSE_AND_RETURN ("unexpected operand", x
);
1205 cris_print_operand_punct_valid_p (unsigned char code
)
1207 return (code
== '#' || code
== '!' || code
== ':');
1210 /* The PRINT_OPERAND_ADDRESS worker. */
1213 cris_print_operand_address (FILE *file
, machine_mode
/*mode*/, rtx x
)
1215 /* All these were inside MEM:s so output indirection characters. */
1218 if (CONSTANT_ADDRESS_P (x
))
1219 cris_output_addr_const (file
, x
);
1220 else if (cris_base_or_autoincr_p (x
, true))
1221 cris_print_base (x
, file
);
1222 else if (GET_CODE (x
) == PLUS
)
1228 if (cris_base_p (x1
, true))
1230 cris_print_base (x1
, file
);
1231 cris_print_index (x2
, file
);
1233 else if (cris_base_p (x2
, true))
1235 cris_print_base (x2
, file
);
1236 cris_print_index (x1
, file
);
1239 LOSE_AND_RETURN ("unrecognized address", x
);
1243 /* A DIP. Output more indirection characters. */
1245 cris_print_base (XEXP (x
, 0), file
);
1249 LOSE_AND_RETURN ("unrecognized address", x
);
1254 /* The RETURN_ADDR_RTX worker.
1255 We mark that the return address is used, either by EH or
1256 __builtin_return_address, for use by the function prologue and
1257 epilogue. FIXME: This isn't optimal; we just use the mark in the
1258 prologue and epilogue to say that the return address is to be stored
1259 in the stack frame. We could return SRP for leaf-functions and use the
1260 initial-value machinery. */
1263 cris_return_addr_rtx (int count
, rtx frameaddr ATTRIBUTE_UNUSED
)
1265 cfun
->machine
->needs_return_address_on_stack
= 1;
1267 /* The return-address is stored just above the saved frame-pointer (if
1268 present). Apparently we can't eliminate from the frame-pointer in
1269 that direction, so use the incoming args (maybe pretended) pointer. */
1271 ? gen_rtx_MEM (Pmode
, plus_constant (Pmode
, virtual_incoming_args_rtx
, -4))
1275 /* Accessor used in cris.md:return because cfun->machine isn't available
1279 cris_return_address_on_stack (void)
1281 return df_regs_ever_live_p (CRIS_SRP_REGNUM
)
1282 || cfun
->machine
->needs_return_address_on_stack
;
1285 /* Accessor used in cris.md:return because cfun->machine isn't available
1289 cris_return_address_on_stack_for_return (void)
1291 return cfun
->machine
->return_type
== CRIS_RETINSN_RET
? false
1292 : cris_return_address_on_stack ();
1295 /* This handles FP -> SP elimination offset. */
1298 cris_initial_frame_pointer_offset (void)
1302 /* Initial offset is 0 if we don't have a frame pointer. */
1304 bool got_really_used
= false;
1306 if (crtl
->uses_pic_offset_table
)
1308 push_topmost_sequence ();
1310 = reg_used_between_p (pic_offset_table_rtx
, get_insns (),
1312 pop_topmost_sequence ();
1315 /* And 4 for each register pushed. */
1316 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
1317 if (cris_reg_saved_in_regsave_area (regno
, got_really_used
))
1320 /* And then, last, we add the locals allocated. */
1321 offs
+= get_frame_size ();
1323 /* And more; the accumulated args size. */
1324 offs
+= crtl
->outgoing_args_size
;
1326 /* Then round it off, in case we use aligned stack. */
1327 if (TARGET_STACK_ALIGN
)
1328 offs
= TARGET_ALIGN_BY_32
? (offs
+ 3) & ~3 : (offs
+ 1) & ~1;
1333 /* The INITIAL_ELIMINATION_OFFSET worker.
1334 Calculate the difference between imaginary registers such as frame
1335 pointer and the stack pointer. Used to eliminate the frame pointer
1336 and imaginary arg pointer. */
1339 cris_initial_elimination_offset (int fromreg
, int toreg
)
1342 = cris_initial_frame_pointer_offset ();
1344 /* We should be able to use regs_ever_live and related prologue
1345 information here, or alpha should not as well. */
1346 bool return_address_on_stack
= cris_return_address_on_stack ();
1348 /* Here we act as if the frame-pointer were needed. */
1349 int ap_fp_offset
= 4 + (return_address_on_stack
? 4 : 0);
1351 if (fromreg
== ARG_POINTER_REGNUM
1352 && toreg
== FRAME_POINTER_REGNUM
)
1353 return ap_fp_offset
;
1355 /* Between the frame pointer and the stack are only "normal" stack
1356 variables and saved registers. */
1357 if (fromreg
== FRAME_POINTER_REGNUM
1358 && toreg
== STACK_POINTER_REGNUM
)
1359 return fp_sp_offset
;
1361 /* We need to balance out the frame pointer here. */
1362 if (fromreg
== ARG_POINTER_REGNUM
1363 && toreg
== STACK_POINTER_REGNUM
)
1364 return ap_fp_offset
+ fp_sp_offset
- 4;
1369 /* Nonzero if X is a hard reg that can be used as an index. */
1371 reg_ok_for_base_p (const_rtx x
, bool strict
)
1373 return ((! strict
&& ! HARD_REGISTER_P (x
))
1374 || REGNO_OK_FOR_BASE_P (REGNO (x
)));
1377 /* Nonzero if X is a hard reg that can be used as an index. */
1379 reg_ok_for_index_p (const_rtx x
, bool strict
)
1381 return reg_ok_for_base_p (x
, strict
);
1384 /* No symbol can be used as an index (or more correct, as a base) together
1385 with a register with PIC; the PIC register must be there. */
1388 cris_constant_index_p (const_rtx x
)
1390 return (CRIS_CONSTANT_P (x
) && (!flag_pic
|| cris_valid_pic_const (x
, true)));
1393 /* True if X is a valid base register. */
1396 cris_base_p (const_rtx x
, bool strict
)
1398 return (REG_P (x
) && reg_ok_for_base_p (x
, strict
));
1401 /* True if X is a valid index register. */
1404 cris_index_p (const_rtx x
, bool strict
)
1406 return (REG_P (x
) && reg_ok_for_index_p (x
, strict
));
1409 /* True if X is a valid base register with or without autoincrement. */
1412 cris_base_or_autoincr_p (const_rtx x
, bool strict
)
1414 return (cris_base_p (x
, strict
)
1415 || (GET_CODE (x
) == POST_INC
1416 && cris_base_p (XEXP (x
, 0), strict
)
1417 && REGNO (XEXP (x
, 0)) != CRIS_ACR_REGNUM
));
1420 /* True if X is a valid (register) index for BDAP, i.e. [Rs].S or [Rs+].S. */
1423 cris_bdap_index_p (const_rtx x
, bool strict
)
1426 && GET_MODE (x
) == SImode
1427 && cris_base_or_autoincr_p (XEXP (x
, 0), strict
))
1428 || (GET_CODE (x
) == SIGN_EXTEND
1429 && MEM_P (XEXP (x
, 0))
1430 && (GET_MODE (XEXP (x
, 0)) == HImode
1431 || GET_MODE (XEXP (x
, 0)) == QImode
)
1432 && cris_base_or_autoincr_p (XEXP (XEXP (x
, 0), 0), strict
)));
1435 /* True if X is a valid (register) index for BIAP, i.e. Rd.m. */
1438 cris_biap_index_p (const_rtx x
, bool strict
)
1440 return (cris_index_p (x
, strict
)
1441 || (GET_CODE (x
) == MULT
1442 && cris_index_p (XEXP (x
, 0), strict
)
1443 && cris_scale_int_operand (XEXP (x
, 1), VOIDmode
)));
1446 /* Worker function for TARGET_LEGITIMATE_ADDRESS_P.
1448 A PIC operand looks like a normal symbol here. At output we dress it
1449 in "[rPIC+symbol:GOT]" (global symbol) or "rPIC+symbol:GOTOFF" (local
1450 symbol) so we exclude all addressing modes where we can't replace a
1451 plain "symbol" with that. A global PIC symbol does not fit anywhere
1452 here (but is thankfully a general_operand in itself). A local PIC
1453 symbol is valid for the plain "symbol + offset" case. */
1456 cris_legitimate_address_p (machine_mode mode
, rtx x
, bool strict
)
1460 if (cris_base_or_autoincr_p (x
, strict
))
1462 else if (TARGET_V32
)
1463 /* Nothing else is valid then. */
1465 else if (cris_constant_index_p (x
))
1468 else if (GET_CODE (x
) == PLUS
)
1473 if ((cris_base_p (x1
, strict
) && cris_constant_index_p (x2
))
1474 || (cris_base_p (x2
, strict
) && cris_constant_index_p (x1
))
1475 /* BDAP Rs[+], Rd. */
1476 || (GET_MODE_SIZE (mode
) <= UNITS_PER_WORD
1477 && ((cris_base_p (x1
, strict
)
1478 && cris_bdap_index_p (x2
, strict
))
1479 || (cris_base_p (x2
, strict
)
1480 && cris_bdap_index_p (x1
, strict
))
1482 || (cris_base_p (x1
, strict
)
1483 && cris_biap_index_p (x2
, strict
))
1484 || (cris_base_p (x2
, strict
)
1485 && cris_biap_index_p (x1
, strict
)))))
1490 /* DIP (Rs). Reject [[reg+]] and [[reg]] for DImode (long long). */
1491 if (GET_MODE_SIZE (mode
) <= UNITS_PER_WORD
1492 && cris_base_or_autoincr_p (XEXP (x
, 0), strict
))
1499 /* Worker function for TARGET_LEGITIMATE_CONSTANT_P. We have to handle
1500 PIC constants that aren't legitimized. FIXME: there used to be a
1501 guarantee that the target LEGITIMATE_CONSTANT_P didn't have to handle
1502 PIC constants, but no more (4.7 era); testcase: glibc init-first.c.
1503 While that may be seen as a bug, that guarantee seems a wart by design,
1504 so don't bother; fix the documentation instead. */
1507 cris_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED
, rtx x
)
1509 enum cris_symbol_type t
;
1512 return LEGITIMATE_PIC_OPERAND_P (x
);
1514 t
= cris_symbol_type_of (x
);
1518 || t
== cris_offsettable_symbol
1519 || t
== cris_unspec
;
1522 /* Worker function for LEGITIMIZE_RELOAD_ADDRESS. */
1525 cris_reload_address_legitimized (rtx x
,
1526 machine_mode mode ATTRIBUTE_UNUSED
,
1527 int opnum ATTRIBUTE_UNUSED
,
1529 int ind_levels ATTRIBUTE_UNUSED
)
1531 enum reload_type type
= (enum reload_type
) itype
;
1535 if (GET_CODE (x
) != PLUS
)
1543 op1p
= &XEXP (x
, 1);
1548 if (GET_CODE (op0
) == SIGN_EXTEND
&& MEM_P (XEXP (op0
, 0)))
1550 rtx op00
= XEXP (op0
, 0);
1551 rtx op000
= XEXP (op00
, 0);
1552 rtx
*op000p
= &XEXP (op00
, 0);
1554 if ((GET_MODE (op00
) == HImode
|| GET_MODE (op00
) == QImode
)
1556 || (GET_CODE (op000
) == POST_INC
&& REG_P (XEXP (op000
, 0)))))
1558 bool something_reloaded
= false;
1560 if (GET_CODE (op000
) == POST_INC
1561 && REG_P (XEXP (op000
, 0))
1562 && REGNO (XEXP (op000
, 0)) > CRIS_LAST_GENERAL_REGISTER
)
1563 /* No, this gets too complicated and is too rare to care
1564 about trying to improve on the general code Here.
1565 As the return-value is an all-or-nothing indicator, we
1566 punt on the other register too. */
1570 && REGNO (op000
) > CRIS_LAST_GENERAL_REGISTER
))
1572 /* The address of the inner mem is a pseudo or wrong
1573 reg: reload that. */
1574 push_reload (op000
, NULL_RTX
, op000p
, NULL
, GENERAL_REGS
,
1575 GET_MODE (x
), VOIDmode
, 0, 0, opnum
, type
);
1576 something_reloaded
= true;
1579 if (REGNO (op1
) > CRIS_LAST_GENERAL_REGISTER
)
1581 /* Base register is a pseudo or wrong reg: reload it. */
1582 push_reload (op1
, NULL_RTX
, op1p
, NULL
, GENERAL_REGS
,
1583 GET_MODE (x
), VOIDmode
, 0, 0,
1585 something_reloaded
= true;
1588 gcc_assert (something_reloaded
);
1598 /* Worker function for TARGET_PREFERRED_RELOAD_CLASS.
1600 It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as
1601 the class for a constant (testcase: __Mul in arit.c). To avoid forcing
1602 out a constant into the constant pool, we will trap this case and
1603 return something a bit more sane. FIXME: Check if this is a bug.
1604 Beware that we must not "override" classes that can be specified as
1605 constraint letters, or else asm operands using them will fail when
1606 they need to be reloaded. FIXME: Investigate whether that constitutes
1610 cris_preferred_reload_class (rtx x ATTRIBUTE_UNUSED
, reg_class_t rclass
)
1612 if (rclass
!= ACR_REGS
1613 && rclass
!= MOF_REGS
1614 && rclass
!= MOF_SRP_REGS
1615 && rclass
!= SRP_REGS
1616 && rclass
!= CC0_REGS
1617 && rclass
!= SPECIAL_REGS
)
1618 return GENNONACR_REGS
;
1623 /* Worker function for TARGET_REGISTER_MOVE_COST. */
1626 cris_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED
,
1627 reg_class_t from
, reg_class_t to
)
1629 /* Can't move to and from a SPECIAL_REGS register, so we have to say
1630 their move cost within that class is higher. How about 7? That's 3
1631 for a move to a GENERAL_REGS register, 3 for the move from the
1632 GENERAL_REGS register, and 1 for the increased register pressure.
1633 Also, it's higher than the memory move cost, as it should.
1634 We also do this for ALL_REGS, since we don't want that class to be
1635 preferred (even to memory) at all where GENERAL_REGS doesn't fit.
1636 Whenever it's about to be used, it's for SPECIAL_REGS. If we don't
1637 present a higher cost for ALL_REGS than memory, a SPECIAL_REGS may be
1638 used when a GENERAL_REGS should be used, even if there are call-saved
1639 GENERAL_REGS left to allocate. This is because the fall-back when
1640 the most preferred register class isn't available, isn't the next
1641 (or next good) wider register class, but the *most widest* register
1642 class. FIXME: pre-IRA comment, perhaps obsolete now. */
1644 if ((reg_classes_intersect_p (from
, SPECIAL_REGS
)
1645 && reg_classes_intersect_p (to
, SPECIAL_REGS
))
1646 || from
== ALL_REGS
|| to
== ALL_REGS
)
1649 /* Make moves to/from SPECIAL_REGS slightly more expensive, as we
1650 generally prefer GENERAL_REGS. */
1651 if (reg_classes_intersect_p (from
, SPECIAL_REGS
)
1652 || reg_classes_intersect_p (to
, SPECIAL_REGS
))
1658 /* Worker function for TARGET_MEMORY_MOVE_COST.
1660 This isn't strictly correct for v0..3 in buswidth-8bit mode, but should
1664 cris_memory_move_cost (machine_mode mode
,
1665 reg_class_t rclass ATTRIBUTE_UNUSED
,
1666 bool in ATTRIBUTE_UNUSED
)
1675 /* Worker for cris_notice_update_cc; handles the "normal" cases.
1676 FIXME: this code is historical; its functionality should be
1677 refactored to look at insn attributes and moved to
1678 cris_notice_update_cc. Except, we better lose cc0 entirely. */
1681 cris_normal_notice_update_cc (rtx exp
, rtx insn
)
1683 /* "Normal" means, for:
1688 CC is (reg) and (...) - unless (...) is 0 or reg is a special
1689 register or (v32 and (...) is -32..-1), then CC does not change.
1690 CC_NO_OVERFLOW unless (...) is reg or mem.
1699 (set (reg1) (mem (bdap/biap)))
1700 (set (reg2) (bdap/biap))):
1701 CC is (reg1) and (mem (reg2))
1704 (set (mem (bdap/biap)) (reg1)) [or 0]
1705 (set (reg2) (bdap/biap))):
1708 (where reg and mem includes strict_low_parts variants thereof)
1710 For all others, assume CC is clobbered.
1711 Note that we do not have to care about setting CC_NO_OVERFLOW,
1712 since the overflow flag is set to 0 (i.e. right) for
1713 instructions where it does not have any sane sense, but where
1714 other flags have meanings. (This includes shifts; the carry is
1717 Note that there are other parallel constructs we could match,
1718 but we don't do that yet. */
1720 if (GET_CODE (exp
) == SET
)
1722 /* FIXME: Check when this happens. It looks like we should
1723 actually do a CC_STATUS_INIT here to be safe. */
1724 if (SET_DEST (exp
) == pc_rtx
)
1727 /* Record CC0 changes, so we do not have to output multiple
1729 if (SET_DEST (exp
) == cc0_rtx
)
1733 if (GET_CODE (SET_SRC (exp
)) == COMPARE
1734 && XEXP (SET_SRC (exp
), 1) == const0_rtx
)
1735 cc_status
.value1
= XEXP (SET_SRC (exp
), 0);
1737 cc_status
.value1
= SET_SRC (exp
);
1739 /* Handle flags for the special btstq on one bit. */
1740 if (GET_CODE (cc_status
.value1
) == ZERO_EXTRACT
1741 && XEXP (cc_status
.value1
, 1) == const1_rtx
)
1743 if (CONST_INT_P (XEXP (cc_status
.value1
, 0)))
1745 cc_status
.flags
= CC_INVERTED
;
1747 /* A one-bit btstq. */
1748 cc_status
.flags
= CC_Z_IN_NOT_N
;
1751 else if (GET_CODE (SET_SRC (exp
)) == COMPARE
)
1753 if (!REG_P (XEXP (SET_SRC (exp
), 0))
1754 && XEXP (SET_SRC (exp
), 1) != const0_rtx
)
1755 /* For some reason gcc will not canonicalize compare
1756 operations, reversing the sign by itself if
1757 operands are in wrong order. */
1758 /* (But NOT inverted; eq is still eq.) */
1759 cc_status
.flags
= CC_REVERSED
;
1761 /* This seems to be overlooked by gcc. FIXME: Check again.
1762 FIXME: Is it really safe? */
1764 = gen_rtx_MINUS (GET_MODE (SET_SRC (exp
)),
1765 XEXP (SET_SRC (exp
), 0),
1766 XEXP (SET_SRC (exp
), 1));
1770 else if (REG_P (SET_DEST (exp
))
1771 || (GET_CODE (SET_DEST (exp
)) == STRICT_LOW_PART
1772 && REG_P (XEXP (SET_DEST (exp
), 0))))
1774 /* A register is set; normally CC is set to show that no
1775 test insn is needed. Catch the exceptions. */
1777 /* If not to cc0, then no "set"s in non-natural mode give
1779 if (GET_MODE_SIZE (GET_MODE (SET_DEST (exp
))) > UNITS_PER_WORD
1780 || GET_MODE_CLASS (GET_MODE (SET_DEST (exp
))) == MODE_FLOAT
)
1782 /* ... except add:s and sub:s in DImode. */
1783 if (GET_MODE (SET_DEST (exp
)) == DImode
1784 && (GET_CODE (SET_SRC (exp
)) == PLUS
1785 || GET_CODE (SET_SRC (exp
)) == MINUS
))
1788 cc_status
.value1
= SET_DEST (exp
);
1789 cc_status
.value2
= SET_SRC (exp
);
1791 if (cris_reg_overlap_mentioned_p (cc_status
.value1
,
1793 cc_status
.value2
= 0;
1795 /* Add and sub may set V, which gets us
1796 unoptimizable results in "gt" and "le" condition
1798 cc_status
.flags
|= CC_NO_OVERFLOW
;
1803 else if (SET_SRC (exp
) == const0_rtx
1804 || (REG_P (SET_SRC (exp
))
1805 && (REGNO (SET_SRC (exp
))
1806 > CRIS_LAST_GENERAL_REGISTER
))
1808 && REG_P (SET_DEST (exp
))
1809 && satisfies_constraint_I (SET_SRC (exp
))))
1811 /* There's no CC0 change for this case. Just check
1813 if (cc_status
.value1
1814 && modified_in_p (cc_status
.value1
, insn
))
1815 cc_status
.value1
= 0;
1817 if (cc_status
.value2
1818 && modified_in_p (cc_status
.value2
, insn
))
1819 cc_status
.value2
= 0;
1826 cc_status
.value1
= SET_DEST (exp
);
1827 cc_status
.value2
= SET_SRC (exp
);
1829 if (cris_reg_overlap_mentioned_p (cc_status
.value1
,
1831 cc_status
.value2
= 0;
1833 /* Some operations may set V, which gets us
1834 unoptimizable results in "gt" and "le" condition
1836 if (GET_CODE (SET_SRC (exp
)) == PLUS
1837 || GET_CODE (SET_SRC (exp
)) == MINUS
1838 || GET_CODE (SET_SRC (exp
)) == NEG
)
1839 cc_status
.flags
|= CC_NO_OVERFLOW
;
1841 /* For V32, nothing with a register destination sets
1842 C and V usefully. */
1844 cc_status
.flags
|= CC_NO_OVERFLOW
;
1849 else if (MEM_P (SET_DEST (exp
))
1850 || (GET_CODE (SET_DEST (exp
)) == STRICT_LOW_PART
1851 && MEM_P (XEXP (SET_DEST (exp
), 0))))
1853 /* When SET to MEM, then CC is not changed (except for
1855 if (cc_status
.value1
1856 && modified_in_p (cc_status
.value1
, insn
))
1857 cc_status
.value1
= 0;
1859 if (cc_status
.value2
1860 && modified_in_p (cc_status
.value2
, insn
))
1861 cc_status
.value2
= 0;
1866 else if (GET_CODE (exp
) == PARALLEL
)
1868 if (GET_CODE (XVECEXP (exp
, 0, 0)) == SET
1869 && GET_CODE (XVECEXP (exp
, 0, 1)) == SET
1870 && REG_P (XEXP (XVECEXP (exp
, 0, 1), 0)))
1872 if (REG_P (XEXP (XVECEXP (exp
, 0, 0), 0))
1873 && MEM_P (XEXP (XVECEXP (exp
, 0, 0), 1)))
1877 /* For "move.S [rx=ry+o],rz", say CC reflects
1878 value1=rz and value2=[rx] */
1879 cc_status
.value1
= XEXP (XVECEXP (exp
, 0, 0), 0);
1881 = replace_equiv_address (XEXP (XVECEXP (exp
, 0, 0), 1),
1882 XEXP (XVECEXP (exp
, 0, 1), 0));
1884 /* Huh? A side-effect cannot change the destination
1886 if (cris_reg_overlap_mentioned_p (cc_status
.value1
,
1888 internal_error ("internal error: sideeffect-insn affecting main effect");
1890 /* For V32, moves to registers don't set C and V. */
1892 cc_status
.flags
|= CC_NO_OVERFLOW
;
1895 else if ((REG_P (XEXP (XVECEXP (exp
, 0, 0), 1))
1896 || XEXP (XVECEXP (exp
, 0, 0), 1) == const0_rtx
)
1897 && MEM_P (XEXP (XVECEXP (exp
, 0, 0), 0)))
1899 /* For "move.S rz,[rx=ry+o]" and "clear.S [rx=ry+o]",
1900 say flags are not changed, except for overlap. */
1901 if (cc_status
.value1
1902 && modified_in_p (cc_status
.value1
, insn
))
1903 cc_status
.value1
= 0;
1905 if (cc_status
.value2
1906 && modified_in_p (cc_status
.value2
, insn
))
1907 cc_status
.value2
= 0;
1914 /* If we got here, the case wasn't covered by the code above. */
1918 /* This function looks into the pattern to see how this insn affects
1921 Used when to eliminate test insns before a condition-code user,
1922 such as a "scc" insn or a conditional branch. This includes
1923 checking if the entities that cc was updated by, are changed by the
1926 Currently a jumble of the old peek-inside-the-insn and the newer
1927 check-cc-attribute methods. */
1930 cris_notice_update_cc (rtx exp
, rtx_insn
*insn
)
1932 enum attr_cc attrval
= get_attr_cc (insn
);
1934 /* Check if user specified "-mcc-init" as a bug-workaround. Remember
1935 to still set CC_REVERSED as below, since that's required by some
1936 compare insn alternatives. (FIXME: GCC should do this virtual
1937 operand swap by itself.) A test-case that may otherwise fail is
1938 gcc.c-torture/execute/20000217-1.c -O0 and -O1. */
1943 if (attrval
== CC_REV
)
1944 cc_status
.flags
= CC_REVERSED
;
1948 /* Slowly, we're converting to using attributes to control the setting
1949 of condition-code status. */
1953 /* Even if it is "none", a setting may clobber a previous
1954 cc-value, so check. */
1955 if (GET_CODE (exp
) == SET
)
1957 if (cc_status
.value1
1958 && modified_in_p (cc_status
.value1
, insn
))
1959 cc_status
.value1
= 0;
1961 if (cc_status
.value2
1962 && modified_in_p (cc_status
.value2
, insn
))
1963 cc_status
.value2
= 0;
1974 cris_normal_notice_update_cc (exp
, insn
);
1976 /* The "test" insn doesn't clear (carry and) overflow on V32. We
1977 can change bge => bpl and blt => bmi by passing on to the cc0
1978 user that V should not be considered; bgt and ble are taken
1979 care of by other methods (see {tst,cmp}{si,hi,qi}). */
1980 if (attrval
== CC_NOOV32
&& TARGET_V32
)
1981 cc_status
.flags
|= CC_NO_OVERFLOW
;
1985 internal_error ("unknown cc_attr value");
1991 /* Return != 0 if the return sequence for the current function is short,
1992 like "ret" or "jump [sp+]". Prior to reloading, we can't tell if
1993 registers must be saved, so return 0 then. */
1996 cris_simple_epilogue (void)
1999 unsigned int reglimit
= STACK_POINTER_REGNUM
;
2000 bool got_really_used
= false;
2002 if (! reload_completed
2003 || frame_pointer_needed
2004 || get_frame_size () != 0
2005 || crtl
->args
.pretend_args_size
2007 || crtl
->outgoing_args_size
2008 || crtl
->calls_eh_return
2010 /* If we're not supposed to emit prologue and epilogue, we must
2011 not emit return-type instructions. */
2012 || !TARGET_PROLOGUE_EPILOGUE
)
2015 /* Can't return from stacked return address with v32. */
2016 if (TARGET_V32
&& cris_return_address_on_stack ())
2019 if (crtl
->uses_pic_offset_table
)
2021 push_topmost_sequence ();
2023 = reg_used_between_p (pic_offset_table_rtx
, get_insns (), NULL
);
2024 pop_topmost_sequence ();
2027 /* No simple epilogue if there are saved registers. */
2028 for (regno
= 0; regno
< reglimit
; regno
++)
2029 if (cris_reg_saved_in_regsave_area (regno
, got_really_used
))
2035 /* Emit checking that MEM is aligned for an access in MODE, failing
2036 that, executing a "break 8" (or call to abort, if "break 8" is
2040 cris_emit_trap_for_misalignment (rtx mem
)
2042 rtx addr
, reg
, ok_label
, andop
;
2044 int natural_alignment
;
2045 gcc_assert (MEM_P (mem
));
2047 natural_alignment
= GET_MODE_SIZE (GET_MODE (mem
));
2048 addr
= XEXP (mem
, 0);
2049 reg
= force_reg (Pmode
, addr
);
2050 ok_label
= gen_label_rtx ();
2052 /* This will yield a btstq without a separate register used, usually -
2053 with the exception for PRE hoisting the "and" but not the branch
2054 around the trap: see testsuite/gcc.target/cris/sync-3s.c. */
2055 andop
= gen_rtx_AND (Pmode
, reg
, GEN_INT (natural_alignment
- 1));
2056 emit_cmp_and_jump_insns (force_reg (SImode
, andop
), const0_rtx
, EQ
,
2057 NULL_RTX
, Pmode
, 1, ok_label
);
2058 jmp
= get_last_insn ();
2059 gcc_assert (JUMP_P (jmp
));
2061 predict_insn_def (jmp
, PRED_NORETURN
, TAKEN
);
2062 expand_builtin_trap ();
2063 emit_label (ok_label
);
2066 /* Expand a return insn (just one insn) marked as using SRP or stack
2067 slot depending on parameter ON_STACK. */
2070 cris_expand_return (bool on_stack
)
2072 /* FIXME: emit a parallel with a USE for SRP or the stack-slot, to
2073 tell "ret" from "jump [sp+]". Some, but not all, other parts of
2074 GCC expect just (return) to do the right thing when optimizing, so
2075 we do that until they're fixed. Currently, all return insns in a
2076 function must be the same (not really a limiting factor) so we need
2077 to check that it doesn't change half-way through. */
2078 emit_jump_insn (ret_rtx
);
2080 CRIS_ASSERT (cfun
->machine
->return_type
!= CRIS_RETINSN_RET
|| !on_stack
);
2081 CRIS_ASSERT (cfun
->machine
->return_type
!= CRIS_RETINSN_JUMP
|| on_stack
);
2083 cfun
->machine
->return_type
2084 = on_stack
? CRIS_RETINSN_JUMP
: CRIS_RETINSN_RET
;
2087 /* Compute a (partial) cost for rtx X. Return true if the complete
2088 cost has been computed, and false if subexpressions should be
2089 scanned. In either case, *TOTAL contains the cost result. */
2092 cris_rtx_costs (rtx x
, machine_mode mode
, int outer_code
, int opno
,
2093 int *total
, bool speed
)
2095 int code
= GET_CODE (x
);
2101 HOST_WIDE_INT val
= INTVAL (x
);
2104 else if (val
< 32 && val
>= -32)
2106 /* Eight or 16 bits are a word and cycle more expensive. */
2107 else if (val
<= 32767 && val
>= -32768)
2109 /* A 32-bit constant (or very seldom, unsigned 16 bits) costs
2110 another word. FIXME: This isn't linear to 16 bits. */
2126 if (x
!= CONST0_RTX (mode
== VOIDmode
? DImode
: mode
))
2129 /* Make 0.0 cheap, else test-insns will not be used. */
2134 /* If we have one arm of an ADDI, make sure it gets the cost of
2135 one insn, i.e. zero cost for this operand, and just the cost
2136 of the PLUS, as the insn is created by combine from a PLUS
2137 and an ASHIFT, and the MULT cost below would make the
2138 combined value be larger than the separate insns. The insn
2139 validity is checked elsewhere by combine.
2141 FIXME: this case is a stop-gap for 4.3 and 4.4, this whole
2142 function should be rewritten. */
2143 if (outer_code
== PLUS
&& cris_biap_index_p (x
, false))
2149 /* Identify values that are no powers of two. Powers of 2 are
2150 taken care of already and those values should not be changed. */
2151 if (!CONST_INT_P (XEXP (x
, 1))
2152 || exact_log2 (INTVAL (XEXP (x
, 1)) < 0))
2154 /* If we have a multiply insn, then the cost is between
2155 1 and 2 "fast" instructions. */
2156 if (TARGET_HAS_MUL_INSNS
)
2158 *total
= COSTS_N_INSNS (1) + COSTS_N_INSNS (1) / 2;
2162 /* Estimate as 4 + 4 * #ofbits. */
2163 *total
= COSTS_N_INSNS (132);
2172 if (!CONST_INT_P (XEXP (x
, 1))
2173 || exact_log2 (INTVAL (XEXP (x
, 1)) < 0))
2175 /* Estimate this as 4 + 8 * #of bits. */
2176 *total
= COSTS_N_INSNS (260);
2182 if (CONST_INT_P (XEXP (x
, 1))
2183 /* Two constants may actually happen before optimization. */
2184 && !CONST_INT_P (XEXP (x
, 0))
2185 && !satisfies_constraint_I (XEXP (x
, 1)))
2188 = (rtx_cost (XEXP (x
, 0), mode
, (enum rtx_code
) outer_code
,
2190 + 2 * GET_MODE_NUNITS (mode
));
2196 if (outer_code
!= COMPARE
)
2200 case ZERO_EXTEND
: case SIGN_EXTEND
:
2201 *total
= rtx_cost (XEXP (x
, 0), VOIDmode
, (enum rtx_code
) outer_code
,
2210 /* The ADDRESS_COST worker. */
2213 cris_address_cost (rtx x
, machine_mode mode ATTRIBUTE_UNUSED
,
2214 addr_space_t as ATTRIBUTE_UNUSED
,
2215 bool speed ATTRIBUTE_UNUSED
)
2217 /* The metric to use for the cost-macros is unclear.
2218 The metric used here is (the number of cycles needed) / 2,
2219 where we consider equal a cycle for a word of code and a cycle to
2220 read memory. FIXME: Adding "+ 1" to all values would avoid
2221 returning 0, as tree-ssa-loop-ivopts.c as of r128272 "normalizes"
2222 0 to 1, thereby giving equal costs to [rN + rM] and [rN].
2223 Unfortunately(?) such a hack would expose other pessimizations,
2224 at least with g++.dg/tree-ssa/ivopts-1.C, adding insns to the
2225 loop there, without apparent reason. */
2227 /* The cheapest addressing modes get 0, since nothing extra is needed. */
2228 if (cris_base_or_autoincr_p (x
, false))
2231 /* An indirect mem must be a DIP. This means two bytes extra for code,
2232 and 4 bytes extra for memory read, i.e. (2 + 4) / 2. */
2236 /* Assume (2 + 4) / 2 for a single constant; a dword, since it needs
2237 an extra DIP prefix and 4 bytes of constant in most cases. */
2241 /* Handle BIAP and BDAP prefixes. */
2242 if (GET_CODE (x
) == PLUS
)
2244 rtx tem1
= XEXP (x
, 0);
2245 rtx tem2
= XEXP (x
, 1);
2247 /* Local extended canonicalization rule: the first operand must
2248 be REG, unless it's an operation (MULT). */
2249 if (!REG_P (tem1
) && GET_CODE (tem1
) != MULT
)
2250 tem1
= tem2
, tem2
= XEXP (x
, 0);
2252 /* We'll "assume" we have canonical RTX now. */
2253 gcc_assert (REG_P (tem1
) || GET_CODE (tem1
) == MULT
);
2255 /* A BIAP is 2 extra bytes for the prefix insn, nothing more. We
2256 recognize the typical MULT which is always in tem1 because of
2257 insn canonicalization. */
2258 if ((GET_CODE (tem1
) == MULT
&& cris_biap_index_p (tem1
, false))
2262 /* A BDAP (quick) is 2 extra bytes. Any constant operand to the
2263 PLUS is always found in tem2. */
2264 if (CONST_INT_P (tem2
) && INTVAL (tem2
) < 128 && INTVAL (tem2
) >= -128)
2267 /* A BDAP -32768 .. 32767 is like BDAP quick, but with 2 extra
2269 if (satisfies_constraint_L (tem2
))
2272 /* A BDAP with some other constant is 2 bytes extra. */
2273 if (CRIS_CONSTANT_P (tem2
))
2274 return (2 + 2 + 2) / 2;
2276 /* BDAP with something indirect should have a higher cost than
2277 BIAP with register. FIXME: Should it cost like a MEM or more? */
2278 return (2 + 2 + 2) / 2;
2281 /* What else? Return a high cost. It matters only for valid
2282 addressing modes. */
2286 /* Check various objections to the side-effect. Used in the test-part
2287 of an anonymous insn describing an insn with a possible side-effect.
2288 Returns nonzero if the implied side-effect is ok.
2291 ops : An array of rtx:es. lreg, rreg, rval,
2292 The variables multop and other_op are indexes into this,
2293 or -1 if they are not applicable.
2294 lreg : The register that gets assigned in the side-effect.
2295 rreg : One register in the side-effect expression
2296 rval : The other register, or an int.
2297 multop : An integer to multiply rval with.
2298 other_op : One of the entities of the main effect,
2299 whose mode we must consider. */
2302 cris_side_effect_mode_ok (enum rtx_code code
, rtx
*ops
,
2303 int lreg
, int rreg
, int rval
,
2304 int multop
, int other_op
)
2306 /* Find what value to multiply with, for rx =ry + rz * n. */
2307 int mult
= multop
< 0 ? 1 : INTVAL (ops
[multop
]);
2309 rtx reg_rtx
= ops
[rreg
];
2310 rtx val_rtx
= ops
[rval
];
2312 /* The operands may be swapped. Canonicalize them in reg_rtx and
2313 val_rtx, where reg_rtx always is a reg (for this constraint to
2315 if (! cris_base_p (reg_rtx
, reload_in_progress
|| reload_completed
))
2316 reg_rtx
= val_rtx
, val_rtx
= ops
[rreg
];
2318 /* Don't forget to check that reg_rtx really is a reg. If it isn't,
2319 we have no business. */
2320 if (! cris_base_p (reg_rtx
, reload_in_progress
|| reload_completed
))
2323 /* Don't do this when -mno-split. */
2324 if (!TARGET_SIDE_EFFECT_PREFIXES
)
2327 /* The mult expression may be hidden in lreg. FIXME: Add more
2328 commentary about that. */
2329 if (GET_CODE (val_rtx
) == MULT
)
2331 mult
= INTVAL (XEXP (val_rtx
, 1));
2332 val_rtx
= XEXP (val_rtx
, 0);
2336 /* First check the "other operand". */
2339 if (GET_MODE_SIZE (GET_MODE (ops
[other_op
])) > UNITS_PER_WORD
)
2342 /* Check if the lvalue register is the same as the "other
2343 operand". If so, the result is undefined and we shouldn't do
2344 this. FIXME: Check again. */
2345 if ((cris_base_p (ops
[lreg
], reload_in_progress
|| reload_completed
)
2346 && cris_base_p (ops
[other_op
],
2347 reload_in_progress
|| reload_completed
)
2348 && REGNO (ops
[lreg
]) == REGNO (ops
[other_op
]))
2349 || rtx_equal_p (ops
[other_op
], ops
[lreg
]))
2353 /* Do not accept frame_pointer_rtx as any operand. */
2354 if (ops
[lreg
] == frame_pointer_rtx
|| ops
[rreg
] == frame_pointer_rtx
2355 || ops
[rval
] == frame_pointer_rtx
2356 || (other_op
>= 0 && ops
[other_op
] == frame_pointer_rtx
))
2360 && ! cris_base_p (val_rtx
, reload_in_progress
|| reload_completed
))
2363 /* Do not allow rx = rx + n if a normal add or sub with same size
2365 if (rtx_equal_p (ops
[lreg
], reg_rtx
)
2366 && CONST_INT_P (val_rtx
)
2367 && (INTVAL (val_rtx
) <= 63 && INTVAL (val_rtx
) >= -63))
2370 /* Check allowed cases, like [r(+)?].[bwd] and const. */
2371 if (CRIS_CONSTANT_P (val_rtx
))
2375 && cris_base_or_autoincr_p (XEXP (val_rtx
, 0),
2376 reload_in_progress
|| reload_completed
))
2379 if (GET_CODE (val_rtx
) == SIGN_EXTEND
2380 && MEM_P (XEXP (val_rtx
, 0))
2381 && cris_base_or_autoincr_p (XEXP (XEXP (val_rtx
, 0), 0),
2382 reload_in_progress
|| reload_completed
))
2385 /* If we got here, it's not a valid addressing mode. */
2388 else if (code
== MULT
2390 && cris_base_p (val_rtx
,
2391 reload_in_progress
|| reload_completed
)))
2393 /* Do not allow rx = rx + ry.S, since it doesn't give better code. */
2394 if (rtx_equal_p (ops
[lreg
], reg_rtx
)
2395 || (mult
== 1 && rtx_equal_p (ops
[lreg
], val_rtx
)))
2398 /* Do not allow bad multiply-values. */
2399 if (mult
!= 1 && mult
!= 2 && mult
!= 4)
2402 /* Only allow r + ... */
2403 if (! cris_base_p (reg_rtx
, reload_in_progress
|| reload_completed
))
2406 /* If we got here, all seems ok.
2407 (All checks need to be done above). */
2411 /* If we get here, the caller got its initial tests wrong. */
2412 internal_error ("internal error: cris_side_effect_mode_ok with bad operands");
2415 /* Whether next_cc0_user of insn is LE or GT or requires a real compare
2416 insn for other reasons. */
2419 cris_cc0_user_requires_cmp (rtx_insn
*insn
)
2421 rtx_insn
*cc0_user
= NULL
;
2425 gcc_assert (insn
!= NULL
);
2430 cc0_user
= next_cc0_user (insn
);
2431 if (cc0_user
== NULL
)
2434 body
= PATTERN (cc0_user
);
2435 set
= single_set (cc0_user
);
2437 /* Users can be sCC and bCC. */
2438 if (JUMP_P (cc0_user
)
2439 && GET_CODE (body
) == SET
2440 && SET_DEST (body
) == pc_rtx
2441 && GET_CODE (SET_SRC (body
)) == IF_THEN_ELSE
2442 && XEXP (XEXP (SET_SRC (body
), 0), 0) == cc0_rtx
)
2445 GET_CODE (XEXP (SET_SRC (body
), 0)) == GT
2446 || GET_CODE (XEXP (SET_SRC (body
), 0)) == LE
;
2451 GET_CODE (SET_SRC (body
)) == GT
2452 || GET_CODE (SET_SRC (body
)) == LE
;
2458 /* The function reg_overlap_mentioned_p in CVS (still as of 2001-05-16)
2459 does not handle the case where the IN operand is strict_low_part; it
2460 does handle it for X. Test-case in Axis-20010516. This function takes
2461 care of that for THIS port. FIXME: strict_low_part is going away
2465 cris_reg_overlap_mentioned_p (rtx x
, rtx in
)
2467 /* The function reg_overlap_mentioned now handles when X is
2468 strict_low_part, but not when IN is a STRICT_LOW_PART. */
2469 if (GET_CODE (in
) == STRICT_LOW_PART
)
2472 return reg_overlap_mentioned_p (x
, in
);
2475 /* Return TRUE iff X is a CONST valid for e.g. indexing.
2476 ANY_OPERAND is 0 if X is in a CALL_P insn or movsi, 1
2480 cris_valid_pic_const (const_rtx x
, bool any_operand
)
2482 gcc_assert (flag_pic
);
2484 switch (GET_CODE (x
))
2493 if (GET_CODE (x
) != CONST
)
2498 /* Handle (const (plus (unspec .. UNSPEC_GOTREL) (const_int ...))). */
2499 if (GET_CODE (x
) == PLUS
2500 && GET_CODE (XEXP (x
, 0)) == UNSPEC
2501 && (XINT (XEXP (x
, 0), 1) == CRIS_UNSPEC_GOTREL
2502 || XINT (XEXP (x
, 0), 1) == CRIS_UNSPEC_PCREL
)
2503 && CONST_INT_P (XEXP (x
, 1)))
2506 if (GET_CODE (x
) == UNSPEC
)
2507 switch (XINT (x
, 1))
2509 /* A PCREL operand is only valid for call and movsi. */
2510 case CRIS_UNSPEC_PLT_PCREL
:
2511 case CRIS_UNSPEC_PCREL
:
2512 return !any_operand
;
2514 case CRIS_UNSPEC_PLT_GOTREL
:
2515 case CRIS_UNSPEC_PLTGOTREAD
:
2516 case CRIS_UNSPEC_GOTREAD
:
2517 case CRIS_UNSPEC_GOTREL
:
2523 return cris_symbol_type_of (x
) == cris_no_symbol
;
2526 /* Helper function to find the right symbol-type to generate,
2527 given the original (non-PIC) representation. */
2529 enum cris_symbol_type
2530 cris_symbol_type_of (const_rtx x
)
2532 switch (GET_CODE (x
))
2536 ? (SYMBOL_REF_LOCAL_P (x
)
2537 ? cris_rel_symbol
: cris_got_symbol
)
2538 : cris_offsettable_symbol
;
2541 return flag_pic
? cris_rel_symbol
: cris_offsettable_symbol
;
2544 return cris_symbol_type_of (XEXP (x
, 0));
2549 enum cris_symbol_type t1
= cris_symbol_type_of (XEXP (x
, 0));
2550 enum cris_symbol_type t2
= cris_symbol_type_of (XEXP (x
, 1));
2552 gcc_assert (t1
== cris_no_symbol
|| t2
== cris_no_symbol
);
2554 if (t1
== cris_got_symbol
|| t2
== cris_got_symbol
)
2555 return cris_got_symbol_needing_fixup
;
2557 return t1
!= cris_no_symbol
? t1
: t2
;
2562 return cris_no_symbol
;
2568 fatal_insn ("unrecognized supposed constant", x
);
2574 /* The LEGITIMATE_PIC_OPERAND_P worker. */
2577 cris_legitimate_pic_operand (rtx x
)
2579 /* Symbols are not valid PIC operands as-is; just constants. */
2580 return cris_valid_pic_const (x
, true);
2583 /* Queue an .ident string in the queue of top-level asm statements.
2584 If the front-end is done, we must be being called from toplev.c.
2585 In that case, do nothing. */
2587 cris_asm_output_ident (const char *string
)
2589 if (symtab
->state
!= PARSING
)
2592 default_asm_output_ident_directive (string
);
2595 /* The ASM_OUTPUT_CASE_END worker. */
2598 cris_asm_output_case_end (FILE *stream
, int num
, rtx_insn
*table
)
2600 /* Step back, over the label for the table, to the actual casejump and
2601 assert that we find only what's expected. */
2602 rtx_insn
*whole_jump_insn
= prev_nonnote_nondebug_insn (table
);
2603 gcc_assert (whole_jump_insn
!= NULL_RTX
&& LABEL_P (whole_jump_insn
));
2604 whole_jump_insn
= prev_nonnote_nondebug_insn (whole_jump_insn
);
2605 gcc_assert (whole_jump_insn
!= NULL_RTX
2606 && (JUMP_P (whole_jump_insn
)
2607 || (TARGET_V32
&& INSN_P (whole_jump_insn
)
2608 && GET_CODE (PATTERN (whole_jump_insn
)) == SEQUENCE
)));
2609 /* Get the pattern of the casejump, so we can extract the default label. */
2610 rtx whole_jump_pat
= PATTERN (whole_jump_insn
);
2614 /* This can be a SEQUENCE, meaning the delay-slot of the jump is
2615 filled. We also output the offset word a little differently. */
2617 = (GET_CODE (whole_jump_pat
) == SEQUENCE
2618 ? PATTERN (XVECEXP (whole_jump_pat
, 0, 0)) : whole_jump_pat
);
2620 asm_fprintf (stream
,
2621 "\t.word %LL%d-.%s\n",
2622 CODE_LABEL_NUMBER (XEXP (XEXP (XEXP (XVECEXP
2623 (parallel_jump
, 0, 0),
2625 (TARGET_PDEBUG
? "; default" : ""));
2629 asm_fprintf (stream
,
2630 "\t.word %LL%d-%LL%d%s\n",
2631 CODE_LABEL_NUMBER (XEXP
2633 (XEXP (XVECEXP (whole_jump_pat
, 0, 0), 1),
2636 (TARGET_PDEBUG
? "; default" : ""));
2639 /* The TARGET_OPTION_OVERRIDE worker.
2640 As is the norm, this also parses -mfoo=bar type parameters. */
2643 cris_option_override (void)
2645 if (cris_max_stackframe_str
)
2647 cris_max_stackframe
= atoi (cris_max_stackframe_str
);
2649 /* Do some sanity checking. */
2650 if (cris_max_stackframe
< 0 || cris_max_stackframe
> 0x20000000)
2651 internal_error ("-max-stackframe=%d is not usable, not between 0 and %d",
2652 cris_max_stackframe
, 0x20000000);
2655 /* Let "-metrax4" and "-metrax100" change the cpu version. */
2656 if (TARGET_SVINTO
&& cris_cpu_version
< CRIS_CPU_SVINTO
)
2657 cris_cpu_version
= CRIS_CPU_SVINTO
;
2658 else if (TARGET_ETRAX4_ADD
&& cris_cpu_version
< CRIS_CPU_ETRAX4
)
2659 cris_cpu_version
= CRIS_CPU_ETRAX4
;
2661 /* Parse -march=... and its synonym, the deprecated -mcpu=... */
2665 = (*cris_cpu_str
== 'v' ? atoi (cris_cpu_str
+ 1) : -1);
2667 if (strcmp ("etrax4", cris_cpu_str
) == 0)
2668 cris_cpu_version
= 3;
2670 if (strcmp ("svinto", cris_cpu_str
) == 0
2671 || strcmp ("etrax100", cris_cpu_str
) == 0)
2672 cris_cpu_version
= 8;
2674 if (strcmp ("ng", cris_cpu_str
) == 0
2675 || strcmp ("etrax100lx", cris_cpu_str
) == 0)
2676 cris_cpu_version
= 10;
2678 if (cris_cpu_version
< 0 || cris_cpu_version
> 32)
2679 error ("unknown CRIS version specification in -march= or -mcpu= : %s",
2682 /* Set the target flags. */
2683 if (cris_cpu_version
>= CRIS_CPU_ETRAX4
)
2684 target_flags
|= MASK_ETRAX4_ADD
;
2686 /* If this is Svinto or higher, align for 32 bit accesses. */
2687 if (cris_cpu_version
>= CRIS_CPU_SVINTO
)
2689 |= (MASK_SVINTO
| MASK_ALIGN_BY_32
2690 | MASK_STACK_ALIGN
| MASK_CONST_ALIGN
2693 /* Note that we do not add new flags when it can be completely
2694 described with a macro that uses -mcpu=X. So
2695 TARGET_HAS_MUL_INSNS is (cris_cpu_version >= CRIS_CPU_NG). */
2701 = (*cris_tune_str
== 'v' ? atoi (cris_tune_str
+ 1) : -1);
2703 if (strcmp ("etrax4", cris_tune_str
) == 0)
2706 if (strcmp ("svinto", cris_tune_str
) == 0
2707 || strcmp ("etrax100", cris_tune_str
) == 0)
2710 if (strcmp ("ng", cris_tune_str
) == 0
2711 || strcmp ("etrax100lx", cris_tune_str
) == 0)
2714 if (cris_tune
< 0 || cris_tune
> 32)
2715 error ("unknown CRIS cpu version specification in -mtune= : %s",
2718 if (cris_tune
>= CRIS_CPU_SVINTO
)
2719 /* We have currently nothing more to tune than alignment for
2722 |= (MASK_STACK_ALIGN
| MASK_CONST_ALIGN
2723 | MASK_DATA_ALIGN
| MASK_ALIGN_BY_32
);
2726 if (cris_cpu_version
>= CRIS_CPU_V32
)
2727 target_flags
&= ~(MASK_SIDE_EFFECT_PREFIXES
|MASK_MUL_BUG
);
2731 /* Use error rather than warning, so invalid use is easily
2732 detectable. Still change to the values we expect, to avoid
2736 error ("-fPIC and -fpic are not supported in this configuration");
2740 /* Turn off function CSE. We need to have the addresses reach the
2741 call expanders to get PLT-marked, as they could otherwise be
2742 compared against zero directly or indirectly. After visiting the
2743 call expanders they will then be cse:ed, as the call expanders
2744 force_reg the addresses, effectively forcing flag_no_function_cse
2746 flag_no_function_cse
= 1;
2749 /* Set the per-function-data initializer. */
2750 init_machine_status
= cris_init_machine_status
;
2753 /* The TARGET_ASM_OUTPUT_MI_THUNK worker. */
2756 cris_asm_output_mi_thunk (FILE *stream
,
2757 tree thunkdecl ATTRIBUTE_UNUSED
,
2758 HOST_WIDE_INT delta
,
2759 HOST_WIDE_INT vcall_offset ATTRIBUTE_UNUSED
,
2762 /* Make sure unwind info is emitted for the thunk if needed. */
2763 final_start_function (emit_barrier (), stream
, 1);
2766 fprintf (stream
, "\tadd%s " HOST_WIDE_INT_PRINT_DEC
",$%s\n",
2767 ADDITIVE_SIZE_MODIFIER (delta
), delta
,
2768 reg_names
[CRIS_FIRST_ARG_REG
]);
2770 fprintf (stream
, "\tsub%s " HOST_WIDE_INT_PRINT_DEC
",$%s\n",
2771 ADDITIVE_SIZE_MODIFIER (-delta
), -delta
,
2772 reg_names
[CRIS_FIRST_ARG_REG
]);
2776 const char *name
= XSTR (XEXP (DECL_RTL (funcdecl
), 0), 0);
2778 name
= (* targetm
.strip_name_encoding
) (name
);
2782 fprintf (stream
, "\tba ");
2783 assemble_name (stream
, name
);
2784 fprintf (stream
, "%s\n\tnop\n", CRIS_PLT_PCOFFSET_SUFFIX
);
2788 fprintf (stream
, "\tadd.d ");
2789 assemble_name (stream
, name
);
2790 fprintf (stream
, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX
);
2795 fprintf (stream
, "\tjump ");
2796 assemble_name (stream
, XSTR (XEXP (DECL_RTL (funcdecl
), 0), 0));
2797 fprintf (stream
, "\n");
2800 fprintf (stream
, "\tnop\n");
2803 final_end_function ();
2806 /* Boilerplate emitted at start of file.
2808 NO_APP *only at file start* means faster assembly. It also means
2809 comments are not allowed. In some cases comments will be output
2810 for debugging purposes. Make sure they are allowed then. */
2812 cris_file_start (void)
2814 /* These expressions can vary at run time, so we cannot put
2815 them into TARGET_INITIALIZER. */
2816 targetm
.asm_file_start_app_off
= !(TARGET_PDEBUG
|| flag_print_asm_name
);
2818 default_file_start ();
2821 /* Output that goes at the end of the file, similarly. */
2824 cris_file_end (void)
2826 /* For CRIS, the default is to assume *no* executable stack, so output
2827 an executable-stack-note only when needed. */
2828 if (TARGET_LINUX
&& trampolines_created
)
2829 file_end_indicate_exec_stack ();
2832 /* Rename the function calls for integer multiply and divide. */
2834 cris_init_libfuncs (void)
2836 set_optab_libfunc (smul_optab
, SImode
, "__Mul");
2837 set_optab_libfunc (sdiv_optab
, SImode
, "__Div");
2838 set_optab_libfunc (udiv_optab
, SImode
, "__Udiv");
2839 set_optab_libfunc (smod_optab
, SImode
, "__Mod");
2840 set_optab_libfunc (umod_optab
, SImode
, "__Umod");
2842 /* Atomic data being unaligned is unfortunately a reality.
2844 if (TARGET_ATOMICS_MAY_CALL_LIBFUNCS
)
2846 set_optab_libfunc (sync_compare_and_swap_optab
, SImode
,
2847 "__cris_atcmpxchgr32");
2848 set_optab_libfunc (sync_compare_and_swap_optab
, HImode
,
2849 "__cris_atcmpxchgr16");
2853 /* The INIT_EXPANDERS worker sets the per-function-data initializer and
2857 cris_init_expanders (void)
2859 /* Nothing here at the moment. */
2862 /* Zero initialization is OK for all current fields. */
2864 static struct machine_function
*
2865 cris_init_machine_status (void)
2867 return ggc_cleared_alloc
<machine_function
> ();
2870 /* Split a 2 word move (DI or presumably DF) into component parts.
2871 Originally a copy of gen_split_move_double in m32r.c. */
2874 cris_split_movdx (rtx
*operands
)
2876 machine_mode mode
= GET_MODE (operands
[0]);
2877 rtx dest
= operands
[0];
2878 rtx src
= operands
[1];
2881 /* We used to have to handle (SUBREG (MEM)) here, but that should no
2882 longer happen; after reload there are no SUBREGs any more, and we're
2883 only called after reload. */
2884 CRIS_ASSERT (GET_CODE (dest
) != SUBREG
&& GET_CODE (src
) != SUBREG
);
2889 int dregno
= REGNO (dest
);
2891 /* Reg-to-reg copy. */
2894 int sregno
= REGNO (src
);
2896 int reverse
= (dregno
== sregno
+ 1);
2898 /* We normally copy the low-numbered register first. However, if
2899 the first register operand 0 is the same as the second register of
2900 operand 1, we must copy in the opposite order. */
2901 emit_insn (gen_rtx_SET (operand_subword (dest
, reverse
, TRUE
, mode
),
2902 operand_subword (src
, reverse
, TRUE
, mode
)));
2904 emit_insn (gen_rtx_SET (operand_subword (dest
, !reverse
, TRUE
, mode
),
2905 operand_subword (src
, !reverse
, TRUE
, mode
)));
2907 /* Constant-to-reg copy. */
2908 else if (CONST_INT_P (src
) || GET_CODE (src
) == CONST_DOUBLE
)
2911 split_double (src
, &words
[0], &words
[1]);
2912 emit_insn (gen_rtx_SET (operand_subword (dest
, 0, TRUE
, mode
),
2915 emit_insn (gen_rtx_SET (operand_subword (dest
, 1, TRUE
, mode
),
2918 /* Mem-to-reg copy. */
2919 else if (MEM_P (src
))
2921 /* If the high-address word is used in the address, we must load it
2922 last. Otherwise, load it first. */
2923 rtx addr
= XEXP (src
, 0);
2924 int reverse
= (refers_to_regno_p (dregno
, addr
) != 0);
2926 /* The original code implies that we can't do
2927 move.x [rN+],rM move.x [rN],rM+1
2928 when rN is dead, because of REG_NOTES damage. That is
2929 consistent with what I've seen, so don't try it.
2931 We have two different cases here; if the addr is POST_INC,
2932 just pass it through, otherwise add constants. */
2934 if (GET_CODE (addr
) == POST_INC
)
2939 /* Whenever we emit insns with post-incremented
2940 addresses ourselves, we must add a post-inc note
2942 mem
= change_address (src
, SImode
, addr
);
2944 = gen_rtx_SET (operand_subword (dest
, 0, TRUE
, mode
), mem
);
2945 insn
= emit_insn (insn
);
2946 if (GET_CODE (XEXP (mem
, 0)) == POST_INC
)
2948 = alloc_EXPR_LIST (REG_INC
, XEXP (XEXP (mem
, 0), 0),
2951 mem
= copy_rtx (mem
);
2953 = gen_rtx_SET (operand_subword (dest
, 1, TRUE
, mode
), mem
);
2954 insn
= emit_insn (insn
);
2955 if (GET_CODE (XEXP (mem
, 0)) == POST_INC
)
2957 = alloc_EXPR_LIST (REG_INC
, XEXP (XEXP (mem
, 0), 0),
2962 /* Make sure we don't get any other addresses with
2963 embedded postincrements. They should be stopped in
2964 GO_IF_LEGITIMATE_ADDRESS, but we're here for your
2966 if (side_effects_p (addr
))
2967 fatal_insn ("unexpected side-effects in address", addr
);
2969 emit_insn (gen_rtx_SET
2970 (operand_subword (dest
, reverse
, TRUE
, mode
),
2973 plus_constant (Pmode
, addr
,
2974 reverse
* UNITS_PER_WORD
))));
2975 emit_insn (gen_rtx_SET
2976 (operand_subword (dest
, ! reverse
, TRUE
, mode
),
2979 plus_constant (Pmode
, addr
,
2985 internal_error ("unknown src");
2987 /* Reg-to-mem copy or clear mem. */
2988 else if (MEM_P (dest
)
2990 || src
== const0_rtx
2991 || src
== CONST0_RTX (DFmode
)))
2993 rtx addr
= XEXP (dest
, 0);
2995 if (GET_CODE (addr
) == POST_INC
)
3000 /* Whenever we emit insns with post-incremented addresses
3001 ourselves, we must add a post-inc note manually. */
3002 mem
= change_address (dest
, SImode
, addr
);
3004 = gen_rtx_SET (mem
, operand_subword (src
, 0, TRUE
, mode
));
3005 insn
= emit_insn (insn
);
3006 if (GET_CODE (XEXP (mem
, 0)) == POST_INC
)
3008 = alloc_EXPR_LIST (REG_INC
, XEXP (XEXP (mem
, 0), 0),
3011 mem
= copy_rtx (mem
);
3012 insn
= gen_rtx_SET (mem
, operand_subword (src
, 1, TRUE
, mode
));
3013 insn
= emit_insn (insn
);
3014 if (GET_CODE (XEXP (mem
, 0)) == POST_INC
)
3016 = alloc_EXPR_LIST (REG_INC
, XEXP (XEXP (mem
, 0), 0),
3021 /* Make sure we don't get any other addresses with embedded
3022 postincrements. They should be stopped in
3023 GO_IF_LEGITIMATE_ADDRESS, but we're here for your safety. */
3024 if (side_effects_p (addr
))
3025 fatal_insn ("unexpected side-effects in address", addr
);
3027 emit_insn (gen_rtx_SET
3028 (change_address (dest
, SImode
, addr
),
3029 operand_subword (src
, 0, TRUE
, mode
)));
3031 emit_insn (gen_rtx_SET
3032 (change_address (dest
, SImode
,
3033 plus_constant (Pmode
, addr
,
3035 operand_subword (src
, 1, TRUE
, mode
)));
3040 internal_error ("unknown dest");
3047 /* The expander for the prologue pattern name. */
3050 cris_expand_prologue (void)
3053 int size
= get_frame_size ();
3054 /* Shorten the used name for readability. */
3055 int cfoa_size
= crtl
->outgoing_args_size
;
3056 int last_movem_reg
= -1;
3059 int return_address_on_stack
= cris_return_address_on_stack ();
3060 int got_really_used
= false;
3061 int n_movem_regs
= 0;
3062 int pretend
= crtl
->args
.pretend_args_size
;
3064 /* Don't do anything if no prologues or epilogues are wanted. */
3065 if (!TARGET_PROLOGUE_EPILOGUE
)
3068 CRIS_ASSERT (size
>= 0);
3070 if (crtl
->uses_pic_offset_table
)
3072 /* A reference may have been optimized out (like the abort () in
3073 fde_split in unwind-dw2-fde.c, at least 3.2.1) so check that
3075 push_topmost_sequence ();
3077 = reg_used_between_p (pic_offset_table_rtx
, get_insns (), NULL
);
3078 pop_topmost_sequence ();
3081 /* Align the size to what's best for the CPU model. */
3082 if (TARGET_STACK_ALIGN
)
3083 size
= TARGET_ALIGN_BY_32
? (size
+ 3) & ~3 : (size
+ 1) & ~1;
3087 /* See also cris_setup_incoming_varargs where
3088 cfun->machine->stdarg_regs is set. There are other setters of
3089 crtl->args.pretend_args_size than stdarg handling, like
3090 for an argument passed with parts in R13 and stack. We must
3091 not store R13 into the pretend-area for that case, as GCC does
3092 that itself. "Our" store would be marked as redundant and GCC
3093 will attempt to remove it, which will then be flagged as an
3094 internal error; trying to remove a frame-related insn. */
3095 int stdarg_regs
= cfun
->machine
->stdarg_regs
;
3097 framesize
+= pretend
;
3099 for (regno
= CRIS_FIRST_ARG_REG
+ CRIS_MAX_ARGS_IN_REGS
- 1;
3101 regno
--, pretend
-= 4, stdarg_regs
--)
3103 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3104 plus_constant (Pmode
,
3107 /* FIXME: When dwarf2 frame output and unless asynchronous
3108 exceptions, make dwarf2 bundle together all stack
3109 adjustments like it does for registers between stack
3111 RTX_FRAME_RELATED_P (insn
) = 1;
3113 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3114 set_mem_alias_set (mem
, get_varargs_alias_set ());
3115 insn
= emit_move_insn (mem
, gen_raw_REG (SImode
, regno
));
3117 /* Note the absence of RTX_FRAME_RELATED_P on the above insn:
3118 the value isn't restored, so we don't want to tell dwarf2
3119 that it's been stored to stack, else EH handling info would
3123 /* For other setters of crtl->args.pretend_args_size, we
3124 just adjust the stack by leaving the remaining size in
3125 "pretend", handled below. */
3128 /* Save SRP if not a leaf function. */
3129 if (return_address_on_stack
)
3131 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3132 plus_constant (Pmode
, stack_pointer_rtx
,
3135 RTX_FRAME_RELATED_P (insn
) = 1;
3137 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3138 set_mem_alias_set (mem
, get_frame_alias_set ());
3139 insn
= emit_move_insn (mem
, gen_raw_REG (SImode
, CRIS_SRP_REGNUM
));
3140 RTX_FRAME_RELATED_P (insn
) = 1;
3144 /* Set up the frame pointer, if needed. */
3145 if (frame_pointer_needed
)
3147 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3148 plus_constant (Pmode
, stack_pointer_rtx
,
3151 RTX_FRAME_RELATED_P (insn
) = 1;
3153 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3154 set_mem_alias_set (mem
, get_frame_alias_set ());
3155 insn
= emit_move_insn (mem
, frame_pointer_rtx
);
3156 RTX_FRAME_RELATED_P (insn
) = 1;
3158 insn
= emit_move_insn (frame_pointer_rtx
, stack_pointer_rtx
);
3159 RTX_FRAME_RELATED_P (insn
) = 1;
3164 /* Between frame-pointer and saved registers lie the area for local
3165 variables. If we get here with "pretended" size remaining, count
3166 it into the general stack size. */
3169 /* Get a contiguous sequence of registers, starting with R0, that need
3171 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
3173 if (cris_reg_saved_in_regsave_area (regno
, got_really_used
))
3177 /* Check if movem may be used for registers so far. */
3178 if (regno
== last_movem_reg
+ 1)
3179 /* Yes, update next expected register. */
3180 last_movem_reg
= regno
;
3183 /* We cannot use movem for all registers. We have to flush
3184 any movem:ed registers we got so far. */
3185 if (last_movem_reg
!= -1)
3188 = (n_movem_regs
== 1) ? 1 : last_movem_reg
+ 1;
3190 /* It is a win to use a side-effect assignment for
3191 64 <= size <= 128. But side-effect on movem was
3192 not usable for CRIS v0..3. Also only do it if
3193 side-effects insns are allowed. */
3194 if ((last_movem_reg
+ 1) * 4 + size
>= 64
3195 && (last_movem_reg
+ 1) * 4 + size
<= 128
3196 && (cris_cpu_version
>= CRIS_CPU_SVINTO
|| n_saved
== 1)
3197 && TARGET_SIDE_EFFECT_PREFIXES
)
3200 = gen_rtx_MEM (SImode
,
3201 plus_constant (Pmode
, stack_pointer_rtx
,
3202 -(n_saved
* 4 + size
)));
3203 set_mem_alias_set (mem
, get_frame_alias_set ());
3205 = cris_emit_movem_store (mem
, GEN_INT (n_saved
),
3206 -(n_saved
* 4 + size
),
3212 = gen_rtx_SET (stack_pointer_rtx
,
3213 plus_constant (Pmode
, stack_pointer_rtx
,
3214 -(n_saved
* 4 + size
)));
3215 insn
= emit_insn (insn
);
3216 RTX_FRAME_RELATED_P (insn
) = 1;
3218 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3219 set_mem_alias_set (mem
, get_frame_alias_set ());
3220 insn
= cris_emit_movem_store (mem
, GEN_INT (n_saved
),
3224 framesize
+= n_saved
* 4 + size
;
3225 last_movem_reg
= -1;
3229 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3230 plus_constant (Pmode
,
3233 RTX_FRAME_RELATED_P (insn
) = 1;
3235 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3236 set_mem_alias_set (mem
, get_frame_alias_set ());
3237 insn
= emit_move_insn (mem
, gen_raw_REG (SImode
, regno
));
3238 RTX_FRAME_RELATED_P (insn
) = 1;
3240 framesize
+= 4 + size
;
3246 /* Check after, if we could movem all registers. This is the normal case. */
3247 if (last_movem_reg
!= -1)
3250 = (n_movem_regs
== 1) ? 1 : last_movem_reg
+ 1;
3252 /* Side-effect on movem was not usable for CRIS v0..3. Also only
3253 do it if side-effects insns are allowed. */
3254 if ((last_movem_reg
+ 1) * 4 + size
>= 64
3255 && (last_movem_reg
+ 1) * 4 + size
<= 128
3256 && (cris_cpu_version
>= CRIS_CPU_SVINTO
|| n_saved
== 1)
3257 && TARGET_SIDE_EFFECT_PREFIXES
)
3260 = gen_rtx_MEM (SImode
,
3261 plus_constant (Pmode
, stack_pointer_rtx
,
3262 -(n_saved
* 4 + size
)));
3263 set_mem_alias_set (mem
, get_frame_alias_set ());
3264 insn
= cris_emit_movem_store (mem
, GEN_INT (n_saved
),
3265 -(n_saved
* 4 + size
), true);
3270 = gen_rtx_SET (stack_pointer_rtx
,
3271 plus_constant (Pmode
, stack_pointer_rtx
,
3272 -(n_saved
* 4 + size
)));
3273 insn
= emit_insn (insn
);
3274 RTX_FRAME_RELATED_P (insn
) = 1;
3276 mem
= gen_rtx_MEM (SImode
, stack_pointer_rtx
);
3277 set_mem_alias_set (mem
, get_frame_alias_set ());
3278 insn
= cris_emit_movem_store (mem
, GEN_INT (n_saved
), 0, true);
3281 framesize
+= n_saved
* 4 + size
;
3282 /* We have to put outgoing argument space after regs. */
3285 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3286 plus_constant (Pmode
,
3289 RTX_FRAME_RELATED_P (insn
) = 1;
3290 framesize
+= cfoa_size
;
3293 else if ((size
+ cfoa_size
) > 0)
3295 insn
= emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3296 plus_constant (Pmode
,
3298 -(cfoa_size
+ size
))));
3299 RTX_FRAME_RELATED_P (insn
) = 1;
3300 framesize
+= size
+ cfoa_size
;
3303 /* Set up the PIC register, if it is used. */
3304 if (got_really_used
)
3307 = gen_rtx_UNSPEC (SImode
, gen_rtvec (1, const0_rtx
), CRIS_UNSPEC_GOT
);
3308 emit_move_insn (pic_offset_table_rtx
, got
);
3310 /* FIXME: This is a cover-up for flow2 messing up; it doesn't
3311 follow exceptional paths and tries to delete the GOT load as
3312 unused, if it isn't used on the non-exceptional paths. Other
3313 ports have similar or other cover-ups, or plain bugs marking
3314 the GOT register load as maybe-dead. To see this, remove the
3315 line below and try libsupc++/vec.cc or a trivial
3316 "static void y (); void x () {try {y ();} catch (...) {}}". */
3317 emit_use (pic_offset_table_rtx
);
3320 if (cris_max_stackframe
&& framesize
> cris_max_stackframe
)
3321 warning (0, "stackframe too big: %d bytes", framesize
);
3324 /* The expander for the epilogue pattern. */
3327 cris_expand_epilogue (void)
3330 int size
= get_frame_size ();
3331 int last_movem_reg
= -1;
3332 int argspace_offset
= crtl
->outgoing_args_size
;
3333 int pretend
= crtl
->args
.pretend_args_size
;
3335 bool return_address_on_stack
= cris_return_address_on_stack ();
3336 /* A reference may have been optimized out
3337 (like the abort () in fde_split in unwind-dw2-fde.c, at least 3.2.1)
3338 so check that it's still used. */
3339 int got_really_used
= false;
3340 int n_movem_regs
= 0;
3342 if (!TARGET_PROLOGUE_EPILOGUE
)
3345 if (crtl
->uses_pic_offset_table
)
3347 /* A reference may have been optimized out (like the abort () in
3348 fde_split in unwind-dw2-fde.c, at least 3.2.1) so check that
3350 push_topmost_sequence ();
3352 = reg_used_between_p (pic_offset_table_rtx
, get_insns (), NULL
);
3353 pop_topmost_sequence ();
3356 /* Align byte count of stack frame. */
3357 if (TARGET_STACK_ALIGN
)
3358 size
= TARGET_ALIGN_BY_32
? (size
+ 3) & ~3 : (size
+ 1) & ~1;
3360 /* Check how many saved regs we can movem. They start at r0 and must
3363 regno
< FIRST_PSEUDO_REGISTER
;
3365 if (cris_reg_saved_in_regsave_area (regno
, got_really_used
))
3369 if (regno
== last_movem_reg
+ 1)
3370 last_movem_reg
= regno
;
3375 /* If there was only one register that really needed to be saved
3376 through movem, don't use movem. */
3377 if (n_movem_regs
== 1)
3378 last_movem_reg
= -1;
3380 /* Now emit "normal" move insns for all regs higher than the movem
3382 for (regno
= FIRST_PSEUDO_REGISTER
- 1;
3383 regno
> last_movem_reg
;
3385 if (cris_reg_saved_in_regsave_area (regno
, got_really_used
))
3389 if (argspace_offset
)
3391 /* There is an area for outgoing parameters located before
3392 the saved registers. We have to adjust for that. */
3393 emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3394 plus_constant (Pmode
, stack_pointer_rtx
,
3396 /* Make sure we only do this once. */
3397 argspace_offset
= 0;
3400 mem
= gen_rtx_MEM (SImode
, gen_rtx_POST_INC (SImode
,
3401 stack_pointer_rtx
));
3402 set_mem_alias_set (mem
, get_frame_alias_set ());
3403 insn
= emit_move_insn (gen_raw_REG (SImode
, regno
), mem
);
3405 /* Whenever we emit insns with post-incremented addresses
3406 ourselves, we must add a post-inc note manually. */
3408 = alloc_EXPR_LIST (REG_INC
, stack_pointer_rtx
, REG_NOTES (insn
));
3411 /* If we have any movem-restore, do it now. */
3412 if (last_movem_reg
!= -1)
3416 if (argspace_offset
)
3418 emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3419 plus_constant (Pmode
, stack_pointer_rtx
,
3421 argspace_offset
= 0;
3424 mem
= gen_rtx_MEM (SImode
,
3425 gen_rtx_POST_INC (SImode
, stack_pointer_rtx
));
3426 set_mem_alias_set (mem
, get_frame_alias_set ());
3428 = emit_insn (cris_gen_movem_load (mem
,
3429 GEN_INT (last_movem_reg
+ 1), 0));
3430 /* Whenever we emit insns with post-incremented addresses
3431 ourselves, we must add a post-inc note manually. */
3432 if (side_effects_p (PATTERN (insn
)))
3434 = alloc_EXPR_LIST (REG_INC
, stack_pointer_rtx
, REG_NOTES (insn
));
3437 /* If we don't clobber all of the allocated stack area (we've already
3438 deallocated saved registers), GCC might want to schedule loads from
3439 the stack to *after* the stack-pointer restore, which introduces an
3440 interrupt race condition. This happened for the initial-value
3441 SRP-restore for g++.dg/eh/registers1.C (noticed by inspection of
3442 other failure for that test). It also happened for the stack slot
3443 for the return value in (one version of)
3444 linux/fs/dcache.c:__d_lookup, at least with "-O2
3445 -fno-omit-frame-pointer". */
3447 /* Restore frame pointer if necessary. */
3448 if (frame_pointer_needed
)
3452 emit_insn (gen_cris_frame_deallocated_barrier ());
3454 emit_move_insn (stack_pointer_rtx
, frame_pointer_rtx
);
3455 mem
= gen_rtx_MEM (SImode
, gen_rtx_POST_INC (SImode
,
3456 stack_pointer_rtx
));
3457 set_mem_alias_set (mem
, get_frame_alias_set ());
3458 insn
= emit_move_insn (frame_pointer_rtx
, mem
);
3460 /* Whenever we emit insns with post-incremented addresses
3461 ourselves, we must add a post-inc note manually. */
3463 = alloc_EXPR_LIST (REG_INC
, stack_pointer_rtx
, REG_NOTES (insn
));
3465 else if ((size
+ argspace_offset
) != 0)
3467 emit_insn (gen_cris_frame_deallocated_barrier ());
3469 /* If there was no frame-pointer to restore sp from, we must
3470 explicitly deallocate local variables. */
3472 /* Handle space for outgoing parameters that hasn't been handled
3474 size
+= argspace_offset
;
3476 emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3477 plus_constant (Pmode
, stack_pointer_rtx
, size
)));
3480 /* If this function has no pushed register parameters
3481 (stdargs/varargs), and if it is not a leaf function, then we have
3482 the return address on the stack. */
3483 if (return_address_on_stack
&& pretend
== 0)
3485 if (TARGET_V32
|| crtl
->calls_eh_return
)
3489 rtx srpreg
= gen_raw_REG (SImode
, CRIS_SRP_REGNUM
);
3490 mem
= gen_rtx_MEM (SImode
,
3491 gen_rtx_POST_INC (SImode
,
3492 stack_pointer_rtx
));
3493 set_mem_alias_set (mem
, get_frame_alias_set ());
3494 insn
= emit_move_insn (srpreg
, mem
);
3496 /* Whenever we emit insns with post-incremented addresses
3497 ourselves, we must add a post-inc note manually. */
3499 = alloc_EXPR_LIST (REG_INC
, stack_pointer_rtx
, REG_NOTES (insn
));
3501 if (crtl
->calls_eh_return
)
3502 emit_insn (gen_addsi3 (stack_pointer_rtx
,
3504 gen_raw_REG (SImode
, CRIS_STACKADJ_REG
)));
3505 cris_expand_return (false);
3508 cris_expand_return (true);
3513 /* If we pushed some register parameters, then adjust the stack for
3517 /* If SRP is stored on the way, we need to restore it first. */
3518 if (return_address_on_stack
)
3521 rtx srpreg
= gen_raw_REG (SImode
, CRIS_SRP_REGNUM
);
3524 mem
= gen_rtx_MEM (SImode
,
3525 gen_rtx_POST_INC (SImode
,
3526 stack_pointer_rtx
));
3527 set_mem_alias_set (mem
, get_frame_alias_set ());
3528 insn
= emit_move_insn (srpreg
, mem
);
3530 /* Whenever we emit insns with post-incremented addresses
3531 ourselves, we must add a post-inc note manually. */
3533 = alloc_EXPR_LIST (REG_INC
, stack_pointer_rtx
, REG_NOTES (insn
));
3536 emit_insn (gen_rtx_SET (stack_pointer_rtx
,
3537 plus_constant (Pmode
, stack_pointer_rtx
,
3541 /* Perform the "physical" unwinding that the EH machinery calculated. */
3542 if (crtl
->calls_eh_return
)
3543 emit_insn (gen_addsi3 (stack_pointer_rtx
,
3545 gen_raw_REG (SImode
, CRIS_STACKADJ_REG
)));
3546 cris_expand_return (false);
3549 /* Worker function for generating movem from mem for load_multiple. */
3552 cris_gen_movem_load (rtx src
, rtx nregs_rtx
, int nprefix
)
3554 int nregs
= INTVAL (nregs_rtx
);
3558 rtx srcreg
= XEXP (src
, 0);
3559 unsigned int regno
= nregs
- 1;
3568 if (GET_CODE (srcreg
) == POST_INC
)
3569 srcreg
= XEXP (srcreg
, 0);
3571 CRIS_ASSERT (REG_P (srcreg
));
3573 /* Don't use movem for just one insn. The insns are equivalent except
3574 for the pipeline hazard (on v32); movem does not forward the loaded
3575 registers so there's a three cycles penalty for their use. */
3577 return gen_movsi (gen_rtx_REG (SImode
, 0), src
);
3579 vec
= rtvec_alloc (nprefix
+ nregs
3580 + (GET_CODE (XEXP (src
, 0)) == POST_INC
));
3582 if (GET_CODE (XEXP (src
, 0)) == POST_INC
)
3584 RTVEC_ELT (vec
, nprefix
+ 1)
3585 = gen_rtx_SET (srcreg
, plus_constant (Pmode
, srcreg
, nregs
* 4));
3589 src
= replace_equiv_address (src
, srcreg
);
3590 RTVEC_ELT (vec
, nprefix
)
3591 = gen_rtx_SET (gen_rtx_REG (SImode
, regno
), src
);
3594 for (i
= 1; i
< nregs
; i
++, eltno
++)
3596 RTVEC_ELT (vec
, nprefix
+ eltno
)
3597 = gen_rtx_SET (gen_rtx_REG (SImode
, regno
),
3598 adjust_address_nv (src
, SImode
, i
* 4));
3602 return gen_rtx_PARALLEL (VOIDmode
, vec
);
3605 /* Worker function for generating movem to mem. If FRAME_RELATED, notes
3606 are added that the dwarf2 machinery understands. */
3609 cris_emit_movem_store (rtx dest
, rtx nregs_rtx
, int increment
,
3612 int nregs
= INTVAL (nregs_rtx
);
3617 rtx destreg
= XEXP (dest
, 0);
3618 unsigned int regno
= nregs
- 1;
3627 if (GET_CODE (destreg
) == POST_INC
)
3628 increment
+= nregs
* 4;
3630 if (GET_CODE (destreg
) == POST_INC
|| GET_CODE (destreg
) == PLUS
)
3631 destreg
= XEXP (destreg
, 0);
3633 CRIS_ASSERT (REG_P (destreg
));
3635 /* Don't use movem for just one insn. The insns are equivalent except
3636 for the pipeline hazard (on v32); movem does not forward the loaded
3637 registers so there's a three cycles penalty for use. */
3640 rtx mov
= gen_rtx_SET (dest
, gen_rtx_REG (SImode
, 0));
3644 insn
= emit_insn (mov
);
3646 RTX_FRAME_RELATED_P (insn
) = 1;
3650 /* If there was a request for a side-effect, create the ordinary
3652 vec
= rtvec_alloc (2);
3654 RTVEC_ELT (vec
, 0) = mov
;
3655 RTVEC_ELT (vec
, 1) = gen_rtx_SET (destreg
, plus_constant (Pmode
, destreg
,
3659 RTX_FRAME_RELATED_P (mov
) = 1;
3660 RTX_FRAME_RELATED_P (RTVEC_ELT (vec
, 1)) = 1;
3665 vec
= rtvec_alloc (nregs
+ (increment
!= 0 ? 1 : 0));
3667 = gen_rtx_SET (replace_equiv_address (dest
,
3668 plus_constant (Pmode
, destreg
,
3670 gen_rtx_REG (SImode
, regno
));
3673 /* The dwarf2 info wants this mark on each component in a parallel
3674 that's part of the prologue (though it's optional on the first
3677 RTX_FRAME_RELATED_P (RTVEC_ELT (vec
, 0)) = 1;
3682 = gen_rtx_SET (destreg
, plus_constant (Pmode
, destreg
,
3684 ? increment
: nregs
* 4));
3688 RTX_FRAME_RELATED_P (RTVEC_ELT (vec
, 1)) = 1;
3690 /* Don't call adjust_address_nv on a post-incremented address if
3692 if (GET_CODE (XEXP (dest
, 0)) == POST_INC
)
3693 dest
= replace_equiv_address (dest
, destreg
);
3696 for (i
= 1; i
< nregs
; i
++, eltno
++)
3698 RTVEC_ELT (vec
, eltno
)
3699 = gen_rtx_SET (adjust_address_nv (dest
, SImode
, i
* 4),
3700 gen_rtx_REG (SImode
, regno
));
3702 RTX_FRAME_RELATED_P (RTVEC_ELT (vec
, eltno
)) = 1;
3707 insn
= emit_insn (gen_rtx_PARALLEL (VOIDmode
, vec
));
3709 /* Because dwarf2out.c handles the insns in a parallel as a sequence,
3710 we need to keep the stack adjustment separate, after the
3711 MEM-setters. Else the stack-adjustment in the second component of
3712 the parallel would be mishandled; the offsets for the SETs that
3713 follow it would be wrong. We prepare for this by adding a
3714 REG_FRAME_RELATED_EXPR with the MEM-setting parts in a SEQUENCE
3715 followed by the increment. Note that we have FRAME_RELATED_P on
3716 all the SETs, including the original stack adjustment SET in the
3722 rtx seq
= gen_rtx_SEQUENCE (VOIDmode
, rtvec_alloc (nregs
+ 1));
3723 XVECEXP (seq
, 0, 0) = copy_rtx (XVECEXP (PATTERN (insn
), 0, 0));
3724 for (i
= 1; i
< nregs
; i
++)
3726 = copy_rtx (XVECEXP (PATTERN (insn
), 0, i
+ 1));
3727 XVECEXP (seq
, 0, nregs
) = copy_rtx (XVECEXP (PATTERN (insn
), 0, 1));
3728 add_reg_note (insn
, REG_FRAME_RELATED_EXPR
, seq
);
3731 RTX_FRAME_RELATED_P (insn
) = 1;
3737 /* Worker function for expanding the address for PIC function calls. */
3740 cris_expand_pic_call_address (rtx
*opp
, rtx
*markerp
)
3744 gcc_assert (flag_pic
&& MEM_P (op
));
3747 /* It might be that code can be generated that jumps to 0 (or to a
3748 specific address). Don't die on that. (There is a
3750 if (CONSTANT_P (op
) && !CONST_INT_P (op
))
3752 enum cris_symbol_type t
= cris_symbol_type_of (op
);
3754 CRIS_ASSERT (can_create_pseudo_p ());
3756 /* For local symbols (non-PLT), just get the plain symbol
3757 reference into a register. For symbols that can be PLT, make
3759 if (t
== cris_rel_symbol
)
3761 /* For v32, we're fine as-is; just PICify the symbol. Forcing
3762 into a register caused performance regression for 3.2.1,
3763 observable in __floatdidf and elsewhere in libgcc. */
3766 rtx sym
= GET_CODE (op
) != CONST
? op
: get_related_value (op
);
3767 HOST_WIDE_INT offs
= get_integer_term (op
);
3769 /* We can't get calls to sym+N, N integer, can we? */
3770 gcc_assert (offs
== 0);
3772 op
= gen_rtx_CONST (Pmode
,
3773 gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, sym
),
3774 CRIS_UNSPEC_PCREL
));
3777 op
= force_reg (Pmode
, op
);
3780 *markerp
= const0_rtx
;
3782 else if (t
== cris_got_symbol
)
3784 if (TARGET_AVOID_GOTPLT
)
3786 /* Change a "jsr sym" into (allocate register rM, rO)
3787 "move.d (const (unspec [sym] CRIS_UNSPEC_PLT_GOTREL)),rM"
3788 "add.d rPIC,rM,rO", "jsr rO" for pre-v32 and
3789 "jsr (const (unspec [sym] CRIS_UNSPEC_PLT_PCREL))"
3793 crtl
->uses_pic_offset_table
= 1;
3794 tem
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, op
),
3796 ? CRIS_UNSPEC_PLT_PCREL
3797 : CRIS_UNSPEC_PLT_GOTREL
);
3798 tem
= gen_rtx_CONST (Pmode
, tem
);
3803 rm
= gen_reg_rtx (Pmode
);
3804 emit_move_insn (rm
, tem
);
3805 ro
= gen_reg_rtx (Pmode
);
3806 if (expand_binop (Pmode
, add_optab
, rm
,
3807 pic_offset_table_rtx
,
3808 ro
, 0, OPTAB_LIB_WIDEN
) != ro
)
3809 internal_error ("expand_binop failed in movsi got");
3815 /* Change a "jsr sym" into (allocate register rM, rO)
3816 "move.d (const (unspec [sym] CRIS_UNSPEC_PLTGOTREAD)),rM"
3817 "add.d rPIC,rM,rO" "jsr [rO]" with the memory access
3818 marked as not trapping and not aliasing. No "move.d
3819 [rO],rP" as that would invite to re-use of a value
3820 that should not be reused. FIXME: Need a peephole2
3821 for cases when this is cse:d from the call, to change
3822 back to just get the PLT entry address, so we don't
3823 resolve the same symbol over and over (the memory
3824 access of the PLTGOT isn't constant). */
3825 rtx tem
, mem
, rm
, ro
;
3827 gcc_assert (can_create_pseudo_p ());
3828 crtl
->uses_pic_offset_table
= 1;
3829 tem
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, op
),
3830 CRIS_UNSPEC_PLTGOTREAD
);
3831 rm
= gen_reg_rtx (Pmode
);
3832 emit_move_insn (rm
, gen_rtx_CONST (Pmode
, tem
));
3833 ro
= gen_reg_rtx (Pmode
);
3834 if (expand_binop (Pmode
, add_optab
, rm
,
3835 pic_offset_table_rtx
,
3836 ro
, 0, OPTAB_LIB_WIDEN
) != ro
)
3837 internal_error ("expand_binop failed in movsi got");
3838 mem
= gen_rtx_MEM (Pmode
, ro
);
3840 /* This MEM doesn't alias anything. Whether it aliases
3841 other same symbols is unimportant. */
3842 set_mem_alias_set (mem
, new_alias_set ());
3843 MEM_NOTRAP_P (mem
) = 1;
3847 /* We need to prepare this call to go through the PLT; we
3848 need to make GOT available. */
3849 *markerp
= pic_offset_table_rtx
;
3852 /* Can't possibly get anything else for a function-call, right? */
3853 fatal_insn ("unidentifiable call op", op
);
3855 /* If the validizing variant is called, it will try to validize
3856 the address as a valid any-operand constant, but as it's only
3857 valid for calls and moves, it will fail and always be forced
3859 *opp
= replace_equiv_address_nv (*opp
, op
);
3862 /* Can't tell what locality a call to a non-constant address has;
3863 better make the GOT register alive at it.
3864 FIXME: Can we see whether the register has known constant
3866 *markerp
= pic_offset_table_rtx
;
3869 /* Make sure operands are in the right order for an addsi3 insn as
3870 generated by a define_split. Nothing but REG_P as the first
3871 operand is recognized by addsi3 after reload. OPERANDS contains
3872 the operands, with the first at OPERANDS[N] and the second at
3876 cris_order_for_addsi3 (rtx
*operands
, int n
)
3878 if (!REG_P (operands
[n
]))
3880 rtx tem
= operands
[n
];
3881 operands
[n
] = operands
[n
+ 1];
3882 operands
[n
+ 1] = tem
;
3886 /* Use from within code, from e.g. PRINT_OPERAND and
3887 PRINT_OPERAND_ADDRESS. Macros used in output_addr_const need to emit
3888 different things depending on whether code operand or constant is
3892 cris_output_addr_const (FILE *file
, rtx x
)
3895 output_addr_const (file
, x
);
3899 /* Worker function for ASM_OUTPUT_SYMBOL_REF. */
3902 cris_asm_output_symbol_ref (FILE *file
, rtx x
)
3904 gcc_assert (GET_CODE (x
) == SYMBOL_REF
);
3906 if (flag_pic
&& in_code
> 0)
3908 const char *origstr
= XSTR (x
, 0);
3910 str
= (* targetm
.strip_name_encoding
) (origstr
);
3911 assemble_name (file
, str
);
3914 if (!TARGET_V32
&& !crtl
->uses_pic_offset_table
)
3915 output_operand_lossage ("PIC register isn't set up");
3918 assemble_name (file
, XSTR (x
, 0));
3921 /* Worker function for ASM_OUTPUT_LABEL_REF. */
3924 cris_asm_output_label_ref (FILE *file
, char *buf
)
3926 if (flag_pic
&& in_code
> 0)
3928 assemble_name (file
, buf
);
3931 if (!TARGET_V32
&& !crtl
->uses_pic_offset_table
)
3932 internal_error ("emitting PIC operand, but PIC register "
3936 assemble_name (file
, buf
);
3939 /* Worker function for TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */
3942 cris_output_addr_const_extra (FILE *file
, rtx xconst
)
3944 switch (GET_CODE (xconst
))
3949 x
= XVECEXP (xconst
, 0, 0);
3950 CRIS_ASSERT (GET_CODE (x
) == SYMBOL_REF
3951 || GET_CODE (x
) == LABEL_REF
3952 || GET_CODE (x
) == CONST
);
3953 output_addr_const (file
, x
);
3954 switch (XINT (xconst
, 1))
3956 case CRIS_UNSPEC_PCREL
:
3957 /* We only get this with -fpic/PIC to tell it apart from an
3958 invalid symbol. We can't tell here, but it should only
3959 be the operand of a call or movsi. */
3960 gcc_assert (TARGET_V32
&& flag_pic
);
3963 case CRIS_UNSPEC_PLT_PCREL
:
3964 gcc_assert (TARGET_V32
);
3965 fprintf (file
, ":PLT");
3968 case CRIS_UNSPEC_PLT_GOTREL
:
3969 gcc_assert (!TARGET_V32
);
3970 fprintf (file
, ":PLTG");
3973 case CRIS_UNSPEC_GOTREL
:
3974 gcc_assert (!TARGET_V32
);
3975 fprintf (file
, ":GOTOFF");
3978 case CRIS_UNSPEC_GOTREAD
:
3980 fprintf (file
, ":GOT16");
3982 fprintf (file
, ":GOT");
3985 case CRIS_UNSPEC_PLTGOTREAD
:
3987 fprintf (file
, CRIS_GOTPLT_SUFFIX
"16");
3989 fprintf (file
, CRIS_GOTPLT_SUFFIX
);
4002 /* Worker function for TARGET_STRUCT_VALUE_RTX. */
4005 cris_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED
,
4006 int incoming ATTRIBUTE_UNUSED
)
4008 return gen_rtx_REG (Pmode
, CRIS_STRUCT_VALUE_REGNUM
);
4011 /* Worker function for TARGET_SETUP_INCOMING_VARARGS. */
4014 cris_setup_incoming_varargs (cumulative_args_t ca_v
,
4015 machine_mode mode ATTRIBUTE_UNUSED
,
4016 tree type ATTRIBUTE_UNUSED
,
4017 int *pretend_arg_size
,
4020 CUMULATIVE_ARGS
*ca
= get_cumulative_args (ca_v
);
4022 if (ca
->regs
< CRIS_MAX_ARGS_IN_REGS
)
4024 int stdarg_regs
= CRIS_MAX_ARGS_IN_REGS
- ca
->regs
;
4025 cfun
->machine
->stdarg_regs
= stdarg_regs
;
4026 *pretend_arg_size
= stdarg_regs
* 4;
4030 fprintf (asm_out_file
,
4031 "\n; VA:: ANSI: %d args before, anon @ #%d, %dtime\n",
4032 ca
->regs
, *pretend_arg_size
, second_time
);
4035 /* Return true if TYPE must be passed by invisible reference.
4036 For cris, we pass <= 8 bytes by value, others by reference. */
4039 cris_pass_by_reference (cumulative_args_t ca ATTRIBUTE_UNUSED
,
4040 machine_mode mode
, const_tree type
,
4041 bool named ATTRIBUTE_UNUSED
)
4043 return (targetm
.calls
.must_pass_in_stack (mode
, type
)
4044 || CRIS_FUNCTION_ARG_SIZE (mode
, type
) > 8);
4047 /* A combination of defining TARGET_PROMOTE_FUNCTION_MODE, promoting arguments
4048 and *not* defining TARGET_PROMOTE_PROTOTYPES or PROMOTE_MODE gives the
4049 best code size and speed for gcc, ipps and products in gcc-2.7.2. */
4052 cris_promote_function_mode (const_tree type ATTRIBUTE_UNUSED
,
4054 int *punsignedp ATTRIBUTE_UNUSED
,
4055 const_tree fntype ATTRIBUTE_UNUSED
,
4058 /* Defining PROMOTE_FUNCTION_RETURN in gcc-2.7.2 uncovered bug 981110 (even
4059 when modifying TARGET_FUNCTION_VALUE to return the promoted mode).
4060 Maybe pointless as of now, but let's keep the old behavior. */
4061 if (for_return
== 1)
4063 return CRIS_PROMOTED_MODE (mode
, *punsignedp
, type
);
4066 /* Atomic types require alignment to be at least their "natural" size. */
4069 cris_atomic_align_for_mode (machine_mode mode
)
4071 return GET_MODE_BITSIZE (mode
);
4074 /* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
4078 cris_function_value(const_tree type
,
4079 const_tree func ATTRIBUTE_UNUSED
,
4080 bool outgoing ATTRIBUTE_UNUSED
)
4082 return gen_rtx_REG (TYPE_MODE (type
), CRIS_FIRST_ARG_REG
);
4085 /* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
4089 cris_libcall_value (machine_mode mode
,
4090 const_rtx fun ATTRIBUTE_UNUSED
)
4092 return gen_rtx_REG (mode
, CRIS_FIRST_ARG_REG
);
4095 /* Let's assume all functions return in r[CRIS_FIRST_ARG_REG] for the
4099 cris_function_value_regno_p (const unsigned int regno
)
4101 return (regno
== CRIS_FIRST_ARG_REG
);
4105 cris_arg_partial_bytes (cumulative_args_t ca
, machine_mode mode
,
4106 tree type
, bool named ATTRIBUTE_UNUSED
)
4108 if (get_cumulative_args (ca
)->regs
== CRIS_MAX_ARGS_IN_REGS
- 1
4109 && !targetm
.calls
.must_pass_in_stack (mode
, type
)
4110 && CRIS_FUNCTION_ARG_SIZE (mode
, type
) > 4
4111 && CRIS_FUNCTION_ARG_SIZE (mode
, type
) <= 8)
4112 return UNITS_PER_WORD
;
4118 cris_function_arg_1 (cumulative_args_t ca_v
,
4119 machine_mode mode ATTRIBUTE_UNUSED
,
4120 const_tree type ATTRIBUTE_UNUSED
,
4121 bool named
, bool incoming
)
4123 const CUMULATIVE_ARGS
*ca
= get_cumulative_args (ca_v
);
4125 if ((!incoming
|| named
) && ca
->regs
< CRIS_MAX_ARGS_IN_REGS
)
4126 return gen_rtx_REG (mode
, CRIS_FIRST_ARG_REG
+ ca
->regs
);
4131 /* Worker function for TARGET_FUNCTION_ARG.
4132 The void_type_node is sent as a "closing" call. */
4135 cris_function_arg (cumulative_args_t ca
, machine_mode mode
,
4136 const_tree type
, bool named
)
4138 return cris_function_arg_1 (ca
, mode
, type
, named
, false);
4141 /* Worker function for TARGET_FUNCTION_INCOMING_ARG.
4143 The differences between this and the previous, is that this one checks
4144 that an argument is named, since incoming stdarg/varargs arguments are
4145 pushed onto the stack, and we don't have to check against the "closing"
4146 void_type_node TYPE parameter. */
4149 cris_function_incoming_arg (cumulative_args_t ca
, machine_mode mode
,
4150 const_tree type
, bool named
)
4152 return cris_function_arg_1 (ca
, mode
, type
, named
, true);
4155 /* Worker function for TARGET_FUNCTION_ARG_ADVANCE. */
4158 cris_function_arg_advance (cumulative_args_t ca_v
, machine_mode mode
,
4159 const_tree type
, bool named ATTRIBUTE_UNUSED
)
4161 CUMULATIVE_ARGS
*ca
= get_cumulative_args (ca_v
);
4163 ca
->regs
+= (3 + CRIS_FUNCTION_ARG_SIZE (mode
, type
)) / 4;
4166 /* Worker function for TARGET_MD_ASM_ADJUST. */
4169 cris_md_asm_adjust (vec
<rtx
> &outputs
, vec
<rtx
> &inputs
,
4170 vec
<const char *> &constraints
,
4171 vec
<rtx
> &clobbers
, HARD_REG_SET
&clobbered_regs
)
4173 /* For the time being, all asms clobber condition codes.
4174 Revisit when there's a reasonable use for inputs/outputs
4175 that mention condition codes. */
4176 clobbers
.safe_push (gen_rtx_REG (CCmode
, CRIS_CC0_REGNUM
));
4177 SET_HARD_REG_BIT (clobbered_regs
, CRIS_CC0_REGNUM
);
4179 /* Determine if the source using MOF. If it is, automatically
4180 clobbering MOF would cause it to have impossible constraints. */
4182 /* Look for a use of the MOF constraint letter: h. */
4183 for (unsigned i
= 0, n
= constraints
.length(); i
< n
; ++i
)
4184 if (strchr (constraints
[i
], 'h') != NULL
)
4187 /* Look for an output or an input that touches MOF. */
4188 rtx mof_reg
= gen_rtx_REG (SImode
, CRIS_MOF_REGNUM
);
4189 for (unsigned i
= 0, n
= outputs
.length(); i
< n
; ++i
)
4190 if (reg_overlap_mentioned_p (mof_reg
, outputs
[i
]))
4192 for (unsigned i
= 0, n
= inputs
.length(); i
< n
; ++i
)
4193 if (reg_overlap_mentioned_p (mof_reg
, inputs
[i
]))
4196 /* No direct reference to MOF or its constraint.
4197 Clobber it for backward compatibility. */
4198 clobbers
.safe_push (mof_reg
);
4199 SET_HARD_REG_BIT (clobbered_regs
, CRIS_MOF_REGNUM
);
4203 /* Implement TARGET_FRAME_POINTER_REQUIRED.
4205 Really only needed if the stack frame has variable length (alloca
4206 or variable sized local arguments (GNU C extension). See PR39499 and
4207 PR38609 for the reason this isn't just 0. */
4210 cris_frame_pointer_required (void)
4212 return !crtl
->sp_is_unchanging
;
4215 /* Implement TARGET_ASM_TRAMPOLINE_TEMPLATE.
4217 This looks too complicated, and it is. I assigned r7 to be the
4218 static chain register, but it is call-saved, so we have to save it,
4219 and come back to restore it after the call, so we have to save srp...
4220 Anyway, trampolines are rare enough that we can cope with this
4221 somewhat lack of elegance.
4222 (Do not be tempted to "straighten up" whitespace in the asms; the
4223 assembler #NO_APP state mandates strict spacing). */
4224 /* ??? See the i386 regparm=3 implementation that pushes the static
4225 chain value to the stack in the trampoline, and uses a call-saved
4226 register when called directly. */
4229 cris_asm_trampoline_template (FILE *f
)
4233 /* This normally-unused nop insn acts as an instruction to
4234 the simulator to flush its instruction cache. None of
4235 the other instructions in the trampoline template suits
4236 as a trigger for V32. The pc-relative addressing mode
4237 works nicely as a trigger for V10.
4238 FIXME: Have specific V32 template (possibly avoiding the
4239 use of a special instruction). */
4240 fprintf (f
, "\tclearf x\n");
4241 /* We have to use a register as an intermediate, choosing
4242 semi-randomly R1 (which has to not be the STATIC_CHAIN_REGNUM),
4243 so we can use it for address indirection and jsr target. */
4244 fprintf (f
, "\tmove $r1,$mof\n");
4246 fprintf (f
, "\tmove.d 0,$r1\n");
4247 fprintf (f
, "\tmove.d $%s,[$r1]\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4248 fprintf (f
, "\taddq 6,$r1\n");
4249 fprintf (f
, "\tmove $mof,[$r1]\n");
4250 fprintf (f
, "\taddq 6,$r1\n");
4251 fprintf (f
, "\tmove $srp,[$r1]\n");
4253 fprintf (f
, "\tmove.d 0,$%s\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4255 fprintf (f
, "\tmove.d 0,$r1\n");
4256 fprintf (f
, "\tjsr $r1\n");
4257 fprintf (f
, "\tsetf\n");
4259 fprintf (f
, "\tmove.d 0,$%s\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4261 fprintf (f
, "\tmove.d 0,$r1\n");
4263 fprintf (f
, "\tmove.d 0,$r9\n");
4264 fprintf (f
, "\tjump $r9\n");
4265 fprintf (f
, "\tsetf\n");
4269 fprintf (f
, "\tmove.d $%s,[$pc+20]\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4270 fprintf (f
, "\tmove $srp,[$pc+22]\n");
4271 fprintf (f
, "\tmove.d 0,$%s\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4272 fprintf (f
, "\tjsr 0\n");
4273 fprintf (f
, "\tmove.d 0,$%s\n", reg_names
[STATIC_CHAIN_REGNUM
]);
4274 fprintf (f
, "\tjump 0\n");
4278 /* Implement TARGET_TRAMPOLINE_INIT. */
4281 cris_trampoline_init (rtx m_tramp
, tree fndecl
, rtx chain_value
)
4283 rtx fnaddr
= XEXP (DECL_RTL (fndecl
), 0);
4284 rtx tramp
= XEXP (m_tramp
, 0);
4287 emit_block_move (m_tramp
, assemble_trampoline_template (),
4288 GEN_INT (TRAMPOLINE_SIZE
), BLOCK_OP_NORMAL
);
4292 mem
= adjust_address (m_tramp
, SImode
, 6);
4293 emit_move_insn (mem
, plus_constant (Pmode
, tramp
, 38));
4294 mem
= adjust_address (m_tramp
, SImode
, 22);
4295 emit_move_insn (mem
, chain_value
);
4296 mem
= adjust_address (m_tramp
, SImode
, 28);
4297 emit_move_insn (mem
, fnaddr
);
4301 mem
= adjust_address (m_tramp
, SImode
, 10);
4302 emit_move_insn (mem
, chain_value
);
4303 mem
= adjust_address (m_tramp
, SImode
, 16);
4304 emit_move_insn (mem
, fnaddr
);
4307 /* Note that there is no need to do anything with the cache for
4308 sake of a trampoline. */
4311 /* Implement TARGET_HARD_REGNO_NREGS.
4313 The VOIDmode test is so we can omit mode on anonymous insns. FIXME:
4314 Still needed in 2.9x, at least for Axis-20000319. */
4317 cris_hard_regno_nregs (unsigned int, machine_mode mode
)
4319 if (mode
== VOIDmode
)
4321 return CEIL (GET_MODE_SIZE (mode
), UNITS_PER_WORD
);
4324 /* Implement TARGET_HARD_REGNO_MODE_OK.
4326 CRIS permits all registers to hold all modes. Well, except for the
4327 condition-code register. And we can't hold larger-than-register size
4328 modes in the last special register that can hold a full 32 bits. */
4330 cris_hard_regno_mode_ok (unsigned int regno
, machine_mode mode
)
4332 return ((mode
== CCmode
|| regno
!= CRIS_CC0_REGNUM
)
4333 && (GET_MODE_SIZE (mode
) <= UNITS_PER_WORD
4334 || (regno
!= CRIS_MOF_REGNUM
&& regno
!= CRIS_ACR_REGNUM
)));
4337 /* Return the preferred minimum alignment for a static object. */
4339 static HOST_WIDE_INT
4340 cris_preferred_mininum_alignment (void)
4342 if (!TARGET_CONST_ALIGN
)
4344 if (TARGET_ALIGN_BY_32
)
4349 /* Implement TARGET_STATIC_RTX_ALIGNMENT. */
4351 static HOST_WIDE_INT
4352 cris_static_rtx_alignment (machine_mode mode
)
4354 return MAX (cris_preferred_mininum_alignment (), GET_MODE_ALIGNMENT (mode
));
4357 /* Implement TARGET_CONSTANT_ALIGNMENT. Note that this hook has the
4358 effect of making gcc believe that ALL references to constant stuff
4359 (in code segment, like strings) have this alignment. That is a rather
4360 rushed assumption. Luckily we do not care about the "alignment"
4361 operand to builtin memcpy (only place where it counts), so it doesn't
4362 affect any bad spots. */
4364 static HOST_WIDE_INT
4365 cris_constant_alignment (const_tree
, HOST_WIDE_INT basic_align
)
4367 return MAX (cris_preferred_mininum_alignment (), basic_align
);
4371 /* Various small functions to replace macros. Only called from a
4372 debugger. They might collide with gcc functions or system functions,
4373 so only emit them when '#if 1' above. */
4375 enum rtx_code
Get_code (rtx
);
4380 return GET_CODE (x
);
4383 const char *Get_mode (rtx
);
4388 return GET_MODE_NAME (GET_MODE (x
));
4391 rtx
Xexp (rtx
, int);
4399 rtx
Xvecexp (rtx
, int, int);
4402 Xvecexp (rtx x
, int n
, int m
)
4404 return XVECEXP (x
, n
, m
);
4407 int Get_rtx_len (rtx
);
4412 return GET_RTX_LENGTH (GET_CODE (x
));
4415 /* Use upper-case to distinguish from local variables that are sometimes
4416 called next_insn and prev_insn. */
4418 rtx
Next_insn (rtx
);
4421 Next_insn (rtx insn
)
4423 return NEXT_INSN (insn
);
4426 rtx
Prev_insn (rtx
);
4429 Prev_insn (rtx insn
)
4431 return PREV_INSN (insn
);
4435 #include "gt-cris.h"
4439 * eval: (c-set-style "gnu")
4440 * indent-tabs-mode: t