1 /* Subroutines for insn-output.c for NEC V850 series
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by Jeff Law (law@cygnus.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
28 #include "hard-reg-set.h"
30 #include "insn-config.h"
31 #include "conditions.h"
33 #include "insn-attr.h"
42 #include "integrate.h"
45 #include "target-def.h"
48 #define streq(a,b) (strcmp (a, b) == 0)
51 /* Function prototypes for stupid compilers: */
52 static void const_double_split
PARAMS ((rtx
, HOST_WIDE_INT
*, HOST_WIDE_INT
*));
53 static int const_costs_int
PARAMS ((HOST_WIDE_INT
, int));
54 static void substitute_ep_register
PARAMS ((rtx
, rtx
, int, int, rtx
*, rtx
*));
55 static int ep_memory_offset
PARAMS ((enum machine_mode
, int));
56 static void v850_set_data_area
PARAMS ((tree
, v850_data_area
));
57 const struct attribute_spec v850_attribute_table
[];
58 static tree v850_handle_interrupt_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
59 static tree v850_handle_data_area_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
60 static void v850_insert_attributes
PARAMS ((tree
, tree
*));
62 /* True if the current function has anonymous arguments. */
63 int current_function_anonymous_args
;
65 /* Information about the various small memory areas. */
66 struct small_memory_info small_memory
[ (int)SMALL_MEMORY_max
] =
68 /* name value max physical max */
69 { "tda", (char *)0, 0, 256 },
70 { "sda", (char *)0, 0, 65536 },
71 { "zda", (char *)0, 0, 32768 },
74 /* Names of the various data areas used on the v850. */
75 tree GHS_default_section_names
[(int) COUNT_OF_GHS_SECTION_KINDS
];
76 tree GHS_current_section_names
[(int) COUNT_OF_GHS_SECTION_KINDS
];
78 /* Track the current data area set by the data area pragma (which
79 can be nested). Tested by check_default_data_area. */
80 data_area_stack_element
* data_area_stack
= NULL
;
82 /* True if we don't need to check any more if the current
83 function is an interrupt handler. */
84 static int v850_interrupt_cache_p
= FALSE
;
86 /* Whether current function is an interrupt handler. */
87 static int v850_interrupt_p
= FALSE
;
89 /* Initialize the GCC target structure. */
90 #undef TARGET_ASM_ALIGNED_HI_OP
91 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
93 #undef TARGET_ATTRIBUTE_TABLE
94 #define TARGET_ATTRIBUTE_TABLE v850_attribute_table
96 #undef TARGET_INSERT_ATTRIBUTES
97 #define TARGET_INSERT_ATTRIBUTES v850_insert_attributes
99 struct gcc_target targetm
= TARGET_INITIALIZER
;
101 /* Sometimes certain combinations of command options do not make
102 sense on a particular target machine. You can define a macro
103 `OVERRIDE_OPTIONS' to take account of this. This macro, if
104 defined, is executed once just after all the command options have
107 Don't use this macro to turn on various extra optimizations for
108 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
114 extern int atoi
PARAMS ((const char *));
116 /* Parse -m{s,t,z}da=nnn switches */
117 for (i
= 0; i
< (int)SMALL_MEMORY_max
; i
++)
119 if (small_memory
[i
].value
)
121 if (!ISDIGIT (*small_memory
[i
].value
))
122 error ("%s=%s is not numeric",
123 small_memory
[i
].name
,
124 small_memory
[i
].value
);
127 small_memory
[i
].max
= atoi (small_memory
[i
].value
);
128 if (small_memory
[i
].max
> small_memory
[i
].physical_max
)
129 error ("%s=%s is too large",
130 small_memory
[i
].name
,
131 small_memory
[i
].value
);
138 /* Output assembly code for the start of the file. */
141 asm_file_start (file
)
144 output_file_directive (file
, main_input_filename
);
148 /* Return an RTX to represent where a value with mode MODE will be returned
149 from a function. If the result is 0, the argument is pushed. */
152 function_arg (cum
, mode
, type
, named
)
153 CUMULATIVE_ARGS
*cum
;
154 enum machine_mode mode
;
161 if (TARGET_GHS
&& !named
)
165 size
= int_size_in_bytes (type
);
167 size
= GET_MODE_SIZE (mode
);
170 align
= TYPE_ALIGN (type
) / BITS_PER_UNIT
;
174 cum
->nbytes
= (cum
->nbytes
+ align
- 1) &~(align
- 1);
176 if (cum
->nbytes
> 4 * UNITS_PER_WORD
)
179 if (type
== NULL_TREE
180 && cum
->nbytes
+ size
> 4 * UNITS_PER_WORD
)
183 switch (cum
->nbytes
/ UNITS_PER_WORD
)
186 result
= gen_rtx_REG (mode
, 6);
189 result
= gen_rtx_REG (mode
, 7);
192 result
= gen_rtx_REG (mode
, 8);
195 result
= gen_rtx_REG (mode
, 9);
205 /* Return the number of words which must be put into registers
206 for values which are part in registers and part in memory. */
209 function_arg_partial_nregs (cum
, mode
, type
, named
)
210 CUMULATIVE_ARGS
*cum
;
211 enum machine_mode mode
;
217 if (TARGET_GHS
&& !named
)
221 size
= int_size_in_bytes (type
);
223 size
= GET_MODE_SIZE (mode
);
226 align
= TYPE_ALIGN (type
) / BITS_PER_UNIT
;
230 cum
->nbytes
= (cum
->nbytes
+ align
- 1) &~(align
- 1);
232 if (cum
->nbytes
> 4 * UNITS_PER_WORD
)
235 if (cum
->nbytes
+ size
<= 4 * UNITS_PER_WORD
)
238 if (type
== NULL_TREE
239 && cum
->nbytes
+ size
> 4 * UNITS_PER_WORD
)
242 return (4 * UNITS_PER_WORD
- cum
->nbytes
) / UNITS_PER_WORD
;
246 /* Return the high and low words of a CONST_DOUBLE */
249 const_double_split (x
, p_high
, p_low
)
251 HOST_WIDE_INT
*p_high
;
252 HOST_WIDE_INT
*p_low
;
254 if (GET_CODE (x
) == CONST_DOUBLE
)
259 switch (GET_MODE (x
))
262 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
263 REAL_VALUE_TO_TARGET_DOUBLE (rv
, t
);
264 *p_high
= t
[1]; /* since v850 is little endian */
265 *p_low
= t
[0]; /* high is second word */
269 REAL_VALUE_FROM_CONST_DOUBLE (rv
, x
);
270 REAL_VALUE_TO_TARGET_SINGLE (rv
, *p_high
);
276 *p_high
= CONST_DOUBLE_HIGH (x
);
277 *p_low
= CONST_DOUBLE_LOW (x
);
285 fatal_insn ("const_double_split got a bad insn:", x
);
289 /* Return the cost of the rtx R with code CODE. */
292 const_costs_int (value
, zero_cost
)
296 if (CONST_OK_FOR_I (value
))
298 else if (CONST_OK_FOR_J (value
))
300 else if (CONST_OK_FOR_K (value
))
311 HOST_WIDE_INT high
, low
;
316 return const_costs_int (INTVAL (r
), 0);
319 const_double_split (r
, &high
, &low
);
320 if (GET_MODE (r
) == SFmode
)
321 return const_costs_int (high
, 1);
323 return const_costs_int (high
, 1) + const_costs_int (low
, 1);
339 /* Print operand X using operand code CODE to assembly language output file
343 print_operand (file
, x
, code
)
348 HOST_WIDE_INT high
, low
;
353 /* We use 'c' operands with symbols for .vtinherit */
354 if (GET_CODE (x
) == SYMBOL_REF
)
356 output_addr_const(file
, x
);
363 switch ((code
== 'B' || code
== 'C')
364 ? reverse_condition (GET_CODE (x
)) : GET_CODE (x
))
367 if (code
== 'c' || code
== 'C')
368 fprintf (file
, "nz");
370 fprintf (file
, "ne");
373 if (code
== 'c' || code
== 'C')
379 fprintf (file
, "ge");
382 fprintf (file
, "gt");
385 fprintf (file
, "le");
388 fprintf (file
, "lt");
391 fprintf (file
, "nl");
397 fprintf (file
, "nh");
406 case 'F': /* high word of CONST_DOUBLE */
407 if (GET_CODE (x
) == CONST_INT
)
408 fprintf (file
, "%d", (INTVAL (x
) >= 0) ? 0 : -1);
409 else if (GET_CODE (x
) == CONST_DOUBLE
)
411 const_double_split (x
, &high
, &low
);
412 fprintf (file
, "%ld", (long) high
);
417 case 'G': /* low word of CONST_DOUBLE */
418 if (GET_CODE (x
) == CONST_INT
)
419 fprintf (file
, "%ld", (long) INTVAL (x
));
420 else if (GET_CODE (x
) == CONST_DOUBLE
)
422 const_double_split (x
, &high
, &low
);
423 fprintf (file
, "%ld", (long) low
);
429 fprintf (file
, "%d\n", INTVAL (x
) & 0xffff);
432 fprintf (file
, "%d", exact_log2 (INTVAL (x
)));
435 if (special_symbolref_operand (x
, VOIDmode
))
439 if (GET_CODE (x
) == SYMBOL_REF
)
441 else if (GET_CODE (x
) == CONST
)
442 name
= XSTR (XEXP (XEXP (x
, 0), 0), 0);
446 if (ZDA_NAME_P (name
))
447 fprintf (file
, "zdaoff");
448 else if (SDA_NAME_P (name
))
449 fprintf (file
, "sdaoff");
450 else if (TDA_NAME_P (name
))
451 fprintf (file
, "tdaoff");
459 if (special_symbolref_operand (x
, VOIDmode
))
460 output_addr_const (file
, x
);
465 if (special_symbolref_operand (x
, VOIDmode
))
469 if (GET_CODE (x
) == SYMBOL_REF
)
471 else if (GET_CODE (x
) == CONST
)
472 name
= XSTR (XEXP (XEXP (x
, 0), 0), 0);
476 if (ZDA_NAME_P (name
))
477 fprintf (file
, "r0");
478 else if (SDA_NAME_P (name
))
479 fprintf (file
, "gp");
480 else if (TDA_NAME_P (name
))
481 fprintf (file
, "ep");
488 case 'R': /* 2nd word of a double. */
489 switch (GET_CODE (x
))
492 fprintf (file
, reg_names
[REGNO (x
) + 1]);
495 x
= XEXP (adjust_address (x
, SImode
, 4), 0);
496 print_operand_address (file
, x
);
497 if (GET_CODE (x
) == CONST_INT
)
498 fprintf (file
, "[r0]");
507 /* if it's a reference to a TDA variable, use sst/sld vs. st/ld */
508 if (GET_CODE (x
) == MEM
&& ep_memory_operand (x
, GET_MODE (x
), FALSE
))
515 /* Like an 'S' operand above, but for unsigned loads only. */
516 if (GET_CODE (x
) == MEM
&& ep_memory_operand (x
, GET_MODE (x
), TRUE
))
521 case 'W': /* print the instruction suffix */
522 switch (GET_MODE (x
))
527 case QImode
: fputs (".b", file
); break;
528 case HImode
: fputs (".h", file
); break;
529 case SImode
: fputs (".w", file
); break;
530 case SFmode
: fputs (".w", file
); break;
533 case '.': /* register r0 */
534 fputs (reg_names
[0], file
);
536 case 'z': /* reg or zero */
538 fputs (reg_names
[0], file
);
539 else if (GET_CODE (x
) == REG
)
540 fputs (reg_names
[REGNO (x
)], file
);
545 switch (GET_CODE (x
))
548 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
549 output_address (gen_rtx_PLUS (SImode
, gen_rtx (REG
, SImode
, 0),
552 output_address (XEXP (x
, 0));
556 fputs (reg_names
[REGNO (x
)], file
);
559 fputs (reg_names
[subreg_regno (x
)], file
);
566 print_operand_address (file
, x
);
577 /* Output assembly language output for the address ADDR to FILE. */
580 print_operand_address (file
, addr
)
584 switch (GET_CODE (addr
))
587 fprintf (file
, "0[");
588 print_operand (file
, addr
, 0);
592 if (GET_CODE (XEXP (addr
, 0)) == REG
)
595 fprintf (file
, "lo(");
596 print_operand (file
, XEXP (addr
, 1), 0);
597 fprintf (file
, ")[");
598 print_operand (file
, XEXP (addr
, 0), 0);
603 if (GET_CODE (XEXP (addr
, 0)) == REG
604 || GET_CODE (XEXP (addr
, 0)) == SUBREG
)
607 print_operand (file
, XEXP (addr
, 1), 0);
609 print_operand (file
, XEXP (addr
, 0), 0);
614 print_operand (file
, XEXP (addr
, 0), 0);
616 print_operand (file
, XEXP (addr
, 1), 0);
620 if (ENCODED_NAME_P (XSTR (addr
, 0)))
622 const char *name
= XSTR (addr
, 0);
623 const char *off_name
;
624 const char *reg_name
;
626 if (ZDA_NAME_P (name
))
631 else if (SDA_NAME_P (name
))
636 else if (TDA_NAME_P (name
))
644 fprintf (file
, "%s(", off_name
);
645 output_addr_const (file
, addr
);
646 fprintf (file
, ")[%s]", reg_name
);
649 output_addr_const (file
, addr
);
652 if (special_symbolref_operand (addr
, VOIDmode
))
654 const char *name
= XSTR (XEXP (XEXP (addr
, 0), 0), 0);
655 const char *off_name
;
656 const char *reg_name
;
658 if (ZDA_NAME_P (name
))
663 else if (SDA_NAME_P (name
))
668 else if (TDA_NAME_P (name
))
676 fprintf (file
, "%s(", off_name
);
677 output_addr_const (file
, addr
);
678 fprintf (file
, ")[%s]", reg_name
);
681 output_addr_const (file
, addr
);
684 output_addr_const (file
, addr
);
690 /* Return appropriate code to load up a 1, 2, or 4 integer/floating
694 output_move_single (operands
)
697 rtx dst
= operands
[0];
698 rtx src
= operands
[1];
705 else if (GET_CODE (src
) == CONST_INT
)
707 HOST_WIDE_INT value
= INTVAL (src
);
709 if (CONST_OK_FOR_J (value
)) /* signed 5 bit immediate */
712 else if (CONST_OK_FOR_K (value
)) /* signed 16 bit immediate */
713 return "movea lo(%1),%.,%0";
715 else if (CONST_OK_FOR_L (value
)) /* upper 16 bits were set */
716 return "movhi hi(%1),%.,%0";
718 else /* random constant */
719 return "movhi hi(%1),%.,%0\n\tmovea lo(%1),%0,%0";
722 else if (GET_CODE (src
) == CONST_DOUBLE
&& GET_MODE (src
) == SFmode
)
724 HOST_WIDE_INT high
, low
;
726 const_double_split (src
, &high
, &low
);
727 if (CONST_OK_FOR_J (high
)) /* signed 5 bit immediate */
730 else if (CONST_OK_FOR_K (high
)) /* signed 16 bit immediate */
731 return "movea lo(%F1),%.,%0";
733 else if (CONST_OK_FOR_L (high
)) /* upper 16 bits were set */
734 return "movhi hi(%F1),%.,%0";
736 else /* random constant */
737 return "movhi hi(%F1),%.,%0\n\tmovea lo(%F1),%0,%0";
740 else if (GET_CODE (src
) == MEM
)
741 return "%S1ld%W1 %1,%0";
743 else if (special_symbolref_operand (src
, VOIDmode
))
744 return "movea %O1(%P1),%Q1,%0";
746 else if (GET_CODE (src
) == LABEL_REF
747 || GET_CODE (src
) == SYMBOL_REF
748 || GET_CODE (src
) == CONST
)
750 return "movhi hi(%1),%.,%0\n\tmovea lo(%1),%0,%0";
753 else if (GET_CODE (src
) == HIGH
)
754 return "movhi hi(%1),%.,%0";
756 else if (GET_CODE (src
) == LO_SUM
)
758 operands
[2] = XEXP (src
, 0);
759 operands
[3] = XEXP (src
, 1);
760 return "movea lo(%3),%2,%0";
764 else if (GET_CODE (dst
) == MEM
)
767 return "%S0st%W0 %1,%0";
769 else if (GET_CODE (src
) == CONST_INT
&& INTVAL (src
) == 0)
770 return "%S0st%W0 %.,%0";
772 else if (GET_CODE (src
) == CONST_DOUBLE
773 && CONST0_RTX (GET_MODE (dst
)) == src
)
774 return "%S0st%W0 %.,%0";
777 fatal_insn ("output_move_single:", gen_rtx_SET (VOIDmode
, dst
, src
));
782 /* Return appropriate code to load up an 8 byte integer or
783 floating point value */
786 output_move_double (operands
)
789 enum machine_mode mode
= GET_MODE (operands
[0]);
790 rtx dst
= operands
[0];
791 rtx src
= operands
[1];
793 if (register_operand (dst
, mode
)
794 && register_operand (src
, mode
))
796 if (REGNO (src
) + 1 == REGNO (dst
))
797 return "mov %R1,%R0\n\tmov %1,%0";
799 return "mov %1,%0\n\tmov %R1,%R0";
803 if (GET_CODE (dst
) == MEM
804 && ((GET_CODE (src
) == CONST_INT
&& INTVAL (src
) == 0)
805 || (GET_CODE (src
) == CONST_DOUBLE
&& CONST_DOUBLE_OK_FOR_G (src
))))
806 return "st.w %.,%0\n\tst.w %.,%R0";
808 if (GET_CODE (src
) == CONST_INT
|| GET_CODE (src
) == CONST_DOUBLE
)
810 HOST_WIDE_INT high_low
[2];
814 if (GET_CODE (src
) == CONST_DOUBLE
)
815 const_double_split (src
, &high_low
[1], &high_low
[0]);
818 high_low
[0] = INTVAL (src
);
819 high_low
[1] = (INTVAL (src
) >= 0) ? 0 : -1;
822 for (i
= 0; i
< 2; i
++)
824 xop
[0] = gen_rtx_REG (SImode
, REGNO (dst
)+i
);
825 xop
[1] = GEN_INT (high_low
[i
]);
826 output_asm_insn (output_move_single (xop
), xop
);
832 if (GET_CODE (src
) == MEM
)
835 int dreg
= REGNO (dst
);
836 rtx inside
= XEXP (src
, 0);
838 if (GET_CODE (inside
) == REG
)
839 ptrreg
= REGNO (inside
);
840 else if (GET_CODE (inside
) == SUBREG
)
841 ptrreg
= subreg_regno (inside
);
842 else if (GET_CODE (inside
) == PLUS
)
843 ptrreg
= REGNO (XEXP (inside
, 0));
844 else if (GET_CODE (inside
) == LO_SUM
)
845 ptrreg
= REGNO (XEXP (inside
, 0));
848 return "ld.w %R1,%R0\n\tld.w %1,%0";
851 if (GET_CODE (src
) == MEM
)
852 return "ld.w %1,%0\n\tld.w %R1,%R0";
854 if (GET_CODE (dst
) == MEM
)
855 return "st.w %1,%0\n\tst.w %R1,%R0";
857 return "mov %1,%0\n\tmov %R1,%R0";
861 /* Return maximum offset supported for a short EP memory reference of mode
862 MODE and signedness UNSIGNEDP. */
865 ep_memory_offset (mode
, unsignedp
)
866 enum machine_mode mode
;
867 int ATTRIBUTE_UNUSED unsignedp
;
874 max_offset
= (1 << 7);
878 max_offset
= (1 << 8);
883 max_offset
= (1 << 8);
893 /* Return true if OP is a valid short EP memory reference */
896 ep_memory_operand (op
, mode
, unsigned_load
)
898 enum machine_mode mode
;
905 if (GET_CODE (op
) != MEM
)
908 max_offset
= ep_memory_offset (mode
, unsigned_load
);
910 mask
= GET_MODE_SIZE (mode
) - 1;
913 if (GET_CODE (addr
) == CONST
)
914 addr
= XEXP (addr
, 0);
916 switch (GET_CODE (addr
))
922 return TDA_NAME_P (XSTR (addr
, 0));
925 return REGNO (addr
) == EP_REGNUM
;
928 op0
= XEXP (addr
, 0);
929 op1
= XEXP (addr
, 1);
930 if (GET_CODE (op1
) == CONST_INT
931 && INTVAL (op1
) < max_offset
933 && (INTVAL (op1
) & mask
) == 0)
935 if (GET_CODE (op0
) == REG
&& REGNO (op0
) == EP_REGNUM
)
938 if (GET_CODE (op0
) == SYMBOL_REF
&& TDA_NAME_P (XSTR (op0
, 0)))
947 /* Return true if OP is either a register or 0 */
950 reg_or_0_operand (op
, mode
)
952 enum machine_mode mode
;
954 if (GET_CODE (op
) == CONST_INT
)
955 return INTVAL (op
) == 0;
957 else if (GET_CODE (op
) == CONST_DOUBLE
)
958 return CONST_DOUBLE_OK_FOR_G (op
);
961 return register_operand (op
, mode
);
964 /* Return true if OP is either a register or a signed five bit integer */
967 reg_or_int5_operand (op
, mode
)
969 enum machine_mode mode
;
971 if (GET_CODE (op
) == CONST_INT
)
972 return CONST_OK_FOR_J (INTVAL (op
));
975 return register_operand (op
, mode
);
978 /* Return true if OP is a valid call operand. */
981 call_address_operand (op
, mode
)
983 enum machine_mode ATTRIBUTE_UNUSED mode
;
985 /* Only registers are valid call operands if TARGET_LONG_CALLS. */
986 if (TARGET_LONG_CALLS
)
987 return GET_CODE (op
) == REG
;
988 return (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == REG
);
992 special_symbolref_operand (op
, mode
)
994 enum machine_mode ATTRIBUTE_UNUSED mode
;
996 if (GET_CODE (op
) == SYMBOL_REF
)
997 return ENCODED_NAME_P (XSTR (op
, 0));
999 else if (GET_CODE (op
) == CONST
)
1000 return (GET_CODE (XEXP (op
, 0)) == PLUS
1001 && GET_CODE (XEXP (XEXP (op
, 0), 0)) == SYMBOL_REF
1002 && ENCODED_NAME_P (XSTR (XEXP (XEXP (op
, 0), 0), 0))
1003 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
1004 && CONST_OK_FOR_K (INTVAL (XEXP (XEXP (op
, 0), 1))));
1010 movsi_source_operand (op
, mode
)
1012 enum machine_mode mode
;
1014 /* Some constants, as well as symbolic operands
1015 must be done with HIGH & LO_SUM patterns. */
1017 && GET_CODE (op
) != HIGH
1018 && GET_CODE (op
) != CONSTANT_P_RTX
1019 && !(GET_CODE (op
) == CONST_INT
1020 && (CONST_OK_FOR_J (INTVAL (op
))
1021 || CONST_OK_FOR_K (INTVAL (op
))
1022 || CONST_OK_FOR_L (INTVAL (op
)))))
1023 return special_symbolref_operand (op
, mode
);
1025 return general_operand (op
, mode
);
1029 power_of_two_operand (op
, mode
)
1031 enum machine_mode ATTRIBUTE_UNUSED mode
;
1033 if (GET_CODE (op
) != CONST_INT
)
1036 if (exact_log2 (INTVAL (op
)) == -1)
1042 not_power_of_two_operand (op
, mode
)
1044 enum machine_mode mode
;
1050 else if (mode
== HImode
)
1052 else if (mode
== SImode
)
1057 if (GET_CODE (op
) != CONST_INT
)
1060 if (exact_log2 (~INTVAL (op
) & mask
) == -1)
1066 /* Substitute memory references involving a pointer, to use the ep pointer,
1067 taking care to save and preserve the ep. */
1070 substitute_ep_register (first_insn
, last_insn
, uses
, regno
, p_r1
, p_ep
)
1078 rtx reg
= gen_rtx_REG (Pmode
, regno
);
1083 regs_ever_live
[1] = 1;
1084 *p_r1
= gen_rtx_REG (Pmode
, 1);
1085 *p_ep
= gen_rtx_REG (Pmode
, 30);
1090 Saved %d bytes (%d uses of register %s) in function %s, starting as insn %d, ending at %d\n",
1091 2 * (uses
- 3), uses
, reg_names
[regno
],
1092 IDENTIFIER_POINTER (DECL_NAME (current_function_decl
)),
1093 INSN_UID (first_insn
), INSN_UID (last_insn
));
1095 if (GET_CODE (first_insn
) == NOTE
)
1096 first_insn
= next_nonnote_insn (first_insn
);
1098 last_insn
= next_nonnote_insn (last_insn
);
1099 for (insn
= first_insn
; insn
&& insn
!= last_insn
; insn
= NEXT_INSN (insn
))
1101 if (GET_CODE (insn
) == INSN
)
1103 rtx pattern
= single_set (insn
);
1105 /* Replace the memory references. */
1109 /* Memory operands are signed by default. */
1110 int unsignedp
= FALSE
;
1112 if (GET_CODE (SET_DEST (pattern
)) == MEM
1113 && GET_CODE (SET_SRC (pattern
)) == MEM
)
1116 else if (GET_CODE (SET_DEST (pattern
)) == MEM
)
1117 p_mem
= &SET_DEST (pattern
);
1119 else if (GET_CODE (SET_SRC (pattern
)) == MEM
)
1120 p_mem
= &SET_SRC (pattern
);
1127 rtx addr
= XEXP (*p_mem
, 0);
1129 if (GET_CODE (addr
) == REG
&& REGNO (addr
) == (unsigned) regno
)
1130 *p_mem
= change_address (*p_mem
, VOIDmode
, *p_ep
);
1132 else if (GET_CODE (addr
) == PLUS
1133 && GET_CODE (XEXP (addr
, 0)) == REG
1134 && REGNO (XEXP (addr
, 0)) == (unsigned) regno
1135 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
1136 && ((INTVAL (XEXP (addr
, 1)))
1137 < ep_memory_offset (GET_MODE (*p_mem
),
1139 && ((INTVAL (XEXP (addr
, 1))) >= 0))
1140 *p_mem
= change_address (*p_mem
, VOIDmode
,
1141 gen_rtx_PLUS (Pmode
,
1149 /* Optimize back to back cases of ep <- r1 & r1 <- ep. */
1150 insn
= prev_nonnote_insn (first_insn
);
1151 if (insn
&& GET_CODE (insn
) == INSN
1152 && GET_CODE (PATTERN (insn
)) == SET
1153 && SET_DEST (PATTERN (insn
)) == *p_ep
1154 && SET_SRC (PATTERN (insn
)) == *p_r1
)
1157 emit_insn_before (gen_rtx_SET (Pmode
, *p_r1
, *p_ep
), first_insn
);
1159 emit_insn_before (gen_rtx_SET (Pmode
, *p_ep
, reg
), first_insn
);
1160 emit_insn_before (gen_rtx_SET (Pmode
, *p_ep
, *p_r1
), last_insn
);
1164 /* In rare cases, correct code generation requires extra machine
1165 dependent processing between the second jump optimization pass and
1166 delayed branch scheduling. On those machines, define this macro
1167 as a C statement to act on the code starting at INSN.
1169 On the 850, we use it to implement the -mep mode to copy heavily used
1170 pointers to ep to use the implicit addressing. */
1172 void v850_reorg (start_insn
)
1181 regs
[FIRST_PSEUDO_REGISTER
];
1190 /* If not ep mode, just return now. */
1194 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1197 regs
[i
].first_insn
= NULL_RTX
;
1198 regs
[i
].last_insn
= NULL_RTX
;
1201 for (insn
= start_insn
; insn
!= NULL_RTX
; insn
= NEXT_INSN (insn
))
1203 switch (GET_CODE (insn
))
1205 /* End of basic block */
1212 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1214 if (max_uses
< regs
[i
].uses
)
1216 max_uses
= regs
[i
].uses
;
1222 substitute_ep_register (regs
[max_regno
].first_insn
,
1223 regs
[max_regno
].last_insn
,
1224 max_uses
, max_regno
, &r1
, &ep
);
1228 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1231 regs
[i
].first_insn
= NULL_RTX
;
1232 regs
[i
].last_insn
= NULL_RTX
;
1240 pattern
= single_set (insn
);
1242 /* See if there are any memory references we can shorten */
1245 rtx src
= SET_SRC (pattern
);
1246 rtx dest
= SET_DEST (pattern
);
1248 /* Memory operands are signed by default. */
1249 int unsignedp
= FALSE
;
1251 /* We might have (SUBREG (MEM)) here, so just get rid of the
1252 subregs to make this code simpler. It is safe to call
1253 alter_subreg any time after reload. */
1254 if (GET_CODE (dest
) == SUBREG
)
1255 dest
= alter_subreg (dest
);
1256 if (GET_CODE (src
) == SUBREG
)
1257 src
= alter_subreg (src
);
1259 if (GET_CODE (dest
) == MEM
&& GET_CODE (src
) == MEM
)
1262 else if (GET_CODE (dest
) == MEM
)
1265 else if (GET_CODE (src
) == MEM
)
1271 if (mem
&& ep_memory_operand (mem
, GET_MODE (mem
), unsignedp
))
1274 else if (!use_ep
&& mem
1275 && GET_MODE_SIZE (GET_MODE (mem
)) <= UNITS_PER_WORD
)
1277 rtx addr
= XEXP (mem
, 0);
1281 if (GET_CODE (addr
) == REG
)
1284 regno
= REGNO (addr
);
1287 else if (GET_CODE (addr
) == PLUS
1288 && GET_CODE (XEXP (addr
, 0)) == REG
1289 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
1290 && ((INTVAL (XEXP (addr
, 1)))
1291 < ep_memory_offset (GET_MODE (mem
), unsignedp
))
1292 && ((INTVAL (XEXP (addr
, 1))) >= 0))
1295 regno
= REGNO (XEXP (addr
, 0));
1304 regs
[regno
].last_insn
= insn
;
1305 if (!regs
[regno
].first_insn
)
1306 regs
[regno
].first_insn
= insn
;
1310 /* Loading up a register in the basic block zaps any savings
1312 if (GET_CODE (dest
) == REG
)
1314 enum machine_mode mode
= GET_MODE (dest
);
1318 regno
= REGNO (dest
);
1319 endregno
= regno
+ HARD_REGNO_NREGS (regno
, mode
);
1323 /* See if we can use the pointer before this
1328 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1330 if (max_uses
< regs
[i
].uses
)
1332 max_uses
= regs
[i
].uses
;
1338 && max_regno
>= regno
1339 && max_regno
< endregno
)
1341 substitute_ep_register (regs
[max_regno
].first_insn
,
1342 regs
[max_regno
].last_insn
,
1343 max_uses
, max_regno
, &r1
,
1346 /* Since we made a substitution, zap all remembered
1348 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
1351 regs
[i
].first_insn
= NULL_RTX
;
1352 regs
[i
].last_insn
= NULL_RTX
;
1357 for (i
= regno
; i
< endregno
; i
++)
1360 regs
[i
].first_insn
= NULL_RTX
;
1361 regs
[i
].last_insn
= NULL_RTX
;
1370 /* # of registers saved by the interrupt handler. */
1371 #define INTERRUPT_FIXED_NUM 4
1373 /* # of bytes for registers saved by the interrupt handler. */
1374 #define INTERRUPT_FIXED_SAVE_SIZE (4 * INTERRUPT_FIXED_NUM)
1376 /* # of registers saved in register parameter area. */
1377 #define INTERRUPT_REGPARM_NUM 4
1378 /* # of words saved for other registers. */
1379 #define INTERRUPT_ALL_SAVE_NUM \
1380 (30 - INTERRUPT_FIXED_NUM + INTERRUPT_REGPARM_NUM)
1382 #define INTERRUPT_ALL_SAVE_SIZE (4 * INTERRUPT_ALL_SAVE_NUM)
1385 compute_register_save_size (p_reg_saved
)
1390 int interrupt_handler
= v850_interrupt_function_p (current_function_decl
);
1391 int call_p
= regs_ever_live
[LINK_POINTER_REGNUM
];
1394 /* Count the return pointer if we need to save it. */
1395 if (profile_flag
&& !call_p
)
1396 regs_ever_live
[LINK_POINTER_REGNUM
] = call_p
= 1;
1398 /* Count space for the register saves. */
1399 if (interrupt_handler
)
1401 for (i
= 0; i
<= 31; i
++)
1405 if (regs_ever_live
[i
] || call_p
)
1408 reg_saved
|= 1L << i
;
1412 /* We don't save/restore r0 or the stack pointer */
1414 case STACK_POINTER_REGNUM
:
1417 /* For registers with fixed use, we save them, set them to the
1418 appropriate value, and then restore them.
1419 These registers are handled specially, so don't list them
1420 on the list of registers to save in the prologue. */
1421 case 1: /* temp used to hold ep */
1423 case 10: /* temp used to call interrupt save/restore */
1424 case EP_REGNUM
: /* ep */
1431 /* Find the first register that needs to be saved. */
1432 for (i
= 0; i
<= 31; i
++)
1433 if (regs_ever_live
[i
] && ((! call_used_regs
[i
])
1434 || i
== LINK_POINTER_REGNUM
))
1437 /* If it is possible that an out-of-line helper function might be
1438 used to generate the prologue for the current function, then we
1439 need to cover the possibility that such a helper function will
1440 be used, despite the fact that there might be gaps in the list of
1441 registers that need to be saved. To detect this we note that the
1442 helper functions always push at least register r29 if the link
1443 register is not used, and at least registers r27 - r31 if the
1444 link register is used (and provided that the function is not an
1445 interrupt handler). */
1447 if (TARGET_PROLOG_FUNCTION
1448 && (i
== 2 || i
>= 20)
1449 && regs_ever_live
[LINK_POINTER_REGNUM
] ? (i
< 28) : (i
< 30))
1454 reg_saved
|= 1L << i
;
1459 /* Helper functions save all registers between the starting
1460 register and the last register, regardless of whether they
1461 are actually used by the function or not. */
1462 for (; i
<= 29; i
++)
1465 reg_saved
|= 1L << i
;
1468 if (regs_ever_live
[LINK_POINTER_REGNUM
])
1471 reg_saved
|= 1L << LINK_POINTER_REGNUM
;
1476 for (; i
<= 31; i
++)
1477 if (regs_ever_live
[i
] && ((! call_used_regs
[i
])
1478 || i
== LINK_POINTER_REGNUM
))
1481 reg_saved
|= 1L << i
;
1487 *p_reg_saved
= reg_saved
;
1493 compute_frame_size (size
, p_reg_saved
)
1498 + compute_register_save_size (p_reg_saved
)
1499 + current_function_outgoing_args_size
);
1508 unsigned int size
= get_frame_size ();
1509 unsigned int actual_fsize
;
1510 unsigned int init_stack_alloc
= 0;
1513 unsigned int num_save
;
1514 unsigned int default_stack
;
1516 int interrupt_handler
= v850_interrupt_function_p (current_function_decl
);
1519 actual_fsize
= compute_frame_size (size
, ®_saved
);
1521 /* Save/setup global registers for interrupt functions right now. */
1522 if (interrupt_handler
)
1524 emit_insn (gen_save_interrupt ());
1526 actual_fsize
-= INTERRUPT_FIXED_SAVE_SIZE
;
1528 if (((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1529 actual_fsize
-= INTERRUPT_ALL_SAVE_SIZE
;
1532 /* Save arg registers to the stack if necessary. */
1533 else if (current_function_anonymous_args
)
1535 if (TARGET_PROLOG_FUNCTION
)
1537 emit_insn (gen_save_r6_r9 ());
1542 for (i
= 6; i
< 10; i
++)
1544 emit_move_insn (gen_rtx_MEM (SImode
,
1545 plus_constant (stack_pointer_rtx
,
1547 gen_rtx_REG (SImode
, i
));
1553 /* Identify all of the saved registers. */
1556 for (i
= 1; i
< 31; i
++)
1558 if (((1L << i
) & reg_saved
) != 0)
1559 save_regs
[num_save
++] = gen_rtx_REG (Pmode
, i
);
1562 /* If the return pointer is saved, the helper functions also allocate
1563 16 bytes of stack for arguments to be saved in. */
1564 if (((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1566 save_regs
[num_save
++] = gen_rtx_REG (Pmode
, LINK_POINTER_REGNUM
);
1570 /* See if we have an insn that allocates stack space and saves the particular
1571 registers we want to. */
1572 save_all
= NULL_RTX
;
1573 if (TARGET_PROLOG_FUNCTION
&& num_save
> 0 && actual_fsize
>= default_stack
)
1575 int alloc_stack
= (4 * num_save
) + default_stack
;
1576 int unalloc_stack
= actual_fsize
- alloc_stack
;
1577 int save_func_len
= 4;
1578 int save_normal_len
;
1581 save_func_len
+= CONST_OK_FOR_J (unalloc_stack
) ? 2 : 4;
1583 /* see if we would have used ep to save the stack */
1584 if (TARGET_EP
&& num_save
> 3 && (unsigned)actual_fsize
< 255)
1585 save_normal_len
= (3 * 2) + (2 * num_save
);
1587 save_normal_len
= 4 * num_save
;
1589 save_normal_len
+= CONST_OK_FOR_J (actual_fsize
) ? 2 : 4;
1591 /* Don't bother checking if we don't actually save any space.
1592 This happens for instance if one register is saved and additional
1593 stack space is allocated. */
1594 if (save_func_len
< save_normal_len
)
1596 save_all
= gen_rtx_PARALLEL
1598 rtvec_alloc (num_save
+ (TARGET_V850
? 2 : 1)));
1600 XVECEXP (save_all
, 0, 0)
1601 = gen_rtx_SET (VOIDmode
,
1603 plus_constant (stack_pointer_rtx
, -alloc_stack
));
1607 XVECEXP (save_all
, 0, num_save
+1)
1608 = gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (Pmode
, 10));
1611 offset
= - default_stack
;
1612 for (i
= 0; i
< num_save
; i
++)
1614 XVECEXP (save_all
, 0, i
+1)
1615 = gen_rtx_SET (VOIDmode
,
1617 plus_constant (stack_pointer_rtx
,
1623 code
= recog (save_all
, NULL_RTX
, NULL
);
1626 rtx insn
= emit_insn (save_all
);
1627 INSN_CODE (insn
) = code
;
1628 actual_fsize
-= alloc_stack
;
1632 Saved %d bytes via prologue function (%d vs. %d) for function %s\n",
1633 save_normal_len
- save_func_len
,
1634 save_normal_len
, save_func_len
,
1635 IDENTIFIER_POINTER (DECL_NAME (current_function_decl
)));
1638 save_all
= NULL_RTX
;
1642 /* If no prolog save function is available, store the registers the old
1643 fashioned way (one by one). */
1646 /* Special case interrupt functions that save all registers for a call. */
1647 if (interrupt_handler
&& ((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1649 emit_insn (gen_save_all_interrupt ());
1653 /* If the stack is too big, allocate it in chunks so we can do the
1654 register saves. We use the register save size so we use the ep
1656 if (actual_fsize
&& !CONST_OK_FOR_K (-actual_fsize
))
1657 init_stack_alloc
= compute_register_save_size (NULL
);
1659 init_stack_alloc
= actual_fsize
;
1661 /* Save registers at the beginning of the stack frame */
1662 offset
= init_stack_alloc
- 4;
1664 if (init_stack_alloc
)
1665 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1667 GEN_INT (-init_stack_alloc
)));
1669 /* Save the return pointer first. */
1670 if (num_save
> 0 && REGNO (save_regs
[num_save
-1]) == LINK_POINTER_REGNUM
)
1672 emit_move_insn (gen_rtx_MEM (SImode
,
1673 plus_constant (stack_pointer_rtx
,
1675 save_regs
[--num_save
]);
1679 for (i
= 0; i
< num_save
; i
++)
1681 emit_move_insn (gen_rtx_MEM (SImode
,
1682 plus_constant (stack_pointer_rtx
,
1690 /* Allocate the rest of the stack that was not allocated above (either it is
1691 > 32K or we just called a function to save the registers and needed more
1693 if (actual_fsize
> init_stack_alloc
)
1695 int diff
= actual_fsize
- init_stack_alloc
;
1696 if (CONST_OK_FOR_K (diff
))
1697 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1702 rtx reg
= gen_rtx_REG (Pmode
, 12);
1703 emit_move_insn (reg
, GEN_INT (-diff
));
1704 emit_insn (gen_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
, reg
));
1708 /* If we need a frame pointer, set it up now. */
1709 if (frame_pointer_needed
)
1710 emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
);
1719 unsigned int size
= get_frame_size ();
1721 unsigned int actual_fsize
= compute_frame_size (size
, ®_saved
);
1722 unsigned int init_stack_free
= 0;
1723 rtx restore_regs
[32];
1725 unsigned int num_restore
;
1726 unsigned int default_stack
;
1728 int interrupt_handler
= v850_interrupt_function_p (current_function_decl
);
1730 /* Eliminate the initial stack stored by interrupt functions. */
1731 if (interrupt_handler
)
1733 actual_fsize
-= INTERRUPT_FIXED_SAVE_SIZE
;
1734 if (((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1735 actual_fsize
-= INTERRUPT_ALL_SAVE_SIZE
;
1738 /* Cut off any dynamic stack created. */
1739 if (frame_pointer_needed
)
1740 emit_move_insn (stack_pointer_rtx
, hard_frame_pointer_rtx
);
1742 /* Identify all of the saved registers. */
1745 for (i
= 1; i
< 31; i
++)
1747 if (((1L << i
) & reg_saved
) != 0)
1748 restore_regs
[num_restore
++] = gen_rtx_REG (Pmode
, i
);
1751 /* If the return pointer is saved, the helper functions also allocate
1752 16 bytes of stack for arguments to be saved in. */
1753 if (((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1755 restore_regs
[num_restore
++] = gen_rtx_REG (Pmode
, LINK_POINTER_REGNUM
);
1759 /* See if we have an insn that restores the particular registers we
1761 restore_all
= NULL_RTX
;
1763 if (TARGET_PROLOG_FUNCTION
1765 && actual_fsize
>= default_stack
1766 && !interrupt_handler
)
1768 int alloc_stack
= (4 * num_restore
) + default_stack
;
1769 int unalloc_stack
= actual_fsize
- alloc_stack
;
1770 int restore_func_len
= 4;
1771 int restore_normal_len
;
1774 restore_func_len
+= CONST_OK_FOR_J (unalloc_stack
) ? 2 : 4;
1776 /* See if we would have used ep to restore the registers. */
1777 if (TARGET_EP
&& num_restore
> 3 && (unsigned)actual_fsize
< 255)
1778 restore_normal_len
= (3 * 2) + (2 * num_restore
);
1780 restore_normal_len
= 4 * num_restore
;
1782 restore_normal_len
+= (CONST_OK_FOR_J (actual_fsize
) ? 2 : 4) + 2;
1784 /* Don't bother checking if we don't actually save any space. */
1785 if (restore_func_len
< restore_normal_len
)
1787 restore_all
= gen_rtx_PARALLEL (VOIDmode
,
1788 rtvec_alloc (num_restore
+ 2));
1789 XVECEXP (restore_all
, 0, 0) = gen_rtx_RETURN (VOIDmode
);
1790 XVECEXP (restore_all
, 0, 1)
1791 = gen_rtx_SET (VOIDmode
, stack_pointer_rtx
,
1792 gen_rtx_PLUS (Pmode
,
1794 GEN_INT (alloc_stack
)));
1796 offset
= alloc_stack
- 4;
1797 for (i
= 0; i
< num_restore
; i
++)
1799 XVECEXP (restore_all
, 0, i
+2)
1800 = gen_rtx_SET (VOIDmode
,
1803 plus_constant (stack_pointer_rtx
,
1808 code
= recog (restore_all
, NULL_RTX
, NULL
);
1814 actual_fsize
-= alloc_stack
;
1817 if (CONST_OK_FOR_K (actual_fsize
))
1818 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1820 GEN_INT (actual_fsize
)));
1823 rtx reg
= gen_rtx_REG (Pmode
, 12);
1824 emit_move_insn (reg
, GEN_INT (actual_fsize
));
1825 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1831 insn
= emit_jump_insn (restore_all
);
1832 INSN_CODE (insn
) = code
;
1836 Saved %d bytes via epilogue function (%d vs. %d) in function %s\n",
1837 restore_normal_len
- restore_func_len
,
1838 restore_normal_len
, restore_func_len
,
1839 IDENTIFIER_POINTER (DECL_NAME (current_function_decl
)));
1842 restore_all
= NULL_RTX
;
1846 /* If no epilog save function is available, restore the registers the
1847 old fashioned way (one by one). */
1850 /* If the stack is large, we need to cut it down in 2 pieces. */
1851 if (actual_fsize
&& !CONST_OK_FOR_K (-actual_fsize
))
1852 init_stack_free
= 4 * num_restore
;
1854 init_stack_free
= actual_fsize
;
1856 /* Deallocate the rest of the stack if it is > 32K. */
1857 if (actual_fsize
> init_stack_free
)
1861 diff
= actual_fsize
- ((interrupt_handler
) ? 0 : init_stack_free
);
1863 if (CONST_OK_FOR_K (diff
))
1864 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1869 rtx reg
= gen_rtx_REG (Pmode
, 12);
1870 emit_move_insn (reg
, GEN_INT (diff
));
1871 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1877 /* Special case interrupt functions that save all registers
1879 if (interrupt_handler
&& ((1L << LINK_POINTER_REGNUM
) & reg_saved
) != 0)
1881 emit_insn (gen_restore_all_interrupt ());
1885 /* Restore registers from the beginning of the stack frame. */
1886 offset
= init_stack_free
- 4;
1888 /* Restore the return pointer first. */
1890 && REGNO (restore_regs
[num_restore
- 1]) == LINK_POINTER_REGNUM
)
1892 emit_move_insn (restore_regs
[--num_restore
],
1893 gen_rtx_MEM (SImode
,
1894 plus_constant (stack_pointer_rtx
,
1899 for (i
= 0; i
< num_restore
; i
++)
1901 emit_move_insn (restore_regs
[i
],
1902 gen_rtx_MEM (SImode
,
1903 plus_constant (stack_pointer_rtx
,
1906 emit_insn (gen_rtx_USE (VOIDmode
, restore_regs
[i
]));
1910 /* Cut back the remainder of the stack. */
1911 if (init_stack_free
)
1912 emit_insn (gen_addsi3 (stack_pointer_rtx
,
1914 GEN_INT (init_stack_free
)));
1917 /* And return or use reti for interrupt handlers. */
1918 if (interrupt_handler
)
1919 emit_jump_insn (gen_restore_interrupt ());
1920 else if (actual_fsize
)
1921 emit_jump_insn (gen_return_internal ());
1923 emit_jump_insn (gen_return ());
1926 current_function_anonymous_args
= 0;
1927 v850_interrupt_cache_p
= FALSE
;
1928 v850_interrupt_p
= FALSE
;
1932 /* Update the condition code from the insn. */
1935 notice_update_cc (body
, insn
)
1939 switch (get_attr_cc (insn
))
1942 /* Insn does not affect CC at all. */
1946 /* Insn does not change CC, but the 0'th operand has been changed. */
1947 if (cc_status
.value1
!= 0
1948 && reg_overlap_mentioned_p (recog_data
.operand
[0], cc_status
.value1
))
1949 cc_status
.value1
= 0;
1953 /* Insn sets the Z,N flags of CC to recog_data.operand[0].
1954 V,C is in an unusable state. */
1956 cc_status
.flags
|= CC_OVERFLOW_UNUSABLE
| CC_NO_CARRY
;
1957 cc_status
.value1
= recog_data
.operand
[0];
1961 /* Insn sets the Z,N,V flags of CC to recog_data.operand[0].
1962 C is in an unusable state. */
1964 cc_status
.flags
|= CC_NO_CARRY
;
1965 cc_status
.value1
= recog_data
.operand
[0];
1969 /* The insn is a compare instruction. */
1971 cc_status
.value1
= SET_SRC (body
);
1975 /* Insn doesn't leave CC in a usable state. */
1981 /* Retrieve the data area that has been chosen for the given decl. */
1984 v850_get_data_area (decl
)
1987 if (lookup_attribute ("sda", DECL_ATTRIBUTES (decl
)) != NULL_TREE
)
1988 return DATA_AREA_SDA
;
1990 if (lookup_attribute ("tda", DECL_ATTRIBUTES (decl
)) != NULL_TREE
)
1991 return DATA_AREA_TDA
;
1993 if (lookup_attribute ("zda", DECL_ATTRIBUTES (decl
)) != NULL_TREE
)
1994 return DATA_AREA_ZDA
;
1996 return DATA_AREA_NORMAL
;
1999 /* Store the indicated data area in the decl's attributes. */
2002 v850_set_data_area (decl
, data_area
)
2004 v850_data_area data_area
;
2010 case DATA_AREA_SDA
: name
= get_identifier ("sda"); break;
2011 case DATA_AREA_TDA
: name
= get_identifier ("tda"); break;
2012 case DATA_AREA_ZDA
: name
= get_identifier ("zda"); break;
2017 DECL_ATTRIBUTES (decl
) = tree_cons
2018 (name
, NULL
, DECL_ATTRIBUTES (decl
));
2021 const struct attribute_spec v850_attribute_table
[] =
2023 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
2024 { "interrupt_handler", 0, 0, true, false, false, v850_handle_interrupt_attribute
},
2025 { "interrupt", 0, 0, true, false, false, v850_handle_interrupt_attribute
},
2026 { "sda", 0, 0, true, false, false, v850_handle_data_area_attribute
},
2027 { "tda", 0, 0, true, false, false, v850_handle_data_area_attribute
},
2028 { "zda", 0, 0, true, false, false, v850_handle_data_area_attribute
},
2029 { NULL
, 0, 0, false, false, false, NULL
}
2032 /* Handle an "interrupt" attribute; arguments as in
2033 struct attribute_spec.handler. */
2035 v850_handle_interrupt_attribute (node
, name
, args
, flags
, no_add_attrs
)
2038 tree args ATTRIBUTE_UNUSED
;
2039 int flags ATTRIBUTE_UNUSED
;
2042 if (TREE_CODE (*node
) != FUNCTION_DECL
)
2044 warning ("`%s' attribute only applies to functions",
2045 IDENTIFIER_POINTER (name
));
2046 *no_add_attrs
= true;
2052 /* Handle a "sda", "tda" or "zda" attribute; arguments as in
2053 struct attribute_spec.handler. */
2055 v850_handle_data_area_attribute (node
, name
, args
, flags
, no_add_attrs
)
2058 tree args ATTRIBUTE_UNUSED
;
2059 int flags ATTRIBUTE_UNUSED
;
2062 v850_data_area data_area
;
2063 v850_data_area area
;
2066 /* Implement data area attribute. */
2067 if (is_attribute_p ("sda", name
))
2068 data_area
= DATA_AREA_SDA
;
2069 else if (is_attribute_p ("tda", name
))
2070 data_area
= DATA_AREA_TDA
;
2071 else if (is_attribute_p ("zda", name
))
2072 data_area
= DATA_AREA_ZDA
;
2076 switch (TREE_CODE (decl
))
2079 if (current_function_decl
!= NULL_TREE
)
2081 error_with_decl (decl
, "\
2082 a data area attribute cannot be specified for local variables");
2083 *no_add_attrs
= true;
2089 area
= v850_get_data_area (decl
);
2090 if (area
!= DATA_AREA_NORMAL
&& data_area
!= area
)
2092 error_with_decl (decl
, "\
2093 data area of '%s' conflicts with previous declaration");
2094 *no_add_attrs
= true;
2106 /* Return nonzero if FUNC is an interrupt function as specified
2107 by the "interrupt" attribute. */
2110 v850_interrupt_function_p (func
)
2116 if (v850_interrupt_cache_p
)
2117 return v850_interrupt_p
;
2119 if (TREE_CODE (func
) != FUNCTION_DECL
)
2122 a
= lookup_attribute ("interrupt_handler", DECL_ATTRIBUTES (func
));
2128 a
= lookup_attribute ("interrupt", DECL_ATTRIBUTES (func
));
2129 ret
= a
!= NULL_TREE
;
2132 /* Its not safe to trust global variables until after function inlining has
2134 if (reload_completed
| reload_in_progress
)
2135 v850_interrupt_p
= ret
;
2142 v850_encode_data_area (decl
)
2145 const char *str
= XSTR (XEXP (DECL_RTL (decl
), 0), 0);
2146 int len
= strlen (str
);
2149 /* Map explict sections into the appropriate attribute */
2150 if (v850_get_data_area (decl
) == DATA_AREA_NORMAL
)
2152 if (DECL_SECTION_NAME (decl
))
2154 const char *name
= TREE_STRING_POINTER (DECL_SECTION_NAME (decl
));
2156 if (streq (name
, ".zdata") || streq (name
, ".zbss"))
2157 v850_set_data_area (decl
, DATA_AREA_ZDA
);
2159 else if (streq (name
, ".sdata") || streq (name
, ".sbss"))
2160 v850_set_data_area (decl
, DATA_AREA_SDA
);
2162 else if (streq (name
, ".tdata"))
2163 v850_set_data_area (decl
, DATA_AREA_TDA
);
2166 /* If no attribute, support -m{zda,sda,tda}=n */
2169 int size
= int_size_in_bytes (TREE_TYPE (decl
));
2173 else if (size
<= small_memory
[(int) SMALL_MEMORY_TDA
].max
)
2174 v850_set_data_area (decl
, DATA_AREA_TDA
);
2176 else if (size
<= small_memory
[(int) SMALL_MEMORY_SDA
].max
)
2177 v850_set_data_area (decl
, DATA_AREA_SDA
);
2179 else if (size
<= small_memory
[(int) SMALL_MEMORY_ZDA
].max
)
2180 v850_set_data_area (decl
, DATA_AREA_ZDA
);
2183 if (v850_get_data_area (decl
) == DATA_AREA_NORMAL
)
2187 newstr
= alloca (len
+ 2);
2189 strcpy (newstr
+ 1, str
);
2191 switch (v850_get_data_area (decl
))
2193 case DATA_AREA_ZDA
: *newstr
= ZDA_NAME_FLAG_CHAR
; break;
2194 case DATA_AREA_TDA
: *newstr
= TDA_NAME_FLAG_CHAR
; break;
2195 case DATA_AREA_SDA
: *newstr
= SDA_NAME_FLAG_CHAR
; break;
2199 XSTR (XEXP (DECL_RTL (decl
), 0), 0) = ggc_alloc_string (newstr
, len
+ 2);
2202 /* Return true if the given RTX is a register which can be restored
2203 by a function epilogue. */
2205 register_is_ok_for_epilogue (op
, mode
)
2207 enum machine_mode ATTRIBUTE_UNUSED mode
;
2209 /* The save/restore routines can only cope with registers 2, and 20 - 31 */
2210 return (GET_CODE (op
) == REG
)
2211 && (((REGNO (op
) >= 20) && REGNO (op
) <= 31)
2212 || REGNO (op
) == 2);
2215 /* Return non-zero if the given RTX is suitable for collapsing into
2216 jump to a function epilogue. */
2218 pattern_is_ok_for_epilogue (op
, mode
)
2220 enum machine_mode ATTRIBUTE_UNUSED mode
;
2222 int count
= XVECLEN (op
, 0);
2225 /* If there are no registers to restore then the function epilogue
2230 /* The pattern matching has already established that we are performing a
2231 function epilogue and that we are popping at least one register. We must
2232 now check the remaining entries in the vector to make sure that they are
2233 also register pops. There is no good reason why there should ever be
2234 anything else in this vector, but being paranoid always helps...
2236 The test below performs the C equivalent of this machine description
2239 (set (match_operand:SI n "register_is_ok_for_epilogue" "r")
2240 (mem:SI (plus:SI (reg:SI 3) (match_operand:SI n "immediate_operand" "i"))))
2243 for (i
= 3; i
< count
; i
++)
2245 rtx vector_element
= XVECEXP (op
, 0, i
);
2250 if (GET_CODE (vector_element
) != SET
)
2253 dest
= SET_DEST (vector_element
);
2254 src
= SET_SRC (vector_element
);
2256 if (GET_CODE (dest
) != REG
2257 || GET_MODE (dest
) != SImode
2258 || ! register_is_ok_for_epilogue (dest
, SImode
)
2259 || GET_CODE (src
) != MEM
2260 || GET_MODE (src
) != SImode
)
2263 plus
= XEXP (src
, 0);
2265 if (GET_CODE (plus
) != PLUS
2266 || GET_CODE (XEXP (plus
, 0)) != REG
2267 || GET_MODE (XEXP (plus
, 0)) != SImode
2268 || REGNO (XEXP (plus
, 0)) != STACK_POINTER_REGNUM
2269 || GET_CODE (XEXP (plus
, 1)) != CONST_INT
)
2276 /* Construct a JR instruction to a routine that will perform the equivalent of
2277 the RTL passed in as an argument. This RTL is a function epilogue that
2278 pops registers off the stack and possibly releases some extra stack space
2279 as well. The code has already verified that the RTL matches these
2282 construct_restore_jr (op
)
2285 int count
= XVECLEN (op
, 0);
2287 unsigned long int mask
;
2288 unsigned long int first
;
2289 unsigned long int last
;
2291 static char buff
[100]; /* XXX */
2295 error ("bogus JR construction: %d\n", count
);
2299 /* Work out how many bytes to pop off the stack before retrieving
2301 if (GET_CODE (XVECEXP (op
, 0, 1)) != SET
)
2303 if (GET_CODE (SET_SRC (XVECEXP (op
, 0, 1))) != PLUS
)
2305 if (GET_CODE (XEXP (SET_SRC (XVECEXP (op
, 0, 1)), 1)) != CONST_INT
)
2308 stack_bytes
= INTVAL (XEXP (SET_SRC (XVECEXP (op
, 0, 1)), 1));
2310 /* Each pop will remove 4 bytes from the stack... */
2311 stack_bytes
-= (count
- 2) * 4;
2313 /* Make sure that the amount we are popping either 0 or 16 bytes. */
2314 if (stack_bytes
!= 0 && stack_bytes
!= 16)
2316 error ("bad amount of stack space removal: %d", stack_bytes
);
2320 /* Now compute the bit mask of registers to push. */
2322 for (i
= 2; i
< count
; i
++)
2324 rtx vector_element
= XVECEXP (op
, 0, i
);
2326 if (GET_CODE (vector_element
) != SET
)
2328 if (GET_CODE (SET_DEST (vector_element
)) != REG
)
2330 if (! register_is_ok_for_epilogue (SET_DEST (vector_element
), SImode
))
2333 mask
|= 1 << REGNO (SET_DEST (vector_element
));
2336 /* Scan for the first register to pop. */
2337 for (first
= 0; first
< 32; first
++)
2339 if (mask
& (1 << first
))
2346 /* Discover the last register to pop. */
2347 if (mask
& (1 << LINK_POINTER_REGNUM
))
2349 if (stack_bytes
!= 16)
2352 last
= LINK_POINTER_REGNUM
;
2356 if (stack_bytes
!= 0)
2359 if ((mask
& (1 << 29)) == 0)
2365 /* Note, it is possible to have gaps in the register mask.
2366 We ignore this here, and generate a JR anyway. We will
2367 be popping more registers than is strictly necessary, but
2368 it does save code space. */
2370 if (TARGET_LONG_CALLS
)
2375 sprintf (name
, "__return_%s", reg_names
[first
]);
2377 sprintf (name
, "__return_%s_%s", reg_names
[first
], reg_names
[last
]);
2379 sprintf (buff
, "movhi hi(%s), r0, r6\n\tmovea lo(%s), r6, r6\n\tjmp r6",
2385 sprintf (buff
, "jr __return_%s", reg_names
[first
]);
2387 sprintf (buff
, "jr __return_%s_%s", reg_names
[first
], reg_names
[last
]);
2394 /* Return non-zero if the given RTX is suitable for collapsing into
2395 a jump to a function prologue. */
2397 pattern_is_ok_for_prologue (op
, mode
)
2399 enum machine_mode ATTRIBUTE_UNUSED mode
;
2401 int count
= XVECLEN (op
, 0);
2405 /* If there are no registers to save then the function prologue
2410 /* The pattern matching has already established that we are adjusting the
2411 stack and pushing at least one register. We must now check that the
2412 remaining entries in the vector to make sure that they are also register
2413 pushes, except for the last entry which should be a CLOBBER of r10.
2415 The test below performs the C equivalent of this machine description
2418 (set (mem:SI (plus:SI (reg:SI 3)
2419 (match_operand:SI 2 "immediate_operand" "i")))
2420 (match_operand:SI 3 "register_is_ok_for_epilogue" "r"))
2424 for (i
= 2; i
< count
- 1; i
++)
2430 vector_element
= XVECEXP (op
, 0, i
);
2432 if (GET_CODE (vector_element
) != SET
)
2435 dest
= SET_DEST (vector_element
);
2436 src
= SET_SRC (vector_element
);
2438 if (GET_CODE (dest
) != MEM
2439 || GET_MODE (dest
) != SImode
2440 || GET_CODE (src
) != REG
2441 || GET_MODE (src
) != SImode
2442 || ! register_is_ok_for_epilogue (src
, SImode
))
2445 plus
= XEXP (dest
, 0);
2447 if ( GET_CODE (plus
) != PLUS
2448 || GET_CODE (XEXP (plus
, 0)) != REG
2449 || GET_MODE (XEXP (plus
, 0)) != SImode
2450 || REGNO (XEXP (plus
, 0)) != STACK_POINTER_REGNUM
2451 || GET_CODE (XEXP (plus
, 1)) != CONST_INT
)
2454 /* If the register is being pushed somewhere other than the stack
2455 space just acquired by the first operand then abandon this quest.
2456 Note: the test is <= because both values are negative. */
2457 if (INTVAL (XEXP (plus
, 1))
2458 <= INTVAL (XEXP (SET_SRC (XVECEXP (op
, 0, 0)), 1)))
2464 /* Make sure that the last entry in the vector is a clobber. */
2465 vector_element
= XVECEXP (op
, 0, i
);
2467 if (GET_CODE (vector_element
) != CLOBBER
2468 || GET_CODE (XEXP (vector_element
, 0)) != REG
2469 || REGNO (XEXP (vector_element
, 0)) != 10)
2475 /* Construct a JARL instruction to a routine that will perform the equivalent
2476 of the RTL passed as a parameter. This RTL is a function prologue that
2477 saves some of the registers r20 - r31 onto the stack, and possibly acquires
2478 some stack space as well. The code has already verified that the RTL
2479 matches these requirements. */
2481 construct_save_jarl (op
)
2484 int count
= XVECLEN (op
, 0);
2486 unsigned long int mask
;
2487 unsigned long int first
;
2488 unsigned long int last
;
2490 static char buff
[100]; /* XXX */
2494 error ("bogus JARL construction: %d\n", count
);
2499 if (GET_CODE (XVECEXP (op
, 0, 0)) != SET
)
2501 if (GET_CODE (SET_SRC (XVECEXP (op
, 0, 0))) != PLUS
)
2503 if (GET_CODE (XEXP (SET_SRC (XVECEXP (op
, 0, 0)), 0)) != REG
)
2505 if (GET_CODE (XEXP (SET_SRC (XVECEXP (op
, 0, 0)), 1)) != CONST_INT
)
2508 /* Work out how many bytes to push onto the stack after storing the
2510 stack_bytes
= INTVAL (XEXP (SET_SRC (XVECEXP (op
, 0, 0)), 1));
2512 /* Each push will put 4 bytes from the stack... */
2513 stack_bytes
+= (count
- 2) * 4;
2515 /* Make sure that the amount we are popping either 0 or 16 bytes. */
2516 if (stack_bytes
!= 0 && stack_bytes
!= -16)
2518 error ("bad amount of stack space removal: %d", stack_bytes
);
2522 /* Now compute the bit mask of registers to push. */
2524 for (i
= 1; i
< count
- 1; i
++)
2526 rtx vector_element
= XVECEXP (op
, 0, i
);
2528 if (GET_CODE (vector_element
) != SET
)
2530 if (GET_CODE (SET_SRC (vector_element
)) != REG
)
2532 if (! register_is_ok_for_epilogue (SET_SRC (vector_element
), SImode
))
2535 mask
|= 1 << REGNO (SET_SRC (vector_element
));
2538 /* Scan for the first register to push. */
2539 for (first
= 0; first
< 32; first
++)
2541 if (mask
& (1 << first
))
2548 /* Discover the last register to push. */
2549 if (mask
& (1 << LINK_POINTER_REGNUM
))
2551 if (stack_bytes
!= -16)
2554 last
= LINK_POINTER_REGNUM
;
2558 if (stack_bytes
!= 0)
2560 if ((mask
& (1 << 29)) == 0)
2566 /* Note, it is possible to have gaps in the register mask.
2567 We ignore this here, and generate a JARL anyway. We will
2568 be pushing more registers than is strictly necessary, but
2569 it does save code space. */
2571 if (TARGET_LONG_CALLS
)
2576 sprintf (name
, "__save_%s", reg_names
[first
]);
2578 sprintf (name
, "__save_%s_%s", reg_names
[first
], reg_names
[last
]);
2580 sprintf (buff
, "movhi hi(%s), r0, r11\n\tmovea lo(%s), r11, r11\n\tjarl .+4, r10\n\tadd 4, r10\n\tjmp r11",
2586 sprintf (buff
, "jarl __save_%s, r10", reg_names
[first
]);
2588 sprintf (buff
, "jarl __save_%s_%s, r10", reg_names
[first
],
2595 extern tree last_assemble_variable_decl
;
2596 extern int size_directive_output
;
2598 /* A version of asm_output_aligned_bss() that copes with the special
2599 data areas of the v850. */
2601 v850_output_aligned_bss (file
, decl
, name
, size
, align
)
2608 ASM_GLOBALIZE_LABEL (file
, name
);
2610 switch (v850_get_data_area (decl
))
2628 ASM_OUTPUT_ALIGN (file
, floor_log2 (align
/ BITS_PER_UNIT
));
2629 #ifdef ASM_DECLARE_OBJECT_NAME
2630 last_assemble_variable_decl
= decl
;
2631 ASM_DECLARE_OBJECT_NAME (file
, name
, decl
);
2633 /* Standard thing is just output label for the object. */
2634 ASM_OUTPUT_LABEL (file
, name
);
2635 #endif /* ASM_DECLARE_OBJECT_NAME */
2636 ASM_OUTPUT_SKIP (file
, size
? size
: 1);
2639 /* Called via the macro ASM_OUTPUT_DECL_COMMON */
2641 v850_output_common (file
, decl
, name
, size
, align
)
2648 if (decl
== NULL_TREE
)
2650 fprintf (file
, "%s", COMMON_ASM_OP
);
2654 switch (v850_get_data_area (decl
))
2657 fprintf (file
, "%s", ZCOMMON_ASM_OP
);
2661 fprintf (file
, "%s", SCOMMON_ASM_OP
);
2665 fprintf (file
, "%s", TCOMMON_ASM_OP
);
2669 fprintf (file
, "%s", COMMON_ASM_OP
);
2674 assemble_name (file
, name
);
2675 fprintf (file
, ",%u,%u\n", size
, align
/ BITS_PER_UNIT
);
2678 /* Called via the macro ASM_OUTPUT_DECL_LOCAL */
2680 v850_output_local (file
, decl
, name
, size
, align
)
2687 fprintf (file
, "%s", LOCAL_ASM_OP
);
2688 assemble_name (file
, name
);
2689 fprintf (file
, "\n");
2691 ASM_OUTPUT_ALIGNED_DECL_COMMON (file
, decl
, name
, size
, align
);
2694 /* Add data area to the given declaration if a ghs data area pragma is
2695 currently in effect (#pragma ghs startXXX/endXXX). */
2697 v850_insert_attributes (decl
, attr_ptr
)
2699 tree
*attr_ptr ATTRIBUTE_UNUSED
;
2702 && data_area_stack
->data_area
2703 && current_function_decl
== NULL_TREE
2704 && (TREE_CODE (decl
) == VAR_DECL
|| TREE_CODE (decl
) == CONST_DECL
)
2705 && v850_get_data_area (decl
) == DATA_AREA_NORMAL
)
2706 v850_set_data_area (decl
, data_area_stack
->data_area
);
2708 /* Initialise the default names of the v850 specific sections,
2709 if this has not been done before. */
2711 if (GHS_default_section_names
[(int) GHS_SECTION_KIND_SDATA
] == NULL
)
2713 GHS_default_section_names
[(int) GHS_SECTION_KIND_SDATA
]
2714 = build_string (sizeof (".sdata")-1, ".sdata");
2716 GHS_default_section_names
[(int) GHS_SECTION_KIND_ROSDATA
]
2717 = build_string (sizeof (".rosdata")-1, ".rosdata");
2719 GHS_default_section_names
[(int) GHS_SECTION_KIND_TDATA
]
2720 = build_string (sizeof (".tdata")-1, ".tdata");
2722 GHS_default_section_names
[(int) GHS_SECTION_KIND_ZDATA
]
2723 = build_string (sizeof (".zdata")-1, ".zdata");
2725 GHS_default_section_names
[(int) GHS_SECTION_KIND_ROZDATA
]
2726 = build_string (sizeof (".rozdata")-1, ".rozdata");
2729 if (current_function_decl
== NULL_TREE
2730 && (TREE_CODE (decl
) == VAR_DECL
2731 || TREE_CODE (decl
) == CONST_DECL
2732 || TREE_CODE (decl
) == FUNCTION_DECL
)
2733 && (!DECL_EXTERNAL (decl
) || DECL_INITIAL (decl
))
2734 && !DECL_SECTION_NAME (decl
))
2736 enum GHS_section_kind kind
= GHS_SECTION_KIND_DEFAULT
;
2737 tree chosen_section
;
2739 if (TREE_CODE (decl
) == FUNCTION_DECL
)
2740 kind
= GHS_SECTION_KIND_TEXT
;
2743 /* First choose a section kind based on the data area of the decl. */
2744 switch (v850_get_data_area (decl
))
2750 kind
= ((TREE_READONLY (decl
))
2751 ? GHS_SECTION_KIND_ROSDATA
2752 : GHS_SECTION_KIND_SDATA
);
2756 kind
= GHS_SECTION_KIND_TDATA
;
2760 kind
= ((TREE_READONLY (decl
))
2761 ? GHS_SECTION_KIND_ROZDATA
2762 : GHS_SECTION_KIND_ZDATA
);
2765 case DATA_AREA_NORMAL
: /* default data area */
2766 if (TREE_READONLY (decl
))
2767 kind
= GHS_SECTION_KIND_RODATA
;
2768 else if (DECL_INITIAL (decl
))
2769 kind
= GHS_SECTION_KIND_DATA
;
2771 kind
= GHS_SECTION_KIND_BSS
;
2775 /* Now, if the section kind has been explicitly renamed,
2776 then attach a section attribute. */
2777 chosen_section
= GHS_current_section_names
[(int) kind
];
2779 /* Otherwise, if this kind of section needs an explicit section
2780 attribute, then also attach one. */
2781 if (chosen_section
== NULL
)
2782 chosen_section
= GHS_default_section_names
[(int) kind
];
2786 /* Only set the section name if specified by a pragma, because
2787 otherwise it will force those variables to get allocated storage
2788 in this module, rather than by the linker. */
2789 DECL_SECTION_NAME (decl
) = chosen_section
;
2794 /* Implement `va_arg'. */
2797 v850_va_arg (valist
, type
)
2800 HOST_WIDE_INT size
, rsize
;
2805 /* Round up sizeof(type) to a word. */
2806 size
= int_size_in_bytes (type
);
2807 rsize
= (size
+ UNITS_PER_WORD
- 1) & -UNITS_PER_WORD
;
2812 size
= rsize
= UNITS_PER_WORD
;
2816 addr
= save_expr (valist
);
2817 incr
= fold (build (PLUS_EXPR
, ptr_type_node
, addr
,
2818 build_int_2 (rsize
, 0)));
2820 incr
= build (MODIFY_EXPR
, ptr_type_node
, valist
, incr
);
2821 TREE_SIDE_EFFECTS (incr
) = 1;
2822 expand_expr (incr
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2824 addr_rtx
= expand_expr (addr
, NULL
, Pmode
, EXPAND_NORMAL
);
2828 addr_rtx
= force_reg (Pmode
, addr_rtx
);
2829 addr_rtx
= gen_rtx_MEM (Pmode
, addr_rtx
);
2830 set_mem_alias_set (addr_rtx
, get_varargs_alias_set ());
2836 /* Return an RTX indicating where the return address to the
2837 calling function can be found. */
2840 v850_return_addr (count
)
2846 return get_hard_reg_initial_val (Pmode
, LINK_POINTER_REGNUM
);