1 /* Definitions of target machine for Mitsubishi D30V.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
34 #include "insn-attr.h"
43 #include "integrate.h"
46 #include "target-def.h"
47 #include "langhooks.h"
49 static void d30v_print_operand_memory_reference
PARAMS ((FILE *, rtx
));
50 static void d30v_build_long_insn
PARAMS ((HOST_WIDE_INT
, HOST_WIDE_INT
,
52 static struct machine_function
* d30v_init_machine_status
PARAMS ((void));
53 static void d30v_output_function_prologue
PARAMS ((FILE *, HOST_WIDE_INT
));
54 static void d30v_output_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
55 static int d30v_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
56 static int d30v_issue_rate
PARAMS ((void));
57 static bool d30v_rtx_costs
PARAMS ((rtx
, int, int, int *));
59 /* Define the information needed to generate branch and scc insns. This is
60 stored from the compare operation. */
62 struct rtx_def
*d30v_compare_op0
;
63 struct rtx_def
*d30v_compare_op1
;
65 /* Cached value of d30v_stack_info */
66 static d30v_stack_t
*d30v_stack_cache
= (d30v_stack_t
*)0;
68 /* Values of the -mbranch-cost=n string. */
69 int d30v_branch_cost
= D30V_DEFAULT_BRANCH_COST
;
70 const char *d30v_branch_cost_string
= (const char *)0;
72 /* Values of the -mcond-exec=n string. */
73 int d30v_cond_exec
= D30V_DEFAULT_MAX_CONDITIONAL_EXECUTE
;
74 const char *d30v_cond_exec_string
= (const char *)0;
76 /* Whether or not a hard register can accept a register */
77 unsigned char hard_regno_mode_ok
[ (int)MAX_MACHINE_MODE
][FIRST_PSEUDO_REGISTER
];
79 /* Whether to try and avoid moves between two different modes */
80 unsigned char modes_tieable_p
[ (NUM_MACHINE_MODES
) * (NUM_MACHINE_MODES
) ];
82 /* Map register number to smallest register class. */
83 enum reg_class regno_reg_class
[FIRST_PSEUDO_REGISTER
];
85 /* Map class letter into register class */
86 enum reg_class reg_class_from_letter
[256];
88 /* Initialize the GCC target structure. */
89 #undef TARGET_ASM_ALIGNED_HI_OP
90 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
91 #undef TARGET_ASM_ALIGNED_SI_OP
92 #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
94 #undef TARGET_ASM_FUNCTION_PROLOGUE
95 #define TARGET_ASM_FUNCTION_PROLOGUE d30v_output_function_prologue
96 #undef TARGET_ASM_FUNCTION_EPILOGUE
97 #define TARGET_ASM_FUNCTION_EPILOGUE d30v_output_function_epilogue
98 #undef TARGET_SCHED_ADJUST_COST
99 #define TARGET_SCHED_ADJUST_COST d30v_adjust_cost
100 #undef TARGET_SCHED_ISSUE_RATE
101 #define TARGET_SCHED_ISSUE_RATE d30v_issue_rate
103 #undef TARGET_RTX_COSTS
104 #define TARGET_RTX_COSTS d30v_rtx_costs
105 #undef TARGET_ADDRESS_COST
106 #define TARGET_ADDRESS_COST hook_int_rtx_0
108 struct gcc_target targetm
= TARGET_INITIALIZER
;
110 /* Sometimes certain combinations of command options do not make
111 sense on a particular target machine. You can define a macro
112 `OVERRIDE_OPTIONS' to take account of this. This macro, if
113 defined, is executed once just after all the command options have
116 Don't use this macro to turn on various extra optimizations for
117 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
123 enum machine_mode mode1
, mode2
;
125 /* Set up the branch cost information */
126 if (d30v_branch_cost_string
)
127 d30v_branch_cost
= atoi (d30v_branch_cost_string
);
129 /* Set up max # instructions to use with conditional execution */
130 if (d30v_cond_exec_string
)
131 d30v_cond_exec
= atoi (d30v_cond_exec_string
);
133 /* Setup hard_regno_mode_ok/modes_tieable_p */
134 for (mode1
= VOIDmode
;
135 (int)mode1
< NUM_MACHINE_MODES
;
136 mode1
= (enum machine_mode
)((int)mode1
+ 1))
138 int size
= GET_MODE_SIZE (mode1
);
139 int large_p
= size
> UNITS_PER_WORD
;
140 int int_p
= GET_MODE_CLASS (mode1
) == MODE_INT
;
142 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
144 if (mode1
== VOIDmode
)
147 else if (GPR_P (regno
))
152 ok_p
= (((regno
- GPR_FIRST
) & 1) == 0);
155 else if (FLAG_P (regno
))
156 ok_p
= (mode1
== CCmode
);
158 else if (CR_P (regno
))
159 ok_p
= int_p
&& !large_p
;
161 else if (ACCUM_P (regno
))
162 ok_p
= (mode1
== DImode
);
164 else if (SPECIAL_REG_P (regno
))
165 ok_p
= (mode1
== SImode
);
170 hard_regno_mode_ok
[ (int)mode1
][ regno
] = ok_p
;
173 /* A C expression that is nonzero if it is desirable to choose
174 register allocation so as to avoid move instructions between a
175 value of mode MODE1 and a value of mode MODE2.
177 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
178 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
179 MODE2)' must be zero. */
180 for (mode2
= VOIDmode
;
181 (int)mode2
<= NUM_MACHINE_MODES
;
182 mode2
= (enum machine_mode
)((int)mode2
+ 1))
188 else if (GET_MODE_CLASS (mode1
) == MODE_INT
189 && GET_MODE_SIZE (mode1
) <= UNITS_PER_WORD
190 && GET_MODE_CLASS (mode2
) == MODE_INT
191 && GET_MODE_SIZE (mode2
) <= UNITS_PER_WORD
)
198 modes_tieable_p
[ ((int)mode1
* (NUM_MACHINE_MODES
)) + (int)mode2
] = ok_p
;
203 for (mode1
= VOIDmode
;
204 (int)mode1
< NUM_MACHINE_MODES
;
205 mode1
= (enum machine_mode
)((int)mode1
+ 1))
207 for (mode2
= VOIDmode
;
208 (int)mode2
<= NUM_MACHINE_MODES
;
209 mode2
= (enum machine_mode
)((int)mode2
+ 1))
211 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
213 && (hard_regno_mode_ok
[(int)mode1
][regno
]
214 != hard_regno_mode_ok
[(int)mode2
][regno
]))
215 error ("bad modes_tieable_p for register %s, mode1 %s, mode2 %s",
216 reg_names
[regno
], GET_MODE_NAME (mode1
),
217 GET_MODE_NAME (mode2
));
222 /* A C expression whose value is a register class containing hard
223 register REGNO. In general there is more than one such class;
224 choose a class which is "minimal", meaning that no smaller class
225 also contains the register. */
226 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
228 enum reg_class
class;
231 class = (IN_RANGE_P (regno
, GPR_FIRST
+2, GPR_FIRST
+62)
232 && ((regno
- GPR_FIRST
) & 1) == 0) ? EVEN_REGS
: GPR_REGS
;
234 else if (regno
== FLAG_F0
)
237 else if (regno
== FLAG_F1
)
240 else if (FLAG_P (regno
))
241 class = OTHER_FLAG_REGS
;
243 else if (ACCUM_P (regno
))
246 else if (regno
== CR_RPT_C
)
249 else if (CR_P (regno
))
252 else if (SPECIAL_REG_P (regno
))
258 regno_reg_class
[regno
] = class;
262 static const char *const names
[] = REG_CLASS_NAMES
;
263 fprintf (stderr
, "Register %s class is %s, can hold modes", reg_names
[regno
], names
[class]);
264 for (mode1
= VOIDmode
;
265 (int)mode1
< NUM_MACHINE_MODES
;
266 mode1
= (enum machine_mode
)((int)mode1
+ 1))
268 if (hard_regno_mode_ok
[ (int)mode1
][ regno
])
269 fprintf (stderr
, " %s", GET_MODE_NAME (mode1
));
271 fprintf (stderr
, "\n");
276 /* A C expression which defines the machine-dependent operand
277 constraint letters for register classes. If CHAR is such a
278 letter, the value should be the register class corresponding to
279 it. Otherwise, the value should be `NO_REGS'. The register
280 letter `r', corresponding to class `GENERAL_REGS', will not be
281 passed to this macro; you do not need to handle it.
283 The following letters are unavailable, due to being used as
288 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'
289 'Q', 'R', 'S', 'T', 'U'
291 'g', 'i', 'm', 'n', 'o', 'p', 'r', 's' */
293 for (i
= 0; i
< 256; i
++)
294 reg_class_from_letter
[i
] = NO_REGS
;
296 reg_class_from_letter
['a'] = ACCUM_REGS
;
297 reg_class_from_letter
['b'] = BR_FLAG_REGS
;
298 reg_class_from_letter
['c'] = CR_REGS
;
299 reg_class_from_letter
['d'] = GPR_REGS
;
300 reg_class_from_letter
['e'] = EVEN_REGS
;
301 reg_class_from_letter
['f'] = FLAG_REGS
;
302 reg_class_from_letter
['l'] = REPEAT_REGS
;
303 reg_class_from_letter
['x'] = F0_REGS
;
304 reg_class_from_letter
['y'] = F1_REGS
;
305 reg_class_from_letter
['z'] = OTHER_FLAG_REGS
;
309 /* Return true if a memory operand is a short memory operand. */
312 short_memory_operand (op
, mode
)
314 enum machine_mode mode
;
316 if (GET_CODE (op
) != MEM
)
319 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
322 return (d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
)
326 /* Return true if a memory operand is a long operand. */
329 long_memory_operand (op
, mode
)
331 enum machine_mode mode
;
333 if (GET_CODE (op
) != MEM
)
336 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
339 return (d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
)
343 /* Return true if a memory operand is valid for the D30V. */
346 d30v_memory_operand (op
, mode
)
348 enum machine_mode mode
;
350 if (GET_CODE (op
) != MEM
)
353 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
356 return (d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
)
360 /* Return true if a memory operand uses a single register for the
364 single_reg_memory_operand (op
, mode
)
366 enum machine_mode mode
;
370 if (GET_CODE (op
) != MEM
)
373 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
377 if (! d30v_legitimate_address_p (mode
, addr
, reload_completed
))
380 if (GET_CODE (addr
) == SUBREG
)
381 addr
= SUBREG_REG (addr
);
383 return (GET_CODE (addr
) == REG
);
386 /* Return true if a memory operand uses a constant address. */
389 const_addr_memory_operand (op
, mode
)
391 enum machine_mode mode
;
393 if (GET_CODE (op
) != MEM
)
396 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
399 if (! d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
))
402 switch (GET_CODE (XEXP (op
, 0)))
417 /* Return true if operand is a memory reference suitable for a call. */
420 call_operand (op
, mode
)
422 enum machine_mode mode
;
424 if (GET_CODE (op
) != MEM
)
427 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
430 if (! d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
))
433 switch (GET_CODE (XEXP (op
, 0)))
439 op
= SUBREG_REG (op
);
440 if (GET_CODE (op
) != REG
)
446 return (GPR_OR_PSEUDO_P (REGNO (XEXP (op
, 0))));
458 /* Return true if operand is a GPR register. */
461 gpr_operand (op
, mode
)
463 enum machine_mode mode
;
465 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
468 if (GET_CODE (op
) == SUBREG
)
470 if (GET_CODE (SUBREG_REG (op
)) != REG
)
471 return register_operand (op
, mode
);
473 op
= SUBREG_REG (op
);
476 if (GET_CODE (op
) != REG
)
479 return GPR_OR_PSEUDO_P (REGNO (op
));
482 /* Return true if operand is an accumulator register. */
485 accum_operand (op
, mode
)
487 enum machine_mode mode
;
489 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
492 if (GET_CODE (op
) == SUBREG
)
494 if (GET_CODE (SUBREG_REG (op
)) != REG
)
495 return register_operand (op
, mode
);
497 op
= SUBREG_REG (op
);
500 if (GET_CODE (op
) != REG
)
503 return ACCUM_OR_PSEUDO_P (REGNO (op
));
506 /* Return true if operand is a GPR or an accumulator register. */
509 gpr_or_accum_operand (op
, mode
)
511 enum machine_mode mode
;
513 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
516 if (GET_CODE (op
) == SUBREG
)
518 if (GET_CODE (SUBREG_REG (op
)) != REG
)
519 return register_operand (op
, mode
);
521 op
= SUBREG_REG (op
);
524 if (GET_CODE (op
) != REG
)
527 if (ACCUM_P (REGNO (op
)))
530 return GPR_OR_PSEUDO_P (REGNO (op
));
533 /* Return true if operand is a CR register. */
536 cr_operand (op
, mode
)
538 enum machine_mode mode
;
540 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
543 if (GET_CODE (op
) == SUBREG
)
545 if (GET_CODE (SUBREG_REG (op
)) != REG
)
546 return register_operand (op
, mode
);
548 op
= SUBREG_REG (op
);
551 if (GET_CODE (op
) != REG
)
554 return CR_OR_PSEUDO_P (REGNO (op
));
557 /* Return true if operand is the repeat count register. */
560 repeat_operand (op
, mode
)
562 enum machine_mode mode
;
564 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
567 if (GET_CODE (op
) == SUBREG
)
569 if (GET_CODE (SUBREG_REG (op
)) != REG
)
570 return register_operand (op
, mode
);
572 op
= SUBREG_REG (op
);
575 if (GET_CODE (op
) != REG
)
578 return (REGNO (op
) == CR_RPT_C
|| REGNO (op
) >= FIRST_PSEUDO_REGISTER
);
581 /* Return true if operand is a FLAG register. */
584 flag_operand (op
, mode
)
586 enum machine_mode mode
;
588 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
591 if (GET_CODE (op
) == SUBREG
)
593 if (GET_CODE (SUBREG_REG (op
)) != REG
)
594 return register_operand (op
, mode
);
596 op
= SUBREG_REG (op
);
599 if (GET_CODE (op
) != REG
)
602 return FLAG_OR_PSEUDO_P (REGNO (op
));
605 /* Return true if operand is either F0 or F1. */
608 br_flag_operand (op
, mode
)
610 enum machine_mode mode
;
612 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
615 if (GET_CODE (op
) == SUBREG
)
617 if (GET_CODE (SUBREG_REG (op
)) != REG
)
618 return register_operand (op
, mode
);
620 op
= SUBREG_REG (op
);
623 if (GET_CODE (op
) != REG
)
626 return BR_FLAG_OR_PSEUDO_P (REGNO (op
));
629 /* Return true if operand is either F0/F1 or the constants 0/1. */
632 br_flag_or_constant_operand (op
, mode
)
634 enum machine_mode mode
;
636 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
639 if (GET_CODE (op
) == SUBREG
)
641 if (GET_CODE (SUBREG_REG (op
)) != REG
)
642 return register_operand (op
, mode
);
644 op
= SUBREG_REG (op
);
647 if (GET_CODE (op
) == CONST_INT
)
648 return (INTVAL (op
) == 0 || INTVAL (op
) == 1);
650 if (GET_CODE (op
) != REG
)
653 return BR_FLAG_OR_PSEUDO_P (REGNO (op
));
656 /* Return true if operand is either F0 or F1, or a GPR register. */
659 gpr_or_br_flag_operand (op
, mode
)
661 enum machine_mode mode
;
663 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
666 if (GET_CODE (op
) == SUBREG
)
668 if (GET_CODE (SUBREG_REG (op
)) != REG
)
669 return register_operand (op
, mode
);
671 op
= SUBREG_REG (op
);
674 if (GET_CODE (op
) != REG
)
677 return GPR_OR_PSEUDO_P (REGNO (op
)) || BR_FLAG_P (REGNO (op
));
680 /* Return true if operand is the F0 register. */
683 f0_operand (op
, mode
)
685 enum machine_mode mode
;
687 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
690 if (GET_CODE (op
) == SUBREG
)
692 if (GET_CODE (SUBREG_REG (op
)) != REG
)
693 return register_operand (op
, mode
);
695 op
= SUBREG_REG (op
);
698 if (GET_CODE (op
) != REG
)
701 return (REGNO (op
) == FLAG_F0
|| REGNO (op
) >= FIRST_PSEUDO_REGISTER
);
704 /* Return true if operand is the F1 register. */
707 f1_operand (op
, mode
)
709 enum machine_mode mode
;
711 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
714 if (GET_CODE (op
) == SUBREG
)
716 if (GET_CODE (SUBREG_REG (op
)) != REG
)
717 return register_operand (op
, mode
);
719 op
= SUBREG_REG (op
);
722 if (GET_CODE (op
) != REG
)
725 return (REGNO (op
) == FLAG_F1
|| REGNO (op
) >= FIRST_PSEUDO_REGISTER
);
728 /* Return true if operand is the F1 register. */
731 carry_operand (op
, mode
)
733 enum machine_mode mode
;
735 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
738 if (GET_CODE (op
) == SUBREG
)
740 if (GET_CODE (SUBREG_REG (op
)) != REG
)
741 return register_operand (op
, mode
);
743 op
= SUBREG_REG (op
);
746 if (GET_CODE (op
) != REG
)
749 return (REGNO (op
) == FLAG_CARRY
|| REGNO (op
) >= FIRST_PSEUDO_REGISTER
);
752 /* Return true if operand is a register of any flavor or a 0 of the
756 reg_or_0_operand (op
, mode
)
758 enum machine_mode mode
;
760 switch (GET_CODE (op
))
767 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
770 return register_operand (op
, mode
);
773 return INTVAL (op
) == 0;
776 return CONST_DOUBLE_HIGH (op
) == 0 && CONST_DOUBLE_LOW (op
) == 0;
782 /* Return true if operand is a GPR register or a signed 6 bit immediate. */
785 gpr_or_signed6_operand (op
, mode
)
787 enum machine_mode mode
;
789 if (GET_CODE (op
) == SUBREG
)
791 if (GET_CODE (SUBREG_REG (op
)) != REG
)
792 return register_operand (op
, mode
);
794 op
= SUBREG_REG (op
);
797 if (GET_CODE (op
) == CONST_INT
)
798 return IN_RANGE_P (INTVAL (op
), -32, 31);
800 if (GET_CODE (op
) != REG
)
803 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
806 return GPR_OR_PSEUDO_P (REGNO (op
));
809 /* Return true if operand is a GPR register or an unsigned 5 bit immediate. */
812 gpr_or_unsigned5_operand (op
, mode
)
814 enum machine_mode mode
;
816 if (GET_CODE (op
) == SUBREG
)
818 if (GET_CODE (SUBREG_REG (op
)) != REG
)
819 return register_operand (op
, mode
);
821 op
= SUBREG_REG (op
);
824 if (GET_CODE (op
) == CONST_INT
)
825 return IN_RANGE_P (INTVAL (op
), 0, 31);
827 if (GET_CODE (op
) != REG
)
830 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
833 return GPR_OR_PSEUDO_P (REGNO (op
));
836 /* Return true if operand is a GPR register or an unsigned 6 bit immediate. */
839 gpr_or_unsigned6_operand (op
, mode
)
841 enum machine_mode mode
;
843 if (GET_CODE (op
) == SUBREG
)
845 if (GET_CODE (SUBREG_REG (op
)) != REG
)
846 return register_operand (op
, mode
);
848 op
= SUBREG_REG (op
);
851 if (GET_CODE (op
) == CONST_INT
)
852 return IN_RANGE_P (INTVAL (op
), 0, 63);
854 if (GET_CODE (op
) != REG
)
857 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
860 return GPR_OR_PSEUDO_P (REGNO (op
));
863 /* Return true if operand is a GPR register or a constant of some form. */
866 gpr_or_constant_operand (op
, mode
)
868 enum machine_mode mode
;
870 switch (GET_CODE (op
))
882 if (GET_CODE (SUBREG_REG (op
)) != REG
)
883 return register_operand (op
, mode
);
885 op
= SUBREG_REG (op
);
889 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
892 return GPR_OR_PSEUDO_P (REGNO (op
));
898 /* Return true if operand is a GPR register or a constant of some form,
899 including a CONST_DOUBLE, which gpr_or_constant_operand doesn't recognize. */
902 gpr_or_dbl_const_operand (op
, mode
)
904 enum machine_mode mode
;
906 switch (GET_CODE (op
))
919 if (GET_CODE (SUBREG_REG (op
)) != REG
)
920 return register_operand (op
, mode
);
922 op
= SUBREG_REG (op
);
926 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
929 return GPR_OR_PSEUDO_P (REGNO (op
));
935 /* Return true if operand is a gpr register or a valid memory operation. */
938 gpr_or_memory_operand (op
, mode
)
940 enum machine_mode mode
;
942 switch (GET_CODE (op
))
948 if (GET_CODE (SUBREG_REG (op
)) != REG
)
949 return register_operand (op
, mode
);
951 op
= SUBREG_REG (op
);
955 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
958 return GPR_OR_PSEUDO_P (REGNO (op
));
961 return d30v_legitimate_address_p (mode
, XEXP (op
, 0), reload_completed
);
967 /* Return true if operand is something that can be an input for a move
971 move_input_operand (op
, mode
)
973 enum machine_mode mode
;
978 switch (GET_CODE (op
))
991 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
994 subreg
= SUBREG_REG (op
);
995 code
= GET_CODE (subreg
);
997 return d30v_legitimate_address_p ((int)mode
, XEXP (subreg
, 0),
1000 return (code
== REG
);
1003 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1009 if (GET_CODE (XEXP (op
, 0)) == ADDRESSOF
)
1011 return d30v_legitimate_address_p (mode
, XEXP (op
, 0),
1018 /* Return true if operand is something that can be an output for a move
1022 move_output_operand (op
, mode
)
1024 enum machine_mode mode
;
1029 switch (GET_CODE (op
))
1035 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1038 subreg
= SUBREG_REG (op
);
1039 code
= GET_CODE (subreg
);
1041 return d30v_legitimate_address_p ((int)mode
, XEXP (subreg
, 0),
1044 return (code
== REG
);
1047 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1053 if (GET_CODE (XEXP (op
, 0)) == ADDRESSOF
)
1055 return d30v_legitimate_address_p (mode
, XEXP (op
, 0),
1062 /* Return true if operand is a signed 6 bit immediate. */
1065 signed6_operand (op
, mode
)
1067 enum machine_mode mode ATTRIBUTE_UNUSED
;
1069 if (GET_CODE (op
) == CONST_INT
)
1070 return IN_RANGE_P (INTVAL (op
), -32, 31);
1075 /* Return true if operand is an unsigned 5 bit immediate. */
1078 unsigned5_operand (op
, mode
)
1080 enum machine_mode mode ATTRIBUTE_UNUSED
;
1082 if (GET_CODE (op
) == CONST_INT
)
1083 return IN_RANGE_P (INTVAL (op
), 0, 31);
1088 /* Return true if operand is an unsigned 6 bit immediate. */
1091 unsigned6_operand (op
, mode
)
1093 enum machine_mode mode ATTRIBUTE_UNUSED
;
1095 if (GET_CODE (op
) == CONST_INT
)
1096 return IN_RANGE_P (INTVAL (op
), 0, 63);
1101 /* Return true if operand is a constant with a single bit set. */
1104 bitset_operand (op
, mode
)
1106 enum machine_mode mode ATTRIBUTE_UNUSED
;
1108 if (GET_CODE (op
) == CONST_INT
)
1109 return IN_RANGE_P (exact_log2 (INTVAL (op
)), 0, 31);
1114 /* Return true if the operator is a ==/!= test against f0 or f1 that can be
1115 used in conditional execution. */
1118 condexec_test_operator (op
, mode
)
1120 enum machine_mode mode
;
1124 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1127 if (GET_CODE (op
) != EQ
&& GET_CODE (op
) != NE
)
1131 if (GET_CODE (x0
) != REG
|| !BR_FLAG_OR_PSEUDO_P (REGNO (x0
)))
1135 if (GET_CODE (x1
) != CONST_INT
|| INTVAL (x1
) != 0)
1141 /* Return true if the operator is a ==/!= test against f0, f1, or a general
1142 register that can be used in a branch instruction. */
1145 condexec_branch_operator (op
, mode
)
1147 enum machine_mode mode
;
1151 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1154 if (GET_CODE (op
) != EQ
&& GET_CODE (op
) != NE
)
1158 if (GET_CODE (x0
) == REG
)
1160 int regno
= REGNO (x0
);
1161 if (!GPR_OR_PSEUDO_P (regno
) && !BR_FLAG_P (regno
))
1164 /* Allow the optimizer to generate things like:
1165 (if_then_else (ne (const_int 1) (const_int 0))) */
1166 else if (GET_CODE (x0
) != CONST_INT
)
1170 if (GET_CODE (x1
) != CONST_INT
|| INTVAL (x1
) != 0)
1176 /* Return true if the unary operator can be executed with conditional
1180 condexec_unary_operator (op
, mode
)
1182 enum machine_mode mode ATTRIBUTE_UNUSED
;
1186 /* Only do this after register allocation, so that we can look at the register # */
1187 if (!reload_completed
)
1190 if (GET_RTX_CLASS (GET_CODE (op
)) != '1')
1194 if (GET_CODE (op0
) == SUBREG
)
1195 op0
= SUBREG_REG (op0
);
1197 switch (GET_CODE (op
))
1204 if (GET_MODE (op
) == SImode
&& GET_CODE (op0
) == REG
&& GPR_P (REGNO (op0
)))
1213 /* Return true if the add or subtraction can be executed with conditional
1217 condexec_addsub_operator (op
, mode
)
1219 enum machine_mode mode ATTRIBUTE_UNUSED
;
1223 /* Only do this after register allocation, so that we can look at the register # */
1224 if (!reload_completed
)
1227 if (GET_RTX_CLASS (GET_CODE (op
)) != '2' && GET_RTX_CLASS (GET_CODE (op
)) != 'c')
1233 if (GET_CODE (op0
) == SUBREG
)
1234 op0
= SUBREG_REG (op0
);
1236 if (GET_CODE (op1
) == SUBREG
)
1237 op1
= SUBREG_REG (op1
);
1239 if (GET_CODE (op0
) != REG
)
1242 switch (GET_CODE (op
))
1249 return (GET_MODE (op
) == SImode
&& GPR_P (REGNO (op0
))
1250 && gpr_or_constant_operand (op1
, SImode
));
1256 /* Return true if the binary operator can be executed with conditional
1257 execution. We don't include add/sub here, since they have extra
1258 clobbers for the flags registers. */
1261 condexec_binary_operator (op
, mode
)
1263 enum machine_mode mode ATTRIBUTE_UNUSED
;
1267 /* Only do this after register allocation, so that we can look at the register # */
1268 if (!reload_completed
)
1271 if (GET_RTX_CLASS (GET_CODE (op
)) != '2' && GET_RTX_CLASS (GET_CODE (op
)) != 'c')
1277 if (GET_CODE (op0
) == SUBREG
)
1278 op0
= SUBREG_REG (op0
);
1280 if (GET_CODE (op1
) == SUBREG
)
1281 op1
= SUBREG_REG (op1
);
1283 if (GET_CODE (op0
) != REG
)
1286 /* MULT is not included here, because it is an IU only instruction. */
1287 switch (GET_CODE (op
))
1298 return (GET_MODE (op
) == SImode
&& GPR_P (REGNO (op0
))
1299 && gpr_or_constant_operand (op1
, SImode
));
1303 return (GET_MODE (op
) == SImode
&& GPR_P (REGNO (op0
))
1304 && GET_CODE (op1
) == CONST_INT
);
1310 /* Return true if the shift/rotate left operator can be executed with
1311 conditional execution. */
1314 condexec_shiftl_operator (op
, mode
)
1316 enum machine_mode mode ATTRIBUTE_UNUSED
;
1320 /* Only do this after register allocation, so that we can look at the register # */
1321 if (!reload_completed
)
1324 if (GET_RTX_CLASS (GET_CODE (op
)) != '2' && GET_RTX_CLASS (GET_CODE (op
)) != 'c')
1330 if (GET_CODE (op0
) == SUBREG
)
1331 op0
= SUBREG_REG (op0
);
1333 if (GET_CODE (op1
) == SUBREG
)
1334 op1
= SUBREG_REG (op1
);
1336 if (GET_CODE (op0
) != REG
)
1339 switch (GET_CODE (op
))
1346 return (GET_MODE (op
) == SImode
&& GPR_P (REGNO (op0
))
1347 && GET_CODE (op1
) == NEG
1348 && GET_CODE (XEXP (op1
, 0)) == REG
1349 && GPR_P (REGNO (XEXP (op1
, 0))));
1355 /* Return true if the {sign,zero} extend operator from memory can be
1356 conditionally executed. */
1359 condexec_extend_operator (op
, mode
)
1361 enum machine_mode mode ATTRIBUTE_UNUSED
;
1363 /* Only do this after register allocation, so that we can look at the register # */
1364 if (!reload_completed
)
1367 if (GET_RTX_CLASS (GET_CODE (op
)) != '1')
1370 switch (GET_CODE (op
))
1377 if ((GET_MODE (op
) == SImode
&& GET_MODE (XEXP (op
, 0)) == QImode
)
1378 || (GET_MODE (op
) == SImode
&& GET_MODE (XEXP (op
, 0)) == HImode
)
1379 || (GET_MODE (op
) == HImode
&& GET_MODE (XEXP (op
, 0)) == QImode
))
1388 /* Return true for comparisons against 0 that can be turned into a
1389 bratnz/bratzr instruction. */
1392 branch_zero_operator (op
, mode
)
1394 enum machine_mode mode
;
1398 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1401 if (GET_CODE (op
) != EQ
&& GET_CODE (op
) != NE
)
1405 if (GET_CODE (x0
) != REG
|| !GPR_OR_PSEUDO_P (REGNO (x0
)))
1409 if (GET_CODE (x1
) != CONST_INT
|| INTVAL (x1
) != 0)
1415 /* Return true if an operand is simple, suitable for use as the destination of
1416 a conditional move */
1419 cond_move_dest_operand (op
, mode
)
1421 enum machine_mode mode ATTRIBUTE_UNUSED
;
1425 if (mode
!= QImode
&& mode
!= HImode
&& mode
!= SImode
&& mode
!= SFmode
)
1428 switch (GET_CODE (op
))
1435 return gpr_operand (op
, mode
);
1437 /* Don't allow post dec/inc, since we might not get the side effects correct. */
1439 addr
= XEXP (op
, 0);
1440 return (GET_CODE (addr
) != POST_DEC
1441 && GET_CODE (addr
) != POST_INC
1442 && d30v_legitimate_address_p (mode
, addr
, reload_completed
));
1448 /* Return true if an operand is simple, suitable for use in a conditional move */
1451 cond_move_operand (op
, mode
)
1453 enum machine_mode mode ATTRIBUTE_UNUSED
;
1457 if (mode
!= QImode
&& mode
!= HImode
&& mode
!= SImode
&& mode
!= SFmode
)
1460 switch (GET_CODE (op
))
1467 return gpr_operand (op
, mode
);
1470 return GET_MODE (op
) == SFmode
;
1478 /* Don't allow post dec/inc, since we might not get the side effects correct. */
1480 addr
= XEXP (op
, 0);
1481 return (GET_CODE (addr
) != POST_DEC
1482 && GET_CODE (addr
) != POST_INC
1483 && d30v_legitimate_address_p (mode
, addr
, reload_completed
));
1489 /* Return true if an operand is simple, suitable for use in conditional execution.
1490 Unlike cond_move, we can allow auto inc/dec. */
1493 cond_exec_operand (op
, mode
)
1495 enum machine_mode mode
;
1497 if (mode
!= QImode
&& mode
!= HImode
&& mode
!= SImode
&& mode
!= SFmode
)
1500 switch (GET_CODE (op
))
1507 return gpr_operand (op
, mode
);
1510 return GET_MODE (op
) == SFmode
;
1519 return memory_operand (op
, mode
);
1525 /* Return true if operand is a SI mode signed relational test. */
1528 srelational_si_operator (op
, mode
)
1530 enum machine_mode mode
;
1534 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1537 switch (GET_CODE (op
))
1552 if (GET_CODE (x0
) != REG
&& GET_CODE (x0
) != SUBREG
)
1555 if (GET_MODE (x0
) != SImode
)
1559 switch (GET_CODE (x1
))
1576 /* Return true if operand is a SI mode unsigned relational test. */
1579 urelational_si_operator (op
, mode
)
1581 enum machine_mode mode
;
1585 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1588 switch (GET_CODE (op
))
1601 if (GET_CODE (x0
) != REG
&& GET_CODE (x0
) != SUBREG
)
1604 if (GET_MODE (x0
) != SImode
)
1608 switch (GET_CODE (x1
))
1625 /* Return true if operand is a DI mode relational test. */
1628 relational_di_operator (op
, mode
)
1630 enum machine_mode mode
;
1634 if (GET_MODE (op
) != mode
&& mode
!= VOIDmode
)
1637 if (GET_RTX_CLASS (GET_CODE (op
)) != '<')
1641 if (GET_CODE (x0
) != REG
&& GET_CODE (x0
) != SUBREG
)
1644 if (GET_MODE (x0
) != DImode
)
1648 if (GET_CODE (x1
) != REG
&& GET_CODE (x1
) != SUBREG
1649 && GET_CODE (x1
) != CONST_INT
&& GET_CODE (x1
) != CONST_DOUBLE
)
1656 /* Calculate the stack information for the current function.
1658 D30V stack frames look like:
1661 +-------------------------------+
1662 | Argument word #19 |
1663 +-------------------------------+
1664 | Argument word #18 |
1665 +-------------------------------+
1666 | Argument word #17 |
1667 +-------------------------------+
1668 | Argument word #16 |
1669 Prev sp +-------------------------------+
1671 | Save for arguments 1..16 if |
1672 | the func. uses stdarg/varargs |
1674 +-------------------------------+
1676 | Save area for GPR registers |
1678 +-------------------------------+
1680 | Save area for accumulators |
1682 +-------------------------------+
1686 +-------------------------------+
1688 | alloca space if used |
1690 +-------------------------------+
1692 | Space for outgoing arguments |
1694 low SP----> +-------------------------------+
1700 static d30v_stack_t info
, zero_info
;
1701 d30v_stack_t
*info_ptr
= &info
;
1702 tree fndecl
= current_function_decl
;
1703 tree fntype
= TREE_TYPE (fndecl
);
1711 unsigned char save_gpr_p
[GPR_LAST
];
1714 /* If we've already calculated the values and reload is complete, just return now */
1715 if (d30v_stack_cache
)
1716 return d30v_stack_cache
;
1718 /* Zero all fields */
1721 if (current_function_profile
)
1722 regs_ever_live
[GPR_LINK
] = 1;
1724 /* Determine if this is a stdarg function */
1725 if (TYPE_ARG_TYPES (fntype
) != 0
1726 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype
))) != void_type_node
))
1730 /* Find the last argument, and see if it is __builtin_va_alist. */
1731 for (cur_arg
= DECL_ARGUMENTS (fndecl
); cur_arg
!= (tree
)0; cur_arg
= next_arg
)
1733 next_arg
= TREE_CHAIN (cur_arg
);
1734 if (next_arg
== (tree
)0)
1736 if (DECL_NAME (cur_arg
)
1737 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (cur_arg
)), "__builtin_va_alist"))
1745 /* Calculate which registers need to be saved & save area size */
1749 for (i
= ACCUM_FIRST
; i
<= ACCUM_LAST
; i
++)
1751 if (regs_ever_live
[i
] && !call_used_regs
[i
])
1753 info_ptr
->save_p
[i
] = 2;
1760 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
++)
1762 if (regs_ever_live
[i
] && (!call_used_regs
[i
] || i
== GPR_LINK
))
1771 /* Determine which register pairs can be saved together with ld2w/st2w */
1772 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
++)
1774 if (((i
- GPR_FIRST
) & 1) == 0 && save_gpr_p
[i
] && save_gpr_p
[i
+1])
1777 info_ptr
->save_p
[i
++] = 2;
1779 else if (save_gpr_p
[i
])
1782 info_ptr
->save_p
[i
] = 1;
1786 /* Determine various sizes */
1787 info_ptr
->varargs_p
= varargs_p
;
1788 info_ptr
->varargs_size
= ((varargs_p
)
1789 ? (GPR_ARG_LAST
+ 1 - GPR_ARG_FIRST
) * UNITS_PER_WORD
1792 info_ptr
->accum_size
= 2 * UNITS_PER_WORD
* saved_accs
;
1793 info_ptr
->gpr_size
= D30V_ALIGN (UNITS_PER_WORD
* saved_gprs
,
1794 2 * UNITS_PER_WORD
);
1795 info_ptr
->vars_size
= D30V_ALIGN (get_frame_size (), 2 * UNITS_PER_WORD
);
1796 info_ptr
->parm_size
= D30V_ALIGN (current_function_outgoing_args_size
,
1797 2 * UNITS_PER_WORD
);
1799 info_ptr
->total_size
= D30V_ALIGN ((info_ptr
->gpr_size
1800 + info_ptr
->accum_size
1801 + info_ptr
->vars_size
1802 + info_ptr
->parm_size
1803 + info_ptr
->varargs_size
1804 + current_function_pretend_args_size
),
1805 (STACK_BOUNDARY
/ BITS_PER_UNIT
));
1807 info_ptr
->save_offset
= (info_ptr
->total_size
1808 - (current_function_pretend_args_size
1809 + info_ptr
->varargs_size
1810 + info_ptr
->gpr_size
1811 + info_ptr
->accum_size
));
1813 /* The link register is the last GPR saved, but there might be some padding
1814 bytes after it, so account for that. */
1815 info_ptr
->link_offset
= (info_ptr
->total_size
1816 - (current_function_pretend_args_size
1817 + info_ptr
->varargs_size
1818 + (info_ptr
->gpr_size
1819 - UNITS_PER_WORD
* saved_gprs
)
1822 info_ptr
->memrefs_varargs
= info_ptr
->varargs_size
/ (2 * UNITS_PER_WORD
);
1823 info_ptr
->memrefs_2words
= memrefs_2words
;
1824 info_ptr
->memrefs_1word
= memrefs_1word
;
1826 if (reload_completed
)
1827 d30v_stack_cache
= info_ptr
;
1833 /* Internal function to print all of the information about the stack */
1836 debug_stack_info (info
)
1842 info
= d30v_stack_info ();
1844 fprintf (stderr
, "\nStack information for function %s:\n",
1845 ((current_function_decl
&& DECL_NAME (current_function_decl
))
1846 ? IDENTIFIER_POINTER (DECL_NAME (current_function_decl
))
1849 fprintf (stderr
, "\tsave_offset = %d\n", info
->save_offset
);
1850 fprintf (stderr
, "\tmemrefs_varargs = %d\n", info
->memrefs_varargs
);
1851 fprintf (stderr
, "\tmemrefs_2words = %d\n", info
->memrefs_2words
);
1852 fprintf (stderr
, "\tmemrefs_1word = %d\n", info
->memrefs_1word
);
1853 fprintf (stderr
, "\tvarargs_p = %d\n", info
->varargs_p
);
1854 fprintf (stderr
, "\tvarargs_size = %d\n", info
->varargs_size
);
1855 fprintf (stderr
, "\tvars_size = %d\n", info
->vars_size
);
1856 fprintf (stderr
, "\tparm_size = %d\n", info
->parm_size
);
1857 fprintf (stderr
, "\tgpr_size = %d\n", info
->gpr_size
);
1858 fprintf (stderr
, "\taccum_size = %d\n", info
->accum_size
);
1859 fprintf (stderr
, "\ttotal_size = %d\n", info
->total_size
);
1860 fprintf (stderr
, "\tsaved registers =");
1862 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1864 if (info
->save_p
[i
] == 2)
1866 fprintf (stderr
, " %s-%s", reg_names
[i
], reg_names
[i
+1]);
1869 else if (info
->save_p
[i
])
1870 fprintf (stderr
, " %s", reg_names
[i
]);
1873 putc ('\n', stderr
);
1878 /* Return nonzero if this function is known to have a null or 1 instruction epilogue. */
1883 if (reload_completed
)
1885 d30v_stack_t
*info
= d30v_stack_info ();
1887 /* If no epilogue code is needed, can use just a simple jump */
1888 if (info
->total_size
== 0)
1892 /* If just a small amount of local stack was allocated and no registers
1893 saved, skip forward branch */
1894 if (info
->total_size
== info
->vars_size
1895 && IN_RANGE_P (info
->total_size
, 1, 31))
1904 /* A C statement (sans semicolon) for initializing the variable CUM for the
1905 state at the beginning of the argument list. The variable has type
1906 `CUMULATIVE_ARGS'. The value of FNTYPE is the tree node for the data type
1907 of the function which will receive the args, or 0 if the args are to a
1908 compiler support library function.
1910 The value of FNDECL is NULL for indirect calls (eg via a function pointer)
1911 and library calls. For direct calls, and when INIT_CUMULATIVE_ARGS is
1912 being used to find arguments for the function being compiled it contains
1913 the declaration node of FNTYPE.
1915 When processing a call to a compiler support library function, LIBNAME
1916 identifies which one. It is a `symbol_ref' rtx which contains the name of
1917 the function, as a string. LIBNAME is 0 when an ordinary C function call
1918 is being processed. Thus, each time this macro is called, either LIBNAME
1919 or FNTYPE is nonzero, but never both of them at once. */
1922 d30v_init_cumulative_args (cum
, fntype
, libname
, fndecl
, incoming
)
1923 CUMULATIVE_ARGS
*cum
;
1929 *cum
= GPR_ARG_FIRST
;
1931 if (TARGET_DEBUG_ARG
)
1933 fprintf (stderr
, "\ninit_cumulative_args:");
1934 if (!fndecl
&& fntype
)
1935 fputs (" indirect", stderr
);
1938 fputs (" incoming", stderr
);
1942 tree ret_type
= TREE_TYPE (fntype
);
1943 fprintf (stderr
, " return=%s,",
1944 tree_code_name
[ (int)TREE_CODE (ret_type
) ]);
1947 if (libname
&& GET_CODE (libname
) == SYMBOL_REF
)
1948 fprintf (stderr
, " libname=%s", XSTR (libname
, 0));
1950 putc ('\n', stderr
);
1955 /* If defined, a C expression that gives the alignment boundary, in bits, of an
1956 argument with the specified mode and type. If it is not defined,
1957 `PARM_BOUNDARY' is used for all arguments. */
1960 d30v_function_arg_boundary (mode
, type
)
1961 enum machine_mode mode
;
1964 int size
= ((mode
== BLKmode
&& type
)
1965 ? int_size_in_bytes (type
)
1966 : (int) GET_MODE_SIZE (mode
));
1968 return (size
> UNITS_PER_WORD
) ? 2*UNITS_PER_WORD
: UNITS_PER_WORD
;
1972 /* A C expression that controls whether a function argument is passed in a
1973 register, and which register.
1975 The arguments are CUM, which summarizes all the previous arguments; MODE,
1976 the machine mode of the argument; TYPE, the data type of the argument as a
1977 tree node or 0 if that is not known (which happens for C support library
1978 functions); and NAMED, which is 1 for an ordinary argument and 0 for
1979 nameless arguments that correspond to `...' in the called function's
1982 The value of the expression should either be a `reg' RTX for the hard
1983 register in which to pass the argument, or zero to pass the argument on the
1986 For machines like the VAX and 68000, where normally all arguments are
1987 pushed, zero suffices as a definition.
1989 The usual way to make the ANSI library `stdarg.h' work on a machine where
1990 some arguments are usually passed in registers, is to cause nameless
1991 arguments to be passed on the stack instead. This is done by making
1992 `FUNCTION_ARG' return 0 whenever NAMED is 0.
1994 You may use the macro `MUST_PASS_IN_STACK (MODE, TYPE)' in the definition of
1995 this macro to determine if this argument is of a type that must be passed in
1996 the stack. If `REG_PARM_STACK_SPACE' is not defined and `FUNCTION_ARG'
1997 returns nonzero for such an argument, the compiler will abort. If
1998 `REG_PARM_STACK_SPACE' is defined, the argument will be computed in the
1999 stack and then loaded into a register. */
2002 d30v_function_arg (cum
, mode
, type
, named
, incoming
)
2003 CUMULATIVE_ARGS
*cum
;
2004 enum machine_mode mode
;
2007 int incoming ATTRIBUTE_UNUSED
;
2009 int size
= ((mode
== BLKmode
&& type
)
2010 ? int_size_in_bytes (type
)
2011 : (int) GET_MODE_SIZE (mode
));
2012 int adjust
= (size
> UNITS_PER_WORD
&& (*cum
& 1) != 0);
2015 /* Return a marker for use in the call instruction. */
2016 if (mode
== VOIDmode
)
2019 else if (*cum
+ adjust
<= GPR_ARG_LAST
)
2020 ret
= gen_rtx (REG
, mode
, *cum
+ adjust
);
2025 if (TARGET_DEBUG_ARG
)
2027 "function_arg: words = %2d, mode = %4s, named = %d, size = %3d, adjust = %1d, arg = %s\n",
2028 *cum
, GET_MODE_NAME (mode
), named
, size
, adjust
,
2029 (ret
) ? ((ret
== const0_rtx
) ? "<0>" : reg_names
[ REGNO (ret
) ]) : "memory");
2035 /* A C expression for the number of words, at the beginning of an argument,
2036 must be put in registers. The value must be zero for arguments that are
2037 passed entirely in registers or that are entirely pushed on the stack.
2039 On some machines, certain arguments must be passed partially in registers
2040 and partially in memory. On these machines, typically the first N words of
2041 arguments are passed in registers, and the rest on the stack. If a
2042 multi-word argument (a `double' or a structure) crosses that boundary, its
2043 first few words must be passed in registers and the rest must be pushed.
2044 This macro tells the compiler when this occurs, and how many of the words
2045 should go in registers.
2047 `FUNCTION_ARG' for these arguments should return the first register to be
2048 used by the caller for this argument; likewise `FUNCTION_INCOMING_ARG', for
2049 the called function. */
2052 d30v_function_arg_partial_nregs (cum
, mode
, type
, named
)
2053 CUMULATIVE_ARGS
*cum
;
2054 enum machine_mode mode
;
2056 int named ATTRIBUTE_UNUSED
;
2058 int bytes
= ((mode
== BLKmode
)
2059 ? int_size_in_bytes (type
)
2060 : (int) GET_MODE_SIZE (mode
));
2061 int words
= (bytes
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
2062 int adjust
= (bytes
> UNITS_PER_WORD
&& (*cum
& 1) != 0);
2063 int arg_num
= *cum
+ adjust
;
2066 ret
= ((arg_num
<= GPR_ARG_LAST
&& arg_num
+ words
> GPR_ARG_LAST
+1)
2067 ? GPR_ARG_LAST
- arg_num
+ 1
2070 if (TARGET_DEBUG_ARG
&& ret
)
2071 fprintf (stderr
, "function_arg_partial_nregs: %d\n", ret
);
2077 /* A C expression that indicates when an argument must be passed by reference.
2078 If nonzero for an argument, a copy of that argument is made in memory and a
2079 pointer to the argument is passed instead of the argument itself. The
2080 pointer is passed in whatever way is appropriate for passing a pointer to
2083 On machines where `REG_PARM_STACK_SPACE' is not defined, a suitable
2084 definition of this macro might be
2085 #define FUNCTION_ARG_PASS_BY_REFERENCE\
2086 (CUM, MODE, TYPE, NAMED) \
2087 MUST_PASS_IN_STACK (MODE, TYPE) */
2090 d30v_function_arg_pass_by_reference (cum
, mode
, type
, named
)
2091 CUMULATIVE_ARGS
*cum ATTRIBUTE_UNUSED
;
2092 enum machine_mode mode
;
2094 int named ATTRIBUTE_UNUSED
;
2096 int ret
= MUST_PASS_IN_STACK (mode
, type
);
2098 if (TARGET_DEBUG_ARG
&& ret
)
2099 fprintf (stderr
, "function_arg_pass_by_reference: %d\n", ret
);
2105 /* A C statement (sans semicolon) to update the summarizer variable CUM to
2106 advance past an argument in the argument list. The values MODE, TYPE and
2107 NAMED describe that argument. Once this is done, the variable CUM is
2108 suitable for analyzing the *following* argument with `FUNCTION_ARG', etc.
2110 This macro need not do anything if the argument in question was passed on
2111 the stack. The compiler knows how to track the amount of stack space used
2112 for arguments without any special help. */
2115 d30v_function_arg_advance (cum
, mode
, type
, named
)
2116 CUMULATIVE_ARGS
*cum
;
2117 enum machine_mode mode
;
2121 int bytes
= ((mode
== BLKmode
)
2122 ? int_size_in_bytes (type
)
2123 : (int) GET_MODE_SIZE (mode
));
2124 int words
= D30V_ALIGN (bytes
, UNITS_PER_WORD
) / UNITS_PER_WORD
;
2125 int adjust
= (bytes
> UNITS_PER_WORD
&& (*cum
& 1) != 0);
2127 *cum
+= words
+ adjust
;
2129 if (TARGET_DEBUG_ARG
)
2131 "function_adv: words = %2d, mode = %4s, named = %d, size = %3d, adjust = %1d\n",
2132 *cum
, GET_MODE_NAME (mode
), named
, words
* UNITS_PER_WORD
, adjust
);
2136 /* If defined, is a C expression that produces the machine-specific code for a
2137 call to `__builtin_saveregs'. This code will be moved to the very beginning
2138 of the function, before any parameter access are made. The return value of
2139 this function should be an RTX that contains the value to use as the return
2140 of `__builtin_saveregs'.
2142 If this macro is not defined, the compiler will output an ordinary call to
2143 the library function `__builtin_saveregs'. */
2146 d30v_expand_builtin_saveregs ()
2148 int offset
= UNITS_PER_WORD
* (GPR_ARG_LAST
+ 1 - GPR_ARG_FIRST
);
2150 if (TARGET_DEBUG_ARG
)
2151 fprintf (stderr
, "expand_builtin_saveregs: offset from ap = %d\n",
2154 return gen_rtx (PLUS
, Pmode
, virtual_incoming_args_rtx
, GEN_INT (- offset
));
2158 /* This macro offers an alternative to using `__builtin_saveregs' and defining
2159 the macro `EXPAND_BUILTIN_SAVEREGS'. Use it to store the anonymous register
2160 arguments into the stack so that all the arguments appear to have been
2161 passed consecutively on the stack. Once this is done, you can use the
2162 standard implementation of varargs that works for machines that pass all
2163 their arguments on the stack.
2165 The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure, containing
2166 the values that obtain after processing of the named arguments. The
2167 arguments MODE and TYPE describe the last named argument--its machine mode
2168 and its data type as a tree node.
2170 The macro implementation should do two things: first, push onto the stack
2171 all the argument registers *not* used for the named arguments, and second,
2172 store the size of the data thus pushed into the `int'-valued variable whose
2173 name is supplied as the argument PRETEND_ARGS_SIZE. The value that you
2174 store here will serve as additional offset for setting up the stack frame.
2176 Because you must generate code to push the anonymous arguments at compile
2177 time without knowing their data types, `SETUP_INCOMING_VARARGS' is only
2178 useful on machines that have just a single category of argument register and
2179 use it uniformly for all data types.
2181 If the argument SECOND_TIME is nonzero, it means that the arguments of the
2182 function are being analyzed for the second time. This happens for an inline
2183 function, which is not actually compiled until the end of the source file.
2184 The macro `SETUP_INCOMING_VARARGS' should not generate any instructions in
2188 d30v_setup_incoming_varargs (cum
, mode
, type
, pretend_size
, second_time
)
2189 CUMULATIVE_ARGS
*cum
;
2190 enum machine_mode mode
;
2191 tree type ATTRIBUTE_UNUSED
;
2192 int *pretend_size ATTRIBUTE_UNUSED
;
2195 if (TARGET_DEBUG_ARG
)
2197 "setup_vararg: words = %2d, mode = %4s, second_time = %d\n",
2198 *cum
, GET_MODE_NAME (mode
), second_time
);
2202 /* Create the va_list data type. */
2205 d30v_build_va_list ()
2207 tree f_arg_ptr
, f_arg_num
, record
, type_decl
;
2210 record
= (*lang_hooks
.types
.make_type
) (RECORD_TYPE
);
2211 type_decl
= build_decl (TYPE_DECL
, get_identifier ("__va_list_tag"), record
);
2212 int_type_node
= make_signed_type (INT_TYPE_SIZE
);
2214 f_arg_ptr
= build_decl (FIELD_DECL
, get_identifier ("__va_arg_ptr"),
2216 f_arg_num
= build_decl (FIELD_DECL
, get_identifier ("__va_arg_num"),
2219 DECL_FIELD_CONTEXT (f_arg_ptr
) = record
;
2220 DECL_FIELD_CONTEXT (f_arg_num
) = record
;
2222 TREE_CHAIN (record
) = type_decl
;
2223 TYPE_NAME (record
) = type_decl
;
2224 TYPE_FIELDS (record
) = f_arg_ptr
;
2225 TREE_CHAIN (f_arg_ptr
) = f_arg_num
;
2227 layout_type (record
);
2229 /* The correct type is an array type of one element. */
2230 return build_array_type (record
, build_index_type (size_zero_node
));
2234 /* Expand __builtin_va_start to do the va_start macro. */
2237 d30v_expand_builtin_va_start (valist
, nextarg
)
2239 rtx nextarg ATTRIBUTE_UNUSED
;
2241 HOST_WIDE_INT words
;
2242 tree f_arg_ptr
, f_arg_num
;
2243 tree arg_ptr
, arg_num
, saveregs
, t
;
2245 f_arg_ptr
= TYPE_FIELDS (TREE_TYPE (va_list_type_node
));
2246 f_arg_num
= TREE_CHAIN (f_arg_ptr
);
2248 valist
= build1 (INDIRECT_REF
, TREE_TYPE (TREE_TYPE (valist
)), valist
);
2249 arg_ptr
= build (COMPONENT_REF
, TREE_TYPE (f_arg_ptr
), valist
, f_arg_ptr
);
2250 arg_num
= build (COMPONENT_REF
, TREE_TYPE (f_arg_num
), valist
, f_arg_num
);
2252 words
= current_function_args_info
; /* __builtin_args_info (0) */
2254 /* (AP)->__va_arg_ptr = (int *) __builtin_saveregs (); */
2255 saveregs
= make_tree (TREE_TYPE (arg_ptr
), d30v_expand_builtin_saveregs ());
2256 t
= build (MODIFY_EXPR
, TREE_TYPE (arg_ptr
), arg_ptr
, saveregs
);
2257 TREE_SIDE_EFFECTS (t
) = 1;
2258 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2260 /* (AP)->__va_arg_num = __builtin_args_info (0) - 2; */
2261 t
= build (PLUS_EXPR
, TREE_TYPE (arg_num
), build_int_2 (words
, 0),
2262 build_int_2 (-GPR_ARG_FIRST
, 0));
2263 t
= build (MODIFY_EXPR
, TREE_TYPE (arg_num
), arg_num
, t
);
2264 TREE_SIDE_EFFECTS (t
) = 1;
2265 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2269 /* Expand __builtin_va_arg to do the va_arg macro. */
2272 d30v_expand_builtin_va_arg(valist
, type
)
2276 tree f_arg_ptr
, f_arg_num
;
2277 tree arg_ptr
, arg_num
, t
, ptr
;
2279 rtx lab_false
, ptr_rtx
, r
;
2281 f_arg_ptr
= TYPE_FIELDS (TREE_TYPE (va_list_type_node
));
2282 f_arg_num
= TREE_CHAIN (f_arg_ptr
);
2284 valist
= build1 (INDIRECT_REF
, TREE_TYPE (TREE_TYPE (valist
)), valist
);
2285 arg_ptr
= build (COMPONENT_REF
, TREE_TYPE (f_arg_ptr
), valist
, f_arg_ptr
);
2286 arg_num
= build (COMPONENT_REF
, TREE_TYPE (f_arg_num
), valist
, f_arg_num
);
2288 size
= int_size_in_bytes (type
);
2290 lab_false
= gen_label_rtx ();
2291 ptr_rtx
= gen_reg_rtx (Pmode
);
2293 /* if (sizeof (TYPE) > 4 && ((AP)->__va_arg_num & 1) != 0)
2294 (AP)->__va_arg_num++; */
2296 if (size
> UNITS_PER_WORD
)
2298 t
= build (BIT_AND_EXPR
, TREE_TYPE (arg_num
), arg_num
,
2299 build_int_2 (1, 0));
2301 emit_cmp_and_jump_insns (expand_expr (t
, NULL_RTX
, QImode
, EXPAND_NORMAL
),
2302 GEN_INT (0), EQ
, const1_rtx
, QImode
, 1,
2305 t
= build (POSTINCREMENT_EXPR
, TREE_TYPE (arg_num
), arg_num
,
2306 build_int_2 (1, 0));
2307 TREE_SIDE_EFFECTS (t
) = 1;
2308 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2310 emit_label (lab_false
);
2314 /* __ptr = (TYPE *)(((char *)(void *)((AP)->__va_arg_ptr
2315 + (AP)->__va_arg_num))); */
2317 t
= build (MULT_EXPR
, TREE_TYPE (arg_num
), arg_num
, build_int_2 (4, 0));
2318 t
= build (PLUS_EXPR
, ptr_type_node
, arg_ptr
, t
);
2320 /* if (sizeof (TYPE) < 4)
2321 __ptr = (void *)__ptr + 4 - sizeof (TYPE); */
2323 if (size
< UNITS_PER_WORD
)
2324 t
= build (PLUS_EXPR
, ptr_type_node
, t
,
2325 build_int_2 (UNITS_PER_WORD
- size
, 0));
2327 TREE_SIDE_EFFECTS (t
) = 1;
2329 ptr
= build1 (NOP_EXPR
, build_pointer_type (type
), t
);
2330 t
= build (MODIFY_EXPR
, type
, ptr
, t
);
2332 r
= expand_expr (t
, ptr_rtx
, Pmode
, EXPAND_NORMAL
);
2334 emit_move_insn (ptr_rtx
, r
);
2337 /* (AP)->__va_arg_num += (sizeof (TYPE) + 3) / 4; */
2338 num
= (size
+ (UNITS_PER_WORD
- 1)) / UNITS_PER_WORD
;
2339 t
= build (POSTINCREMENT_EXPR
, TREE_TYPE (arg_num
), arg_num
,
2340 build_int_2 (num
, 0));
2341 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2346 /* Generate the assembly code for function entry. FILE is a stdio
2347 stream to output the code to. SIZE is an int: how many units of
2348 temporary storage to allocate.
2350 Refer to the array `regs_ever_live' to determine which registers to
2351 save; `regs_ever_live[I]' is nonzero if register number I is ever
2352 used in the function. This function is responsible for knowing
2353 which registers should not be saved even if used. */
2356 d30v_output_function_prologue (stream
, size
)
2357 FILE *stream ATTRIBUTE_UNUSED
;
2358 HOST_WIDE_INT size ATTRIBUTE_UNUSED
;
2360 /* For the d30v, move all of the prologue processing into separate
2365 /* Called after register allocation to add any instructions needed for
2366 the prologue. Using a prologue insn is favored compared to putting
2367 all of the instructions in output_function_prologue (), since it
2368 allows the scheduler to intermix instructions with the saves of the
2369 caller saved registers. In some cases, it might be necessary to
2370 emit a barrier instruction as the last insn to prevent such
2374 d30v_expand_prologue ()
2376 rtx sp
= stack_pointer_rtx
;
2377 d30v_stack_t
*info
= d30v_stack_info ();
2379 rtx mem_di
= NULL_RTX
;
2380 rtx mem_si
= NULL_RTX
;
2381 int num_memrefs
= (info
->memrefs_2words
2382 + info
->memrefs_1word
2383 + info
->memrefs_varargs
);
2385 if (TARGET_DEBUG_STACK
)
2386 debug_stack_info (info
);
2388 /* Grow the stack. */
2389 if (info
->total_size
)
2390 emit_insn (gen_addsi3 (sp
, sp
, GEN_INT (- info
->total_size
)));
2392 /* If there is more than one save, use post-increment addressing which will
2393 result in smaller code, than would the normal references. If there is
2394 only one save, just do the store as normal. */
2396 if (num_memrefs
> 1)
2398 rtx save_tmp
= gen_rtx (REG
, Pmode
, GPR_STACK_TMP
);
2399 rtx post_inc
= gen_rtx (POST_INC
, Pmode
, save_tmp
);
2400 mem_di
= gen_rtx (MEM
, DImode
, post_inc
);
2401 mem_si
= gen_rtx (MEM
, SImode
, post_inc
);
2402 emit_insn (gen_addsi3 (save_tmp
, sp
, GEN_INT (info
->save_offset
)));
2404 else if (num_memrefs
== 1)
2406 rtx addr
= plus_constant (sp
, info
->save_offset
);
2407 mem_di
= gen_rtx (MEM
, DImode
, addr
);
2408 mem_si
= gen_rtx (MEM
, SImode
, addr
);
2411 /* Save the accumulators. */
2412 for (i
= ACCUM_FIRST
; i
<= ACCUM_LAST
; i
++)
2413 if (info
->save_p
[i
])
2415 rtx acc_tmp
= gen_rtx (REG
, DImode
, GPR_ATMP_FIRST
);
2416 emit_insn (gen_movdi (acc_tmp
, gen_rtx (REG
, DImode
, i
)));
2417 emit_insn (gen_movdi (mem_di
, acc_tmp
));
2420 /* Save the GPR registers that are adjacent to each other with st2w. */
2421 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
+= 2)
2422 if (info
->save_p
[i
] == 2)
2423 emit_insn (gen_movdi (mem_di
, gen_rtx (REG
, DImode
, i
)));
2425 /* Save the GPR registers that need to be saved with a single word store. */
2426 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
++)
2427 if (info
->save_p
[i
] == 1)
2428 emit_insn (gen_movsi (mem_si
, gen_rtx (REG
, SImode
, i
)));
2430 /* Save the argument registers if this function accepts variable args. */
2431 if (info
->varargs_p
)
2433 /* Realign r22 if an odd # of GPRs were saved. */
2434 if ((info
->memrefs_1word
& 1) != 0)
2436 rtx save_tmp
= XEXP (XEXP (mem_si
, 0), 0);
2437 emit_insn (gen_addsi3 (save_tmp
, save_tmp
, GEN_INT (UNITS_PER_WORD
)));
2440 for (i
= GPR_ARG_FIRST
; i
<= GPR_ARG_LAST
; i
+= 2)
2441 emit_insn (gen_movdi (mem_di
, gen_rtx (REG
, DImode
, i
)));
2444 /* Update the frame pointer. */
2445 if (frame_pointer_needed
)
2446 emit_move_insn (frame_pointer_rtx
, sp
);
2448 /* Hack for now, to prevent scheduler from being too cleaver */
2449 emit_insn (gen_blockage ());
2453 /* This function generates the assembly code for function exit.
2454 Args are as for output_function_prologue ().
2456 The function epilogue should not depend on the current stack
2457 pointer! It should use the frame pointer only. This is mandatory
2458 because of alloca; we also take advantage of it to omit stack
2459 adjustments before returning. */
2462 d30v_output_function_epilogue (stream
, size
)
2463 FILE *stream ATTRIBUTE_UNUSED
;
2464 HOST_WIDE_INT size ATTRIBUTE_UNUSED
;
2466 /* For the d30v, move all processing to be as insns, but do any
2467 cleanup here, since it is done after handling all of the insns. */
2468 d30v_stack_cache
= (d30v_stack_t
*)0; /* reset stack cache */
2473 /* Called after register allocation to add any instructions needed for
2474 the epilogue. Using an epilogue insn is favored compared to putting
2475 all of the instructions in output_function_prologue(), since it
2476 allows the scheduler to intermix instructions with the saves of the
2477 caller saved registers. In some cases, it might be necessary to
2478 emit a barrier instruction as the last insn to prevent such
2482 d30v_expand_epilogue ()
2484 rtx sp
= stack_pointer_rtx
;
2485 d30v_stack_t
*info
= d30v_stack_info ();
2487 rtx mem_di
= NULL_RTX
;
2488 rtx mem_si
= NULL_RTX
;
2492 /* Hack for now, to prevent scheduler from being too cleaver */
2493 emit_insn (gen_blockage ());
2495 /* Restore sp from fp. */
2496 if (frame_pointer_needed
)
2497 emit_move_insn (sp
, frame_pointer_rtx
);
2499 /* For the epilogue, use post-increment addressing all of the time. First
2500 adjust the sp, to eliminate all of the stack, except for the save area. */
2502 if (info
->save_offset
)
2503 emit_insn (gen_addsi3 (sp
, sp
, GEN_INT (info
->save_offset
)));
2505 post_inc
= gen_rtx (POST_INC
, Pmode
, sp
);
2506 mem_di
= gen_rtx (MEM
, DImode
, post_inc
);
2507 mem_si
= gen_rtx (MEM
, SImode
, post_inc
);
2509 /* Restore the accumulators. */
2510 for (i
= ACCUM_FIRST
; i
<= ACCUM_LAST
; i
++)
2511 if (info
->save_p
[i
])
2513 rtx acc_tmp
= gen_rtx (REG
, DImode
, GPR_ATMP_FIRST
);
2514 emit_insn (gen_movdi (acc_tmp
, mem_di
));
2515 emit_insn (gen_movdi (gen_rtx (REG
, DImode
, i
), acc_tmp
));
2518 /* Restore the GPR registers that are adjacent to each other with ld2w. */
2519 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
+= 2)
2520 if (info
->save_p
[i
] == 2)
2521 emit_insn (gen_movdi (gen_rtx (REG
, DImode
, i
), mem_di
));
2523 /* Save the GPR registers that need to be saved with a single word store. */
2525 for (i
= GPR_FIRST
; i
<= GPR_LAST
; i
++)
2526 if (info
->save_p
[i
] == 1)
2528 if (cfun
->machine
->eh_epilogue_sp_ofs
&& i
== GPR_LINK
)
2534 emit_insn (gen_addsi3 (sp
, sp
, GEN_INT (extra_stack
)));
2537 emit_insn (gen_movsi (gen_rtx (REG
, SImode
, i
), mem_si
));
2541 /* Release any remaining stack that was allocated for saving the
2542 varargs registers or because an odd # of registers were stored. */
2543 if ((info
->memrefs_1word
& 1) != 0)
2544 extra_stack
+= UNITS_PER_WORD
;
2545 extra_stack
+= current_function_pretend_args_size
+ info
->varargs_size
;
2549 if (cfun
->machine
->eh_epilogue_sp_ofs
)
2550 emit_insn (gen_addsi3 (cfun
->machine
->eh_epilogue_sp_ofs
,
2551 cfun
->machine
->eh_epilogue_sp_ofs
,
2552 GEN_INT (extra_stack
)));
2554 emit_insn (gen_addsi3 (sp
, sp
, GEN_INT (extra_stack
)));
2556 if (cfun
->machine
->eh_epilogue_sp_ofs
)
2557 emit_insn (gen_addsi3 (sp
, sp
, cfun
->machine
->eh_epilogue_sp_ofs
));
2559 /* Now emit the return instruction. */
2560 emit_jump_insn (gen_rtx_RETURN (VOIDmode
));
2564 /* A C statement or compound statement to output to FILE some assembler code to
2565 call the profiling subroutine `mcount'. Before calling, the assembler code
2566 must load the address of a counter variable into a register where `mcount'
2567 expects to find the address. The name of this variable is `LP' followed by
2568 the number LABELNO, so you would generate the name using `LP%d' in a
2571 The details of how the address should be passed to `mcount' are determined
2572 by your operating system environment, not by GCC. To figure them out,
2573 compile a small program for profiling using the system's installed C
2574 compiler and look at the assembler code that results. */
2577 d30v_function_profiler (stream
, labelno
)
2579 int labelno ATTRIBUTE_UNUSED
;
2581 fprintf (stream
, "# profile\n");
2585 /* Split a 64 bit item into an upper and a lower part. We specifically do not
2586 want to call gen_highpart/gen_lowpart on CONST_DOUBLEs since it will give us
2587 the wrong part for floating point in cross compilers, and split_double does
2588 not handle registers. Also abort if the register is not a general purpose
2592 d30v_split_double (value
, p_high
, p_low
)
2600 if (!reload_completed
)
2603 switch (GET_CODE (value
))
2606 if (GET_CODE (SUBREG_REG (value
)) != REG
)
2608 offset
= subreg_regno_offset (REGNO (SUBREG_REG (value
)),
2609 GET_MODE (SUBREG_REG (value
)),
2610 SUBREG_BYTE (value
),
2612 value
= SUBREG_REG (value
);
2617 regno
= REGNO (value
) + offset
;
2621 *p_high
= gen_rtx (REG
, SImode
, regno
);
2622 *p_low
= gen_rtx (REG
, SImode
, regno
+1);
2627 split_double (value
, p_high
, p_low
);
2636 /* A C compound statement to output to stdio stream STREAM the assembler syntax
2637 for an instruction operand that is a memory reference whose address is X. X
2638 is an RTL expression. */
2641 d30v_print_operand_address (stream
, x
)
2645 if (GET_CODE (x
) == MEM
)
2648 switch (GET_CODE (x
))
2654 fputs (reg_names
[ REGNO (x
) ], stream
);
2658 fprintf (stream
, "%ld", (long) INTVAL (x
));
2661 /* We wrap simple symbol refs inside a parenthesis, so that a name
2662 like `r2' is not taken for a register name. */
2664 fputs ("(", stream
);
2665 assemble_name (stream
, XSTR (x
, 0));
2666 fputs (")", stream
);
2671 output_addr_const (stream
, x
);
2675 fatal_insn ("bad insn to d30v_print_operand_address:", x
);
2679 /* Print a memory reference suitable for the ld/st instructions. */
2682 d30v_print_operand_memory_reference (stream
, x
)
2689 switch (GET_CODE (x
))
2692 fatal_insn ("bad insn to d30v_print_operand_memory_reference:", x
);
2712 if (GET_CODE (x0
) == CONST_INT
|| GET_CODE (x0
) == SYMBOL_REF
2713 || GET_CODE (x0
) == CONST
|| GET_CODE (x0
) == LABEL_REF
)
2721 fputs ("@(", stream
);
2723 fputs (reg_names
[GPR_R0
], stream
);
2727 const char *suffix
= "";
2730 if (GET_CODE (x0
) == SUBREG
)
2732 offset0
= subreg_regno_offset (REGNO (SUBREG_REG (x0
)),
2733 GET_MODE (SUBREG_REG (x0
)),
2736 x0
= SUBREG_REG (x0
);
2739 if (GET_CODE (x0
) == POST_INC
)
2744 else if (GET_CODE (x0
) == POST_DEC
)
2750 if (GET_CODE (x0
) == REG
&& GPR_P (REGNO (x0
)))
2751 fprintf (stream
, "%s%s", reg_names
[REGNO (x0
) + offset0
], suffix
);
2753 fatal_insn ("bad insn to d30v_print_operand_memory_reference:", x
);
2756 fputs (",", stream
);
2759 fputs (reg_names
[GPR_R0
], stream
);
2765 switch (GET_CODE (x1
))
2768 offset1
= subreg_regno_offset (REGNO (SUBREG_REG (x1
)),
2769 GET_MODE (SUBREG_REG (x1
)),
2772 x1
= SUBREG_REG (x1
);
2773 if (GET_CODE (x1
) != REG
)
2774 fatal_insn ("bad insn to d30v_print_operand_memory_reference:", x
);
2778 fputs (reg_names
[REGNO (x1
) + offset1
], stream
);
2782 fprintf (stream
, "%ld", (long) INTVAL (x1
));
2788 d30v_print_operand_address (stream
, x1
);
2792 fatal_insn ("bad insn to d30v_print_operand_memory_reference:", x
);
2796 fputs (")", stream
);
2800 /* A C compound statement to output to stdio stream STREAM the assembler syntax
2801 for an instruction operand X. X is an RTL expression.
2803 LETTER is a value that can be used to specify one of several ways of
2804 printing the operand. It is used when identical operands must be printed
2805 differently depending on the context. LETTER comes from the `%'
2806 specification that was used to request printing of the operand. If the
2807 specification was just `%DIGIT' then LETTER is 0; if the specification was
2808 `%LTR DIGIT' then LETTER is the ASCII code for LTR.
2810 If X is a register, this macro should print the register's name. The names
2811 can be found in an array `reg_names' whose type is `char *[]'. `reg_names'
2812 is initialized from `REGISTER_NAMES'.
2814 When the machine description has a specification `%PUNCT' (a `%' followed by
2815 a punctuation character), this macro is called with a null pointer for X and
2816 the punctuation character for LETTER.
2818 Standard operand flags that are handled elsewhere:
2819 `=' Output a number unique to each instruction in the compilation.
2820 `a' Substitute an operand as if it were a memory reference.
2821 `c' Omit the syntax that indicates an immediate operand.
2822 `l' Substitute a LABEL_REF into a jump instruction.
2823 `n' Like %cDIGIT, except negate the value before printing.
2825 The d30v specific operand flags are:
2827 `f' Print a SF constant as an int.
2828 `s' Subtract 32 and negate.
2829 `A' Print accumulator number without an `a' in front of it.
2830 `B' Print bit offset for BSET, etc. instructions.
2831 `E' Print u if this is zero extend, nothing if this is sign extend.
2832 `F' Emit /{f,t,x}{f,t,x} for executing a false condition.
2833 `L' Print the lower half of a 64 bit item.
2834 `M' Print a memory reference for ld/st instructions.
2835 `R' Return appropriate cmp instruction for relational test.
2837 `T' Emit /{f,t,x}{f,t,x} for executing a true condition.
2838 `U' Print the upper half of a 64 bit item. */
2841 d30v_print_operand (stream
, x
, letter
)
2846 enum rtx_code code
= (x
) ? GET_CODE (x
) : NIL
;
2847 rtx split_values
[2];
2854 case '.': /* Output r0 */
2855 fputs (reg_names
[GPR_R0
], stream
);
2858 case 'f': /* Print a SF floating constant as an int */
2859 if (GET_CODE (x
) != CONST_DOUBLE
)
2860 fatal_insn ("bad insn to d30v_print_operand, 'f' modifier:", x
);
2862 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
2863 REAL_VALUE_TO_TARGET_SINGLE (rv
, num
);
2864 fprintf (stream
, "%ld", num
);
2867 case 'A': /* Print accumulator number without an `a' in front of it. */
2868 if (GET_CODE (x
) != REG
|| !ACCUM_P (REGNO (x
)))
2869 fatal_insn ("bad insn to d30v_print_operand, 'A' modifier:", x
);
2871 putc ('0' + REGNO (x
) - ACCUM_FIRST
, stream
);
2874 case 'M': /* Print a memory reference for ld/st */
2875 if (GET_CODE (x
) != MEM
)
2876 fatal_insn ("bad insn to d30v_print_operand, 'M' modifier:", x
);
2878 d30v_print_operand_memory_reference (stream
, XEXP (x
, 0));
2881 case 'L': /* print lower part of 64 bit item. */
2882 case 'U': /* print upper part of 64 bit item. */
2883 d30v_split_double (x
, &split_values
[0], &split_values
[1]);
2884 d30v_print_operand (stream
, split_values
[ letter
== 'L' ], '\0');
2887 case ':': /* Output the condition for the current insn. */
2888 x
= current_insn_predicate
;
2894 case 'F': /* Print an appropriate suffix for a false comparison. */
2895 case 'T': /* Print an appropriate suffix for a true comparison. */
2896 /* Note that the sense of appropriate suffix is for conditional execution
2897 and opposite of what branches want. Branches just use the inverse
2899 if ((GET_CODE (x
) == NE
|| GET_CODE (x
) == EQ
)
2900 && GET_MODE (x
) == CCmode
2901 && GET_CODE (XEXP (x
, 0)) == REG
2902 && (GPR_P (REGNO (XEXP (x
, 0))) || BR_FLAG_P (REGNO (XEXP (x
, 0))))
2903 && GET_CODE (XEXP (x
, 1)) == CONST_INT
&& INTVAL (XEXP (x
, 1)) == 0)
2905 int true_false
= (letter
== 'T');
2907 if (GET_CODE (x
) == EQ
)
2908 true_false
= !true_false
;
2910 if (REGNO (XEXP (x
, 0)) == FLAG_F0
)
2911 fprintf (stream
, "/%cx", (true_false
) ? 'f' : 't');
2913 else if (REGNO (XEXP (x
, 0)) == FLAG_F1
)
2914 fprintf (stream
, "/x%c", (true_false
) ? 'f' : 't');
2917 fputs ((true_false
) ? "tnz" : "tzr", stream
);
2920 else if (GET_CODE (x
) == REG
&& REGNO (x
) == FLAG_F0
)
2921 fprintf (stream
, "/%cx", (letter
== 'T') ? 't' : 'f');
2923 else if (GET_CODE (x
) == REG
&& REGNO (x
) == FLAG_F1
)
2924 fprintf (stream
, "/x%c", (letter
== 'T') ? 't' : 'f');
2926 else if (GET_CODE (x
) == REG
&& GPR_P (REGNO (x
)))
2927 fputs ((letter
== 'T') ? "tnz" : "tzr", stream
);
2930 fatal_insn ("bad insn to print_operand, 'F' or 'T' modifier:", x
);
2933 case 'B': /* emit offset single bit to change */
2934 if (GET_CODE (x
) == CONST_INT
&& (log
= exact_log2 (INTVAL (x
))) >= 0)
2935 fprintf (stream
, "%d", 31 - log
);
2937 else if (GET_CODE (x
) == CONST_INT
&& (log
= exact_log2 (~ INTVAL (x
))) >= 0)
2938 fprintf (stream
, "%d", 31 - log
);
2941 fatal_insn ("bad insn to print_operand, 'B' modifier:", x
);
2944 case 'E': /* Print u if this is zero extend, nothing if sign extend. */
2945 if (GET_CODE (x
) == ZERO_EXTEND
)
2947 else if (GET_CODE (x
) != SIGN_EXTEND
)
2948 fatal_insn ("bad insn to print_operand, 'E' modifier:", x
);
2951 case 'R': /* Return appropriate cmp instruction for relational test. */
2952 switch (GET_CODE (x
))
2954 case EQ
: fputs ("cmpeq", stream
); break;
2955 case NE
: fputs ("cmpne", stream
); break;
2956 case LT
: fputs ("cmplt", stream
); break;
2957 case LE
: fputs ("cmple", stream
); break;
2958 case GT
: fputs ("cmpgt", stream
); break;
2959 case GE
: fputs ("cmpge", stream
); break;
2960 case LTU
: fputs ("cmpult", stream
); break;
2961 case LEU
: fputs ("cmpule", stream
); break;
2962 case GTU
: fputs ("cmpugt", stream
); break;
2963 case GEU
: fputs ("cmpuge", stream
); break;
2966 fatal_insn ("bad insn to print_operand, 'R' modifier:", x
);
2970 case 's': /* Subtract 32 and negate (for 64 bit shifts). */
2971 if (GET_CODE (x
) == CONST_INT
)
2972 fprintf (stream
, "%d", (int) (32 - INTVAL (x
)));
2975 fatal_insn ("bad insn to print_operand, 's' modifier:", x
);
2978 case 'S': /* Subtract 32. */
2979 if (GET_CODE (x
) == CONST_INT
)
2980 fprintf (stream
, "%d", (int)(INTVAL (x
) - 32));
2983 fatal_insn ("bad insn to print_operand, 's' modifier:", x
);
2987 case 'z': /* If arg is 0 or 0.0, print r0, otherwise print as normal */
2988 if ((GET_CODE (x
) == CONST_INT
&& INTVAL (x
) == 0)
2989 || (GET_CODE (x
) == CONST_DOUBLE
&& CONST_DOUBLE_LOW (x
) == 0
2990 && CONST_DOUBLE_HIGH (x
) == 0))
2992 fputs (reg_names
[GPR_FIRST
], stream
);
3000 fputs (reg_names
[ REGNO (x
) ], stream
);
3002 else if (code
== CONST_INT
)
3003 fprintf (stream
, "%d", (int)INTVAL (x
));
3005 else if (code
== MEM
)
3006 d30v_print_operand_address (stream
, XEXP (x
, 0));
3008 else if (CONSTANT_ADDRESS_P (x
))
3009 d30v_print_operand_address (stream
, x
);
3012 fatal_insn ("bad insn in d30v_print_operand, 0 case", x
);
3020 sprintf (buf
, "invalid asm template character '%%%c'", letter
);
3021 fatal_insn (buf
, x
);
3027 /* A C expression for the size in bytes of the trampoline, as an integer. */
3030 d30v_trampoline_size ()
3036 /* Create a long instruction for building up a trampoline. */
3039 d30v_build_long_insn (high_bits
, low_bits
, imm
, mem
)
3040 HOST_WIDE_INT high_bits
;
3041 HOST_WIDE_INT low_bits
;
3045 rtx reg
= gen_reg_rtx (DImode
);
3046 rtx high_word
= gen_highpart (SImode
, reg
);
3047 rtx low_word
= gen_lowpart (SImode
, reg
);
3048 rtx tmp1
= gen_reg_rtx (SImode
);
3049 rtx tmp2
= gen_reg_rtx (SImode
);
3050 rtx tmp3
= gen_reg_rtx (SImode
);
3051 rtx tmp4
= gen_reg_rtx (SImode
);
3052 rtx tmp5
= gen_reg_rtx (SImode
);
3053 rtx tmp6
= gen_reg_rtx (SImode
);
3055 imm
= force_reg (SImode
, imm
);
3057 /* Stuff top 6 bits of immediate value into high word */
3058 emit_insn (gen_lshrsi3 (tmp1
, imm
, GEN_INT (26)));
3059 emit_insn (gen_andsi3 (tmp2
, tmp1
, GEN_INT (0x3F)));
3060 emit_insn (gen_iorsi3 (high_word
, tmp2
, GEN_INT (high_bits
)));
3062 /* Now get the next 8 bits for building the low word */
3063 emit_insn (gen_andsi3 (tmp3
, imm
, GEN_INT (0x03FC0000)));
3064 emit_insn (gen_ashlsi3 (tmp4
, tmp3
, GEN_INT (2)));
3066 /* And the bottom 18 bits */
3067 emit_insn (gen_andsi3 (tmp5
, imm
, GEN_INT (0x0003FFFF)));
3068 emit_insn (gen_iorsi3 (tmp6
, tmp4
, tmp5
));
3069 emit_insn (gen_iorsi3 (low_word
, tmp6
, GEN_INT (low_bits
)));
3071 /* Store the instruction */
3072 emit_insn (gen_movdi (mem
, reg
));
3076 /* A C statement to initialize the variable parts of a trampoline. ADDR is an
3077 RTX for the address of the trampoline; FNADDR is an RTX for the address of
3078 the nested function; STATIC_CHAIN is an RTX for the static chain value that
3079 should be passed to the function when it is called. */
3082 d30v_initialize_trampoline (addr
, fnaddr
, static_chain
)
3087 /* The instruction space can only be accessed by ld2w/st2w.
3088 Generate on the fly:
3089 or r18,r0,<static-chain>
3091 d30v_build_long_insn (0x83A80000 | ((STATIC_CHAIN_REGNUM
- GPR_FIRST
) << 12),
3092 0x80000000, static_chain
,
3093 gen_rtx (MEM
, DImode
, addr
));
3095 d30v_build_long_insn (0x80180000, 0x80000000, fnaddr
,
3096 gen_rtx (MEM
, DImode
, plus_constant (addr
, 8)));
3100 /* A C compound statement with a conditional `goto LABEL;' executed if X (an
3101 RTX) is a legitimate memory address on the target machine for a memory
3102 operand of mode MODE. */
3104 #define XREGNO_OK_FOR_BASE_P(REGNO, STRICT_P) \
3106 ? REGNO_OK_FOR_BASE_P (REGNO) \
3107 : GPR_OR_PSEUDO_P (REGNO))
3110 d30v_legitimate_address_p (mode
, x
, strict_p
)
3111 enum machine_mode mode
;
3118 switch (GET_CODE (x
))
3125 if (GET_CODE (x
) != REG
)
3131 ret
= XREGNO_OK_FOR_BASE_P (REGNO (x
), strict_p
);
3138 if (GET_CODE (x0
) == SUBREG
)
3139 x0
= SUBREG_REG (x0
);
3141 if (GET_CODE (x0
) == POST_INC
|| GET_CODE (x0
) == POST_DEC
)
3144 if (GET_CODE (x0
) != REG
|| !XREGNO_OK_FOR_BASE_P (REGNO (x0
), strict_p
))
3147 switch (GET_CODE (x1
))
3153 x1
= SUBREG_REG (x1
);
3154 if (GET_CODE (x1
) != REG
)
3160 ret
= XREGNO_OK_FOR_BASE_P (REGNO (x1
), strict_p
);
3164 ret
= (IN_RANGE_P (INTVAL (x1
), -32, 31)) ? 1 : 2;
3176 ret
= (IN_RANGE_P (INTVAL (x
), -32, 31)) ? 1 : 2;
3188 if (GET_CODE (x0
) == REG
&& XREGNO_OK_FOR_BASE_P (REGNO (x0
), strict_p
))
3193 if (TARGET_DEBUG_ADDR
)
3195 fprintf (stderr
, "\n========== GO_IF_LEGITIMATE_ADDRESS, mode = %s, result = %d, addresses are %sstrict\n",
3196 GET_MODE_NAME (mode
), ret
, (strict_p
) ? "" : "not ");
3204 /* A C compound statement that attempts to replace X with a valid memory
3205 address for an operand of mode MODE. WIN will be a C statement label
3206 elsewhere in the code; the macro definition may use
3208 GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN);
3210 to avoid further processing if the address has become legitimate.
3212 X will always be the result of a call to `break_out_memory_refs', and OLDX
3213 will be the operand that was given to that function to produce X.
3215 The code generated by this macro should not alter the substructure of X. If
3216 it transforms X into a more legitimate form, it should assign X (which will
3217 always be a C variable) a new value.
3219 It is not necessary for this macro to come up with a legitimate address.
3220 The compiler has standard ways of doing so in all cases. In fact, it is
3221 safe for this macro to do nothing. But often a machine-dependent strategy
3222 can generate better code. */
3225 d30v_legitimize_address (x
, oldx
, mode
, strict_p
)
3227 rtx oldx ATTRIBUTE_UNUSED
;
3228 enum machine_mode mode ATTRIBUTE_UNUSED
;
3229 int strict_p ATTRIBUTE_UNUSED
;
3233 if (TARGET_DEBUG_ADDR
)
3237 fprintf (stderr
, "\n========== LEGITIMIZE_ADDRESS, transformed:\n");
3239 fprintf (stderr
, "\ninto:\n");
3244 fprintf (stderr
, "\n========== LEGITIMIZE_ADDRESS, did nothing with:\n");
3253 /* A C statement or compound statement with a conditional `goto LABEL;'
3254 executed if memory address X (an RTX) can have different meanings depending
3255 on the machine mode of the memory reference it is used for or if the address
3256 is valid for some modes but not others.
3258 Autoincrement and autodecrement addresses typically have mode-dependent
3259 effects because the amount of the increment or decrement is the size of the
3260 operand being addressed. Some machines have other mode-dependent addresses.
3261 Many RISC machines have no mode-dependent addresses.
3263 You may assume that ADDR is a valid address for the machine. */
3266 d30v_mode_dependent_address_p (addr
)
3269 switch (GET_CODE (addr
))
3283 /* Generate the appropriate comparison code for a test. */
3286 d30v_emit_comparison (test_int
, result
, arg1
, arg2
)
3292 enum rtx_code test
= (enum rtx_code
) test_int
;
3293 enum machine_mode mode
= GET_MODE (arg1
);
3294 rtx rtx_test
= gen_rtx (SET
, VOIDmode
, result
, gen_rtx (test
, CCmode
, arg1
, arg2
));
3297 || (mode
== DImode
&& (test
== EQ
|| test
== NE
))
3298 || (mode
== DImode
&& (test
== LT
|| test
== GE
)
3299 && GET_CODE (arg2
) == CONST_INT
&& INTVAL (arg2
) == 0))
3302 else if (mode
== DImode
)
3303 return gen_rtx (PARALLEL
, VOIDmode
,
3306 gen_rtx (CLOBBER
, VOIDmode
,
3307 gen_reg_rtx (CCmode
))));
3310 fatal_insn ("d30v_emit_comparison", rtx_test
);
3314 /* Return appropriate code to move 2 words. Since DImode registers must start
3315 on even register numbers, there is no possibility of overlap. */
3318 d30v_move_2words (operands
, insn
)
3322 if (GET_CODE (operands
[0]) == REG
&& GPR_P (REGNO (operands
[0])))
3324 if (GET_CODE (operands
[1]) == REG
&& GPR_P (REGNO (operands
[1])))
3325 return "or %U0,%.,%U1\n\tor %L0,%.,%L1";
3327 else if (GET_CODE (operands
[1]) == REG
&& ACCUM_P (REGNO (operands
[1])))
3328 return "mvfacc %L0,%1,%.\n\tmvfacc %U0,%1,32";
3330 else if (GET_CODE (operands
[1]) == MEM
)
3331 return "ld2w %0,%M1";
3333 else if (GET_CODE (operands
[1]) == CONST_INT
3334 || GET_CODE (operands
[1]) == CONST_DOUBLE
)
3335 return "or %U0,%.,%U1\n\tor %L0,%.,%L1";
3338 else if (GET_CODE (operands
[0]) == REG
&& ACCUM_P (REGNO (operands
[0])))
3340 if (GET_CODE (operands
[1]) == REG
3341 && GPR_P (REGNO (operands
[1])))
3342 return "mvtacc %0,%U1,%L1";
3344 if (GET_CODE (operands
[1]) == CONST_INT
3345 && INTVAL (operands
[1]) == 0)
3346 return "mvtacc %0,%.,%.";
3349 else if (GET_CODE (operands
[0]) == MEM
3350 && GET_CODE (operands
[1]) == REG
3351 && GPR_P (REGNO (operands
[1])))
3352 return "st2w %1,%M0";
3354 fatal_insn ("bad call to d30v_move_2words", insn
);
3358 /* Emit the code to do a conditional move instruction. Return FALSE
3359 if the conditional move could not be executed. */
3362 d30v_emit_cond_move (dest
, test
, true_value
, false_value
)
3369 enum machine_mode mode
= GET_MODE (dest
);
3370 int two_mem_moves_p
= FALSE
;
3372 if (GET_CODE (dest
) == MEM
)
3374 if (!reg_or_0_operand (true_value
, mode
))
3377 if (rtx_equal_p (dest
, false_value
))
3378 two_mem_moves_p
= TRUE
;
3380 else if (!reg_or_0_operand (false_value
, mode
))
3384 /* We used to try to optimize setting 0/1 by using mvfsys, but that turns out
3385 to be slower than just doing the conditional execution. */
3387 br_reg
= gen_reg_rtx (CCmode
);
3388 emit_insn (d30v_emit_comparison (GET_CODE (test
), br_reg
,
3389 d30v_compare_op0
, d30v_compare_op1
));
3391 if (!two_mem_moves_p
)
3392 emit_insn (gen_rtx_SET (VOIDmode
,
3394 gen_rtx_IF_THEN_ELSE (mode
,
3395 gen_rtx_NE (CCmode
, br_reg
,
3401 /* Emit conditional stores as two separate stores. This avoids a problem
3402 where you have a conditional store, and one of the arms of the
3403 conditional store is spilled to memory. */
3404 emit_insn (gen_rtx_SET (VOIDmode
,
3406 gen_rtx_IF_THEN_ELSE (mode
,
3407 gen_rtx_NE (CCmode
, br_reg
,
3412 emit_insn (gen_rtx_SET (VOIDmode
,
3414 gen_rtx_IF_THEN_ELSE (mode
,
3415 gen_rtx_EQ (CCmode
, br_reg
,
3426 /* A C statement (sans semicolon) to update the integer variable COST based on
3427 the relationship between INSN that is dependent on DEP_INSN through the
3428 dependence LINK. The default is to make no adjustment to COST. This can be
3429 used for example to specify to the scheduler that an output- or
3430 anti-dependence does not incur the same cost as a data-dependence. */
3432 /* For the d30v, try to insure that the source operands for a load/store are
3433 set 2 cycles before the memory reference. */
3436 d30v_adjust_cost (insn
, link
, dep_insn
, cost
)
3438 rtx link ATTRIBUTE_UNUSED
;
3442 rtx set_dep
= single_set (dep_insn
);
3443 rtx set_insn
= single_set (insn
);
3445 if (set_dep
!= NULL_RTX
&& set_insn
!= NULL_RTX
3446 && GET_CODE (SET_DEST (set_dep
)) == REG
)
3448 rtx reg
= SET_DEST (set_dep
);
3451 if ((GET_CODE (mem
= SET_SRC (set_insn
)) == MEM
3452 && reg_mentioned_p (reg
, XEXP (mem
, 0)))
3453 || (GET_CODE (mem
= SET_DEST (set_insn
)) == MEM
3454 && reg_mentioned_p (reg
, XEXP (mem
, 0))))
3463 /* Function which returns the number of insns that can be
3464 scheduled in the same machine cycle. This must be constant
3465 over an entire compilation. The default is 1. */
3473 /* Routine to allocate, mark and free a per-function,
3474 machine specific structure. */
3476 static struct machine_function
*
3477 d30v_init_machine_status ()
3479 return ggc_alloc_cleared (sizeof (machine_function
));
3482 /* Do anything needed before RTL is emitted for each function. */
3485 d30v_init_expanders ()
3487 /* Arrange to save and restore machine status around nested functions. */
3488 init_machine_status
= d30v_init_machine_status
;
3491 /* Find the current function's return address.
3493 ??? It would be better to arrange things such that if we would ordinarily
3494 have been a leaf function and we didn't spill the hard reg that we
3495 wouldn't have to save the register in the prolog. But it's not clear
3496 how to get the right information at the right time. */
3501 return get_hard_reg_initial_val (Pmode
, GPR_LINK
);
3505 d30v_rtx_costs (x
, code
, outer_code
, total
)
3508 int outer_code ATTRIBUTE_UNUSED
;
3514 *total
= COSTS_N_INSNS ((GET_CODE (XEXP (x
, 1)) == CONST_INT
3515 && exact_log2 (INTVAL (XEXP (x
, 1))) >= 0)