1 /* Subroutines for insn-output.c for NEC V850 series
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Jeff Law (law@cygnus.com).
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
29 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "conditions.h"
34 #include "insn-attr.h"
41 #include "integrate.h"
44 #include "target-def.h"
48 #define streq(a,b) (strcmp (a, b) == 0)
51 /* Function prototypes for stupid compilers: */
52 static bool v850_handle_option (size_t, const char *, int);
53 static void const_double_split (rtx, HOST_WIDE_INT *, HOST_WIDE_INT *);
54 static int const_costs_int (HOST_WIDE_INT, int);
55 static int const_costs (rtx, enum rtx_code);
56 static bool v850_rtx_costs (rtx, int, int, int *, bool);
57 static void substitute_ep_register (rtx, rtx, int, int, rtx *, rtx *);
58 static void v850_reorg (void);
59 static int ep_memory_offset (enum machine_mode, int);
60 static void v850_set_data_area (tree, v850_data_area);
61 const struct attribute_spec v850_attribute_table[];
62 static tree v850_handle_interrupt_attribute (tree *, tree, tree, int, bool *);
63 static tree v850_handle_data_area_attribute (tree *, tree, tree, int, bool *);
64 static void v850_insert_attributes (tree, tree *);
65 static void v850_asm_init_sections (void);
66 static section *v850_select_section (tree, int, unsigned HOST_WIDE_INT);
67 static void v850_encode_data_area (tree, rtx);
68 static void v850_encode_section_info (tree, rtx, int);
69 static bool v850_return_in_memory (const_tree, const_tree);
70 static void v850_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
72 static bool v850_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
74 static int v850_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
77 /* Information about the various small memory areas. */
78 struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] =
80 /* name max physical max */
86 /* Names of the various data areas used on the v850. */
87 tree GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
88 tree GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
90 /* Track the current data area set by the data area pragma (which
91 can be nested). Tested by check_default_data_area. */
92 data_area_stack_element * data_area_stack = NULL;
94 /* True if we don't need to check any more if the current
95 function is an interrupt handler. */
96 static int v850_interrupt_cache_p = FALSE;
98 /* Whether current function is an interrupt handler. */
99 static int v850_interrupt_p = FALSE;
101 static GTY(()) section *rosdata_section;
102 static GTY(()) section *rozdata_section;
103 static GTY(()) section *tdata_section;
104 static GTY(()) section *zdata_section;
105 static GTY(()) section *zbss_section;
107 /* Initialize the GCC target structure. */
108 #undef TARGET_ASM_ALIGNED_HI_OP
109 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
111 #undef TARGET_ATTRIBUTE_TABLE
112 #define TARGET_ATTRIBUTE_TABLE v850_attribute_table
114 #undef TARGET_INSERT_ATTRIBUTES
115 #define TARGET_INSERT_ATTRIBUTES v850_insert_attributes
117 #undef TARGET_ASM_SELECT_SECTION
118 #define TARGET_ASM_SELECT_SECTION v850_select_section
120 /* The assembler supports switchable .bss sections, but
121 v850_select_section doesn't yet make use of them. */
122 #undef TARGET_HAVE_SWITCHABLE_BSS_SECTIONS
123 #define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS false
125 #undef TARGET_ENCODE_SECTION_INFO
126 #define TARGET_ENCODE_SECTION_INFO v850_encode_section_info
128 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
129 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
131 #undef TARGET_DEFAULT_TARGET_FLAGS
132 #define TARGET_DEFAULT_TARGET_FLAGS (MASK_DEFAULT | MASK_APP_REGS)
133 #undef TARGET_HANDLE_OPTION
134 #define TARGET_HANDLE_OPTION v850_handle_option
136 #undef TARGET_RTX_COSTS
137 #define TARGET_RTX_COSTS v850_rtx_costs
139 #undef TARGET_ADDRESS_COST
140 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
142 #undef TARGET_MACHINE_DEPENDENT_REORG
143 #define TARGET_MACHINE_DEPENDENT_REORG v850_reorg
145 #undef TARGET_PROMOTE_PROTOTYPES
146 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true
148 #undef TARGET_RETURN_IN_MEMORY
149 #define TARGET_RETURN_IN_MEMORY v850_return_in_memory
151 #undef TARGET_PASS_BY_REFERENCE
152 #define TARGET_PASS_BY_REFERENCE v850_pass_by_reference
154 #undef TARGET_CALLEE_COPIES
155 #define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true
157 #undef TARGET_SETUP_INCOMING_VARARGS
158 #define TARGET_SETUP_INCOMING_VARARGS v850_setup_incoming_varargs
160 #undef TARGET_ARG_PARTIAL_BYTES
161 #define TARGET_ARG_PARTIAL_BYTES v850_arg_partial_bytes
163 struct gcc_target targetm = TARGET_INITIALIZER;
165 /* Set the maximum size of small memory area TYPE to the value given
166 by VALUE. Return true if VALUE was syntactically correct. VALUE
167 starts with the argument separator: either "-" or "=". */
170 v850_handle_memory_option (enum small_memory_type type, const char *value)
174 if (*value != '-' && *value != '=')
178 for (i = 0; value[i]; i++)
179 if (!ISDIGIT (value[i]))
183 if (size > small_memory[type].physical_max)
184 error ("value passed to %<-m%s%> is too large", small_memory[type].name);
186 small_memory[type].max = size;
190 /* Implement TARGET_HANDLE_OPTION. */
193 v850_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED)
198 target_flags |= MASK_EP | MASK_PROLOG_FUNCTION;
202 target_flags &= ~(MASK_CPU ^ MASK_V850);
207 target_flags &= ~(MASK_CPU ^ MASK_V850E);
211 return v850_handle_memory_option (SMALL_MEMORY_TDA, arg);
214 return v850_handle_memory_option (SMALL_MEMORY_SDA, arg);
217 return v850_handle_memory_option (SMALL_MEMORY_ZDA, arg);
225 v850_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
226 enum machine_mode mode, const_tree type,
227 bool named ATTRIBUTE_UNUSED)
229 unsigned HOST_WIDE_INT size;
232 size = int_size_in_bytes (type);
234 size = GET_MODE_SIZE (mode);
239 /* Return an RTX to represent where a value with mode MODE will be returned
240 from a function. If the result is 0, the argument is pushed. */
243 function_arg (CUMULATIVE_ARGS * cum,
244 enum machine_mode mode,
251 if (TARGET_GHS && !named)
255 size = int_size_in_bytes (type);
257 size = GET_MODE_SIZE (mode);
263 align = TYPE_ALIGN (type) / BITS_PER_UNIT;
267 cum->nbytes = (cum->nbytes + align - 1) &~(align - 1);
269 if (cum->nbytes > 4 * UNITS_PER_WORD)
272 if (type == NULL_TREE
273 && cum->nbytes + size > 4 * UNITS_PER_WORD)
276 switch (cum->nbytes / UNITS_PER_WORD)
279 result = gen_rtx_REG (mode, 6);
282 result = gen_rtx_REG (mode, 7);
285 result = gen_rtx_REG (mode, 8);
288 result = gen_rtx_REG (mode, 9);
298 /* Return the number of bytes which must be put into registers
299 for values which are part in registers and part in memory. */
302 v850_arg_partial_bytes (CUMULATIVE_ARGS * cum, enum machine_mode mode,
303 tree type, bool named)
307 if (TARGET_GHS && !named)
311 size = int_size_in_bytes (type);
313 size = GET_MODE_SIZE (mode);
316 align = TYPE_ALIGN (type) / BITS_PER_UNIT;
320 cum->nbytes = (cum->nbytes + align - 1) &~(align - 1);
322 if (cum->nbytes > 4 * UNITS_PER_WORD)
325 if (cum->nbytes + size <= 4 * UNITS_PER_WORD)
328 if (type == NULL_TREE
329 && cum->nbytes + size > 4 * UNITS_PER_WORD)
332 return 4 * UNITS_PER_WORD - cum->nbytes;
336 /* Return the high and low words of a CONST_DOUBLE */
339 const_double_split (rtx x, HOST_WIDE_INT * p_high, HOST_WIDE_INT * p_low)
341 if (GET_CODE (x) == CONST_DOUBLE)
346 switch (GET_MODE (x))
349 REAL_VALUE_FROM_CONST_DOUBLE (rv, x);
350 REAL_VALUE_TO_TARGET_DOUBLE (rv, t);
351 *p_high = t[1]; /* since v850 is little endian */
352 *p_low = t[0]; /* high is second word */
356 REAL_VALUE_FROM_CONST_DOUBLE (rv, x);
357 REAL_VALUE_TO_TARGET_SINGLE (rv, *p_high);
363 *p_high = CONST_DOUBLE_HIGH (x);
364 *p_low = CONST_DOUBLE_LOW (x);
372 fatal_insn ("const_double_split got a bad insn:", x);
376 /* Return the cost of the rtx R with code CODE. */
379 const_costs_int (HOST_WIDE_INT value, int zero_cost)
381 if (CONST_OK_FOR_I (value))
383 else if (CONST_OK_FOR_J (value))
385 else if (CONST_OK_FOR_K (value))
392 const_costs (rtx r, enum rtx_code c)
394 HOST_WIDE_INT high, low;
399 return const_costs_int (INTVAL (r), 0);
402 const_double_split (r, &high, &low);
403 if (GET_MODE (r) == SFmode)
404 return const_costs_int (high, 1);
406 return const_costs_int (high, 1) + const_costs_int (low, 1);
422 v850_rtx_costs (rtx x,
424 int outer_code ATTRIBUTE_UNUSED,
425 int * total, bool speed)
434 *total = COSTS_N_INSNS (const_costs (x, code));
441 if (TARGET_V850E && !speed)
449 && ( GET_MODE (x) == SImode
450 || GET_MODE (x) == HImode
451 || GET_MODE (x) == QImode))
453 if (GET_CODE (XEXP (x, 1)) == REG)
455 else if (GET_CODE (XEXP (x, 1)) == CONST_INT)
457 if (CONST_OK_FOR_O (INTVAL (XEXP (x, 1))))
459 else if (CONST_OK_FOR_K (INTVAL (XEXP (x, 1))))
472 /* Print operand X using operand code CODE to assembly language output file
476 print_operand (FILE * file, rtx x, int code)
478 HOST_WIDE_INT high, low;
483 /* We use 'c' operands with symbols for .vtinherit */
484 if (GET_CODE (x) == SYMBOL_REF)
486 output_addr_const(file, x);
493 switch ((code == 'B' || code == 'C')
494 ? reverse_condition (GET_CODE (x)) : GET_CODE (x))
497 if (code == 'c' || code == 'C')
498 fprintf (file, "nz");
500 fprintf (file, "ne");
503 if (code == 'c' || code == 'C')
509 fprintf (file, "ge");
512 fprintf (file, "gt");
515 fprintf (file, "le");
518 fprintf (file, "lt");
521 fprintf (file, "nl");
527 fprintf (file, "nh");
536 case 'F': /* high word of CONST_DOUBLE */
537 switch (GET_CODE (x))
540 fprintf (file, "%d", (INTVAL (x) >= 0) ? 0 : -1);
544 const_double_split (x, &high, &low);
545 fprintf (file, "%ld", (long) high);
552 case 'G': /* low word of CONST_DOUBLE */
553 switch (GET_CODE (x))
556 fprintf (file, "%ld", (long) INTVAL (x));
560 const_double_split (x, &high, &low);
561 fprintf (file, "%ld", (long) low);
569 fprintf (file, "%d\n", (int)(INTVAL (x) & 0xffff));
572 fprintf (file, "%d", exact_log2 (INTVAL (x)));
575 gcc_assert (special_symbolref_operand (x, VOIDmode));
577 if (GET_CODE (x) == CONST)
578 x = XEXP (XEXP (x, 0), 0);
580 gcc_assert (GET_CODE (x) == SYMBOL_REF);
582 if (SYMBOL_REF_ZDA_P (x))
583 fprintf (file, "zdaoff");
584 else if (SYMBOL_REF_SDA_P (x))
585 fprintf (file, "sdaoff");
586 else if (SYMBOL_REF_TDA_P (x))
587 fprintf (file, "tdaoff");
592 gcc_assert (special_symbolref_operand (x, VOIDmode));
593 output_addr_const (file, x);
596 gcc_assert (special_symbolref_operand (x, VOIDmode));
598 if (GET_CODE (x) == CONST)
599 x = XEXP (XEXP (x, 0), 0);
601 gcc_assert (GET_CODE (x) == SYMBOL_REF);
603 if (SYMBOL_REF_ZDA_P (x))
604 fprintf (file, "r0");
605 else if (SYMBOL_REF_SDA_P (x))
606 fprintf (file, "gp");
607 else if (SYMBOL_REF_TDA_P (x))
608 fprintf (file, "ep");
612 case 'R': /* 2nd word of a double. */
613 switch (GET_CODE (x))
616 fprintf (file, reg_names[REGNO (x) + 1]);
619 x = XEXP (adjust_address (x, SImode, 4), 0);
620 print_operand_address (file, x);
621 if (GET_CODE (x) == CONST_INT)
622 fprintf (file, "[r0]");
631 /* If it's a reference to a TDA variable, use sst/sld vs. st/ld. */
632 if (GET_CODE (x) == MEM && ep_memory_operand (x, GET_MODE (x), FALSE))
639 /* Like an 'S' operand above, but for unsigned loads only. */
640 if (GET_CODE (x) == MEM && ep_memory_operand (x, GET_MODE (x), TRUE))
645 case 'W': /* print the instruction suffix */
646 switch (GET_MODE (x))
651 case QImode: fputs (".b", file); break;
652 case HImode: fputs (".h", file); break;
653 case SImode: fputs (".w", file); break;
654 case SFmode: fputs (".w", file); break;
657 case '.': /* register r0 */
658 fputs (reg_names[0], file);
660 case 'z': /* reg or zero */
661 if (GET_CODE (x) == REG)
662 fputs (reg_names[REGNO (x)], file);
665 gcc_assert (x == const0_rtx);
666 fputs (reg_names[0], file);
670 switch (GET_CODE (x))
673 if (GET_CODE (XEXP (x, 0)) == CONST_INT)
674 output_address (gen_rtx_PLUS (SImode, gen_rtx_REG (SImode, 0),
677 output_address (XEXP (x, 0));
681 fputs (reg_names[REGNO (x)], file);
684 fputs (reg_names[subreg_regno (x)], file);
691 print_operand_address (file, x);
702 /* Output assembly language output for the address ADDR to FILE. */
705 print_operand_address (FILE * file, rtx addr)
707 switch (GET_CODE (addr))
710 fprintf (file, "0[");
711 print_operand (file, addr, 0);
715 if (GET_CODE (XEXP (addr, 0)) == REG)
718 fprintf (file, "lo(");
719 print_operand (file, XEXP (addr, 1), 0);
720 fprintf (file, ")[");
721 print_operand (file, XEXP (addr, 0), 0);
726 if (GET_CODE (XEXP (addr, 0)) == REG
727 || GET_CODE (XEXP (addr, 0)) == SUBREG)
730 print_operand (file, XEXP (addr, 1), 0);
732 print_operand (file, XEXP (addr, 0), 0);
737 print_operand (file, XEXP (addr, 0), 0);
739 print_operand (file, XEXP (addr, 1), 0);
744 const char *off_name = NULL;
745 const char *reg_name = NULL;
747 if (SYMBOL_REF_ZDA_P (addr))
752 else if (SYMBOL_REF_SDA_P (addr))
757 else if (SYMBOL_REF_TDA_P (addr))
764 fprintf (file, "%s(", off_name);
765 output_addr_const (file, addr);
767 fprintf (file, ")[%s]", reg_name);
771 if (special_symbolref_operand (addr, VOIDmode))
773 rtx x = XEXP (XEXP (addr, 0), 0);
774 const char *off_name;
775 const char *reg_name;
777 if (SYMBOL_REF_ZDA_P (x))
782 else if (SYMBOL_REF_SDA_P (x))
787 else if (SYMBOL_REF_TDA_P (x))
795 fprintf (file, "%s(", off_name);
796 output_addr_const (file, addr);
797 fprintf (file, ")[%s]", reg_name);
800 output_addr_const (file, addr);
803 output_addr_const (file, addr);
808 /* When assemble_integer is used to emit the offsets for a switch
809 table it can encounter (TRUNCATE:HI (MINUS:SI (LABEL_REF:SI) (LABEL_REF:SI))).
810 output_addr_const will normally barf at this, but it is OK to omit
811 the truncate and just emit the difference of the two labels. The
812 .hword directive will automatically handle the truncation for us.
814 Returns 1 if rtx was handled, 0 otherwise. */
817 v850_output_addr_const_extra (FILE * file, rtx x)
819 if (GET_CODE (x) != TRUNCATE)
824 /* We must also handle the case where the switch table was passed a
825 constant value and so has been collapsed. In this case the first
826 label will have been deleted. In such a case it is OK to emit
827 nothing, since the table will not be used.
828 (cf gcc.c-torture/compile/990801-1.c). */
829 if (GET_CODE (x) == MINUS
830 && GET_CODE (XEXP (x, 0)) == LABEL_REF
831 && GET_CODE (XEXP (XEXP (x, 0), 0)) == CODE_LABEL
832 && INSN_DELETED_P (XEXP (XEXP (x, 0), 0)))
835 output_addr_const (file, x);
839 /* Return appropriate code to load up a 1, 2, or 4 integer/floating
843 output_move_single (rtx * operands)
845 rtx dst = operands[0];
846 rtx src = operands[1];
853 else if (GET_CODE (src) == CONST_INT)
855 HOST_WIDE_INT value = INTVAL (src);
857 if (CONST_OK_FOR_J (value)) /* Signed 5-bit immediate. */
860 else if (CONST_OK_FOR_K (value)) /* Signed 16-bit immediate. */
861 return "movea lo(%1),%.,%0";
863 else if (CONST_OK_FOR_L (value)) /* Upper 16 bits were set. */
864 return "movhi hi(%1),%.,%0";
866 /* A random constant. */
867 else if (TARGET_V850E)
870 return "movhi hi(%1),%.,%0\n\tmovea lo(%1),%0,%0";
873 else if (GET_CODE (src) == CONST_DOUBLE && GET_MODE (src) == SFmode)
875 HOST_WIDE_INT high, low;
877 const_double_split (src, &high, &low);
879 if (CONST_OK_FOR_J (high)) /* Signed 5-bit immediate. */
882 else if (CONST_OK_FOR_K (high)) /* Signed 16-bit immediate. */
883 return "movea lo(%F1),%.,%0";
885 else if (CONST_OK_FOR_L (high)) /* Upper 16 bits were set. */
886 return "movhi hi(%F1),%.,%0";
888 /* A random constant. */
889 else if (TARGET_V850E)
893 return "movhi hi(%F1),%.,%0\n\tmovea lo(%F1),%0,%0";
896 else if (GET_CODE (src) == MEM)
897 return "%S1ld%W1 %1,%0";
899 else if (special_symbolref_operand (src, VOIDmode))
900 return "movea %O1(%P1),%Q1,%0";
902 else if (GET_CODE (src) == LABEL_REF
903 || GET_CODE (src) == SYMBOL_REF
904 || GET_CODE (src) == CONST)
907 return "mov hilo(%1),%0";
909 return "movhi hi(%1),%.,%0\n\tmovea lo(%1),%0,%0";
912 else if (GET_CODE (src) == HIGH)
913 return "movhi hi(%1),%.,%0";
915 else if (GET_CODE (src) == LO_SUM)
917 operands[2] = XEXP (src, 0);
918 operands[3] = XEXP (src, 1);
919 return "movea lo(%3),%2,%0";
923 else if (GET_CODE (dst) == MEM)
926 return "%S0st%W0 %1,%0";
928 else if (GET_CODE (src) == CONST_INT && INTVAL (src) == 0)
929 return "%S0st%W0 %.,%0";
931 else if (GET_CODE (src) == CONST_DOUBLE
932 && CONST0_RTX (GET_MODE (dst)) == src)
933 return "%S0st%W0 %.,%0";
936 fatal_insn ("output_move_single:", gen_rtx_SET (VOIDmode, dst, src));
941 /* Return maximum offset supported for a short EP memory reference of mode
942 MODE and signedness UNSIGNEDP. */
945 ep_memory_offset (enum machine_mode mode, int unsignedp ATTRIBUTE_UNUSED)
952 if (TARGET_SMALL_SLD)
953 max_offset = (1 << 4);
954 else if (TARGET_V850E
955 && ( ( unsignedp && ! TARGET_US_BIT_SET)
956 || (! unsignedp && TARGET_US_BIT_SET)))
957 max_offset = (1 << 4);
959 max_offset = (1 << 7);
963 if (TARGET_SMALL_SLD)
964 max_offset = (1 << 5);
965 else if (TARGET_V850E
966 && ( ( unsignedp && ! TARGET_US_BIT_SET)
967 || (! unsignedp && TARGET_US_BIT_SET)))
968 max_offset = (1 << 5);
970 max_offset = (1 << 8);
975 max_offset = (1 << 8);
985 /* Return true if OP is a valid short EP memory reference */
988 ep_memory_operand (rtx op, enum machine_mode mode, int unsigned_load)
994 /* If we are not using the EP register on a per-function basis
995 then do not allow this optimization at all. This is to
996 prevent the use of the SLD/SST instructions which cannot be
997 guaranteed to work properly due to a hardware bug. */
1001 if (GET_CODE (op) != MEM)
1004 max_offset = ep_memory_offset (mode, unsigned_load);
1006 mask = GET_MODE_SIZE (mode) - 1;
1008 addr = XEXP (op, 0);
1009 if (GET_CODE (addr) == CONST)
1010 addr = XEXP (addr, 0);
1012 switch (GET_CODE (addr))
1018 return SYMBOL_REF_TDA_P (addr);
1021 return REGNO (addr) == EP_REGNUM;
1024 op0 = XEXP (addr, 0);
1025 op1 = XEXP (addr, 1);
1026 if (GET_CODE (op1) == CONST_INT
1027 && INTVAL (op1) < max_offset
1028 && INTVAL (op1) >= 0
1029 && (INTVAL (op1) & mask) == 0)
1031 if (GET_CODE (op0) == REG && REGNO (op0) == EP_REGNUM)
1034 if (GET_CODE (op0) == SYMBOL_REF && SYMBOL_REF_TDA_P (op0))
1043 /* Substitute memory references involving a pointer, to use the ep pointer,
1044 taking care to save and preserve the ep. */
1047 substitute_ep_register (rtx first_insn,
1054 rtx reg = gen_rtx_REG (Pmode, regno);
1059 df_set_regs_ever_live (1, true);
1060 *p_r1 = gen_rtx_REG (Pmode, 1);
1061 *p_ep = gen_rtx_REG (Pmode, 30);
1066 Saved %d bytes (%d uses of register %s) in function %s, starting as insn %d, ending at %d\n",
1067 2 * (uses - 3), uses, reg_names[regno],
1068 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)),
1069 INSN_UID (first_insn), INSN_UID (last_insn));
1071 if (GET_CODE (first_insn) == NOTE)
1072 first_insn = next_nonnote_insn (first_insn);
1074 last_insn = next_nonnote_insn (last_insn);
1075 for (insn = first_insn; insn && insn != last_insn; insn = NEXT_INSN (insn))
1077 if (GET_CODE (insn) == INSN)
1079 rtx pattern = single_set (insn);
1081 /* Replace the memory references. */
1085 /* Memory operands are signed by default. */
1086 int unsignedp = FALSE;
1088 if (GET_CODE (SET_DEST (pattern)) == MEM
1089 && GET_CODE (SET_SRC (pattern)) == MEM)
1092 else if (GET_CODE (SET_DEST (pattern)) == MEM)
1093 p_mem = &SET_DEST (pattern);
1095 else if (GET_CODE (SET_SRC (pattern)) == MEM)
1096 p_mem = &SET_SRC (pattern);
1098 else if (GET_CODE (SET_SRC (pattern)) == SIGN_EXTEND
1099 && GET_CODE (XEXP (SET_SRC (pattern), 0)) == MEM)
1100 p_mem = &XEXP (SET_SRC (pattern), 0);
1102 else if (GET_CODE (SET_SRC (pattern)) == ZERO_EXTEND
1103 && GET_CODE (XEXP (SET_SRC (pattern), 0)) == MEM)
1105 p_mem = &XEXP (SET_SRC (pattern), 0);
1113 rtx addr = XEXP (*p_mem, 0);
1115 if (GET_CODE (addr) == REG && REGNO (addr) == (unsigned) regno)
1116 *p_mem = change_address (*p_mem, VOIDmode, *p_ep);
1118 else if (GET_CODE (addr) == PLUS
1119 && GET_CODE (XEXP (addr, 0)) == REG
1120 && REGNO (XEXP (addr, 0)) == (unsigned) regno
1121 && GET_CODE (XEXP (addr, 1)) == CONST_INT
1122 && ((INTVAL (XEXP (addr, 1)))
1123 < ep_memory_offset (GET_MODE (*p_mem),
1125 && ((INTVAL (XEXP (addr, 1))) >= 0))
1126 *p_mem = change_address (*p_mem, VOIDmode,
1127 gen_rtx_PLUS (Pmode,
1135 /* Optimize back to back cases of ep <- r1 & r1 <- ep. */
1136 insn = prev_nonnote_insn (first_insn);
1137 if (insn && GET_CODE (insn) == INSN
1138 && GET_CODE (PATTERN (insn)) == SET
1139 && SET_DEST (PATTERN (insn)) == *p_ep
1140 && SET_SRC (PATTERN (insn)) == *p_r1)
1143 emit_insn_before (gen_rtx_SET (Pmode, *p_r1, *p_ep), first_insn);
1145 emit_insn_before (gen_rtx_SET (Pmode, *p_ep, reg), first_insn);
1146 emit_insn_before (gen_rtx_SET (Pmode, *p_ep, *p_r1), last_insn);
1150 /* TARGET_MACHINE_DEPENDENT_REORG. On the 850, we use it to implement
1151 the -mep mode to copy heavily used pointers to ep to use the implicit
1163 regs[FIRST_PSEUDO_REGISTER];
1172 /* If not ep mode, just return now. */
1176 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1179 regs[i].first_insn = NULL_RTX;
1180 regs[i].last_insn = NULL_RTX;
1183 for (insn = get_insns (); insn != NULL_RTX; insn = NEXT_INSN (insn))
1185 switch (GET_CODE (insn))
1187 /* End of basic block */
1194 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1196 if (max_uses < regs[i].uses)
1198 max_uses = regs[i].uses;
1204 substitute_ep_register (regs[max_regno].first_insn,
1205 regs[max_regno].last_insn,
1206 max_uses, max_regno, &r1, &ep);
1210 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1213 regs[i].first_insn = NULL_RTX;
1214 regs[i].last_insn = NULL_RTX;
1222 pattern = single_set (insn);
1224 /* See if there are any memory references we can shorten */
1227 rtx src = SET_SRC (pattern);
1228 rtx dest = SET_DEST (pattern);
1230 /* Memory operands are signed by default. */
1231 int unsignedp = FALSE;
1233 /* We might have (SUBREG (MEM)) here, so just get rid of the
1234 subregs to make this code simpler. */
1235 if (GET_CODE (dest) == SUBREG
1236 && (GET_CODE (SUBREG_REG (dest)) == MEM
1237 || GET_CODE (SUBREG_REG (dest)) == REG))
1238 alter_subreg (&dest);
1239 if (GET_CODE (src) == SUBREG
1240 && (GET_CODE (SUBREG_REG (src)) == MEM
1241 || GET_CODE (SUBREG_REG (src)) == REG))
1242 alter_subreg (&src);
1244 if (GET_CODE (dest) == MEM && GET_CODE (src) == MEM)
1247 else if (GET_CODE (dest) == MEM)
1250 else if (GET_CODE (src) == MEM)
1253 else if (GET_CODE (src) == SIGN_EXTEND
1254 && GET_CODE (XEXP (src, 0)) == MEM)
1255 mem = XEXP (src, 0);
1257 else if (GET_CODE (src) == ZERO_EXTEND
1258 && GET_CODE (XEXP (src, 0)) == MEM)
1260 mem = XEXP (src, 0);
1266 if (mem && ep_memory_operand (mem, GET_MODE (mem), unsignedp))
1269 else if (!use_ep && mem
1270 && GET_MODE_SIZE (GET_MODE (mem)) <= UNITS_PER_WORD)
1272 rtx addr = XEXP (mem, 0);
1276 if (GET_CODE (addr) == REG)
1279 regno = REGNO (addr);
1282 else if (GET_CODE (addr) == PLUS
1283 && GET_CODE (XEXP (addr, 0)) == REG
1284 && GET_CODE (XEXP (addr, 1)) == CONST_INT
1285 && ((INTVAL (XEXP (addr, 1)))
1286 < ep_memory_offset (GET_MODE (mem), unsignedp))
1287 && ((INTVAL (XEXP (addr, 1))) >= 0))
1290 regno = REGNO (XEXP (addr, 0));
1299 regs[regno].last_insn = insn;
1300 if (!regs[regno].first_insn)
1301 regs[regno].first_insn = insn;
1305 /* Loading up a register in the basic block zaps any savings
1307 if (GET_CODE (dest) == REG)
1309 enum machine_mode mode = GET_MODE (dest);
1313 regno = REGNO (dest);
1314 endregno = regno + HARD_REGNO_NREGS (regno, mode);
1318 /* See if we can use the pointer before this
1323 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1325 if (max_uses < regs[i].uses)
1327 max_uses = regs[i].uses;
1333 && max_regno >= regno
1334 && max_regno < endregno)
1336 substitute_ep_register (regs[max_regno].first_insn,
1337 regs[max_regno].last_insn,
1338 max_uses, max_regno, &r1,
1341 /* Since we made a substitution, zap all remembered
1343 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
1346 regs[i].first_insn = NULL_RTX;
1347 regs[i].last_insn = NULL_RTX;
1352 for (i = regno; i < endregno; i++)
1355 regs[i].first_insn = NULL_RTX;
1356 regs[i].last_insn = NULL_RTX;
1365 /* # of registers saved by the interrupt handler. */
1366 #define INTERRUPT_FIXED_NUM 4
1368 /* # of bytes for registers saved by the interrupt handler. */
1369 #define INTERRUPT_FIXED_SAVE_SIZE (4 * INTERRUPT_FIXED_NUM)
1371 /* # of registers saved in register parameter area. */
1372 #define INTERRUPT_REGPARM_NUM 4
1373 /* # of words saved for other registers. */
1374 #define INTERRUPT_ALL_SAVE_NUM \
1375 (30 - INTERRUPT_FIXED_NUM + INTERRUPT_REGPARM_NUM)
1377 #define INTERRUPT_ALL_SAVE_SIZE (4 * INTERRUPT_ALL_SAVE_NUM)
1380 compute_register_save_size (long * p_reg_saved)
1384 int interrupt_handler = v850_interrupt_function_p (current_function_decl);
1385 int call_p = df_regs_ever_live_p (LINK_POINTER_REGNUM);
1388 /* Count the return pointer if we need to save it. */
1389 if (crtl->profile && !call_p)
1391 df_set_regs_ever_live (LINK_POINTER_REGNUM, true);
1395 /* Count space for the register saves. */
1396 if (interrupt_handler)
1398 for (i = 0; i <= 31; i++)
1402 if (df_regs_ever_live_p (i) || call_p)
1405 reg_saved |= 1L << i;
1409 /* We don't save/restore r0 or the stack pointer */
1411 case STACK_POINTER_REGNUM:
1414 /* For registers with fixed use, we save them, set them to the
1415 appropriate value, and then restore them.
1416 These registers are handled specially, so don't list them
1417 on the list of registers to save in the prologue. */
1418 case 1: /* temp used to hold ep */
1420 case 10: /* temp used to call interrupt save/restore */
1421 case EP_REGNUM: /* ep */
1428 /* Find the first register that needs to be saved. */
1429 for (i = 0; i <= 31; i++)
1430 if (df_regs_ever_live_p (i) && ((! call_used_regs[i])
1431 || i == LINK_POINTER_REGNUM))
1434 /* If it is possible that an out-of-line helper function might be
1435 used to generate the prologue for the current function, then we
1436 need to cover the possibility that such a helper function will
1437 be used, despite the fact that there might be gaps in the list of
1438 registers that need to be saved. To detect this we note that the
1439 helper functions always push at least register r29 (provided
1440 that the function is not an interrupt handler). */
1442 if (TARGET_PROLOG_FUNCTION
1443 && (i == 2 || ((i >= 20) && (i < 30))))
1448 reg_saved |= 1L << i;
1453 /* Helper functions save all registers between the starting
1454 register and the last register, regardless of whether they
1455 are actually used by the function or not. */
1456 for (; i <= 29; i++)
1459 reg_saved |= 1L << i;
1462 if (df_regs_ever_live_p (LINK_POINTER_REGNUM))
1465 reg_saved |= 1L << LINK_POINTER_REGNUM;
1470 for (; i <= 31; i++)
1471 if (df_regs_ever_live_p (i) && ((! call_used_regs[i])
1472 || i == LINK_POINTER_REGNUM))
1475 reg_saved |= 1L << i;
1481 *p_reg_saved = reg_saved;
1487 compute_frame_size (int size, long * p_reg_saved)
1490 + compute_register_save_size (p_reg_saved)
1491 + crtl->outgoing_args_size);
1496 expand_prologue (void)
1500 unsigned int size = get_frame_size ();
1501 unsigned int actual_fsize;
1502 unsigned int init_stack_alloc = 0;
1505 unsigned int num_save;
1506 unsigned int default_stack;
1508 int interrupt_handler = v850_interrupt_function_p (current_function_decl);
1511 actual_fsize = compute_frame_size (size, ®_saved);
1513 /* Save/setup global registers for interrupt functions right now. */
1514 if (interrupt_handler)
1516 if (TARGET_V850E && ! TARGET_DISABLE_CALLT)
1517 emit_insn (gen_callt_save_interrupt ());
1519 emit_insn (gen_save_interrupt ());
1521 actual_fsize -= INTERRUPT_FIXED_SAVE_SIZE;
1523 if (((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
1524 actual_fsize -= INTERRUPT_ALL_SAVE_SIZE;
1527 /* Save arg registers to the stack if necessary. */
1528 else if (crtl->args.info.anonymous_args)
1530 if (TARGET_PROLOG_FUNCTION && TARGET_V850E && !TARGET_DISABLE_CALLT)
1531 emit_insn (gen_save_r6_r9_v850e ());
1532 else if (TARGET_PROLOG_FUNCTION && ! TARGET_LONG_CALLS)
1533 emit_insn (gen_save_r6_r9 ());
1537 for (i = 6; i < 10; i++)
1539 emit_move_insn (gen_rtx_MEM (SImode,
1540 plus_constant (stack_pointer_rtx,
1542 gen_rtx_REG (SImode, i));
1548 /* Identify all of the saved registers. */
1551 for (i = 1; i < 31; i++)
1553 if (((1L << i) & reg_saved) != 0)
1554 save_regs[num_save++] = gen_rtx_REG (Pmode, i);
1557 /* If the return pointer is saved, the helper functions also allocate
1558 16 bytes of stack for arguments to be saved in. */
1559 if (((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
1561 save_regs[num_save++] = gen_rtx_REG (Pmode, LINK_POINTER_REGNUM);
1565 /* See if we have an insn that allocates stack space and saves the particular
1566 registers we want to. */
1567 save_all = NULL_RTX;
1568 if (TARGET_PROLOG_FUNCTION && num_save > 0 && actual_fsize >= default_stack)
1570 int alloc_stack = (4 * num_save) + default_stack;
1571 int unalloc_stack = actual_fsize - alloc_stack;
1572 int save_func_len = 4;
1573 int save_normal_len;
1576 save_func_len += CONST_OK_FOR_J (unalloc_stack) ? 2 : 4;
1578 /* see if we would have used ep to save the stack */
1579 if (TARGET_EP && num_save > 3 && (unsigned)actual_fsize < 255)
1580 save_normal_len = (3 * 2) + (2 * num_save);
1582 save_normal_len = 4 * num_save;
1584 save_normal_len += CONST_OK_FOR_J (actual_fsize) ? 2 : 4;
1586 /* Don't bother checking if we don't actually save any space.
1587 This happens for instance if one register is saved and additional
1588 stack space is allocated. */
1589 if (save_func_len < save_normal_len)
1591 save_all = gen_rtx_PARALLEL
1593 rtvec_alloc (num_save + 1
1594 + (TARGET_V850 ? (TARGET_LONG_CALLS ? 2 : 1) : 0)));
1596 XVECEXP (save_all, 0, 0)
1597 = gen_rtx_SET (VOIDmode,
1599 plus_constant (stack_pointer_rtx, -alloc_stack));
1601 offset = - default_stack;
1602 for (i = 0; i < num_save; i++)
1604 XVECEXP (save_all, 0, i+1)
1605 = gen_rtx_SET (VOIDmode,
1607 plus_constant (stack_pointer_rtx,
1615 XVECEXP (save_all, 0, num_save + 1)
1616 = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 10));
1618 if (TARGET_LONG_CALLS)
1619 XVECEXP (save_all, 0, num_save + 2)
1620 = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 11));
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 if (TARGET_V850E && ! TARGET_DISABLE_CALLT)
1650 emit_insn (gen_callt_save_all_interrupt ());
1652 emit_insn (gen_save_all_interrupt ());
1656 /* If the stack is too big, allocate it in chunks so we can do the
1657 register saves. We use the register save size so we use the ep
1659 if (actual_fsize && !CONST_OK_FOR_K (-actual_fsize))
1660 init_stack_alloc = compute_register_save_size (NULL);
1662 init_stack_alloc = actual_fsize;
1664 /* Save registers at the beginning of the stack frame. */
1665 offset = init_stack_alloc - 4;
1667 if (init_stack_alloc)
1668 emit_insn (gen_addsi3 (stack_pointer_rtx,
1670 GEN_INT (- (signed) init_stack_alloc)));
1672 /* Save the return pointer first. */
1673 if (num_save > 0 && REGNO (save_regs[num_save-1]) == LINK_POINTER_REGNUM)
1675 emit_move_insn (gen_rtx_MEM (SImode,
1676 plus_constant (stack_pointer_rtx,
1678 save_regs[--num_save]);
1682 for (i = 0; i < num_save; i++)
1684 emit_move_insn (gen_rtx_MEM (SImode,
1685 plus_constant (stack_pointer_rtx,
1693 /* Allocate the rest of the stack that was not allocated above (either it is
1694 > 32K or we just called a function to save the registers and needed more
1696 if (actual_fsize > init_stack_alloc)
1698 int diff = actual_fsize - init_stack_alloc;
1699 if (CONST_OK_FOR_K (diff))
1700 emit_insn (gen_addsi3 (stack_pointer_rtx,
1705 rtx reg = gen_rtx_REG (Pmode, 12);
1706 emit_move_insn (reg, GEN_INT (-diff));
1707 emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, reg));
1711 /* If we need a frame pointer, set it up now. */
1712 if (frame_pointer_needed)
1713 emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
1718 expand_epilogue (void)
1722 unsigned int size = get_frame_size ();
1724 int actual_fsize = compute_frame_size (size, ®_saved);
1725 unsigned int init_stack_free = 0;
1726 rtx restore_regs[32];
1728 unsigned int num_restore;
1729 unsigned int default_stack;
1731 int interrupt_handler = v850_interrupt_function_p (current_function_decl);
1733 /* Eliminate the initial stack stored by interrupt functions. */
1734 if (interrupt_handler)
1736 actual_fsize -= INTERRUPT_FIXED_SAVE_SIZE;
1737 if (((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
1738 actual_fsize -= INTERRUPT_ALL_SAVE_SIZE;
1741 /* Cut off any dynamic stack created. */
1742 if (frame_pointer_needed)
1743 emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx);
1745 /* Identify all of the saved registers. */
1748 for (i = 1; i < 31; i++)
1750 if (((1L << i) & reg_saved) != 0)
1751 restore_regs[num_restore++] = gen_rtx_REG (Pmode, i);
1754 /* If the return pointer is saved, the helper functions also allocate
1755 16 bytes of stack for arguments to be saved in. */
1756 if (((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
1758 restore_regs[num_restore++] = gen_rtx_REG (Pmode, LINK_POINTER_REGNUM);
1762 /* See if we have an insn that restores the particular registers we
1764 restore_all = NULL_RTX;
1766 if (TARGET_PROLOG_FUNCTION
1768 && actual_fsize >= (signed) default_stack
1769 && !interrupt_handler)
1771 int alloc_stack = (4 * num_restore) + default_stack;
1772 int unalloc_stack = actual_fsize - alloc_stack;
1773 int restore_func_len = 4;
1774 int restore_normal_len;
1777 restore_func_len += CONST_OK_FOR_J (unalloc_stack) ? 2 : 4;
1779 /* See if we would have used ep to restore the registers. */
1780 if (TARGET_EP && num_restore > 3 && (unsigned)actual_fsize < 255)
1781 restore_normal_len = (3 * 2) + (2 * num_restore);
1783 restore_normal_len = 4 * num_restore;
1785 restore_normal_len += (CONST_OK_FOR_J (actual_fsize) ? 2 : 4) + 2;
1787 /* Don't bother checking if we don't actually save any space. */
1788 if (restore_func_len < restore_normal_len)
1790 restore_all = gen_rtx_PARALLEL (VOIDmode,
1791 rtvec_alloc (num_restore + 2));
1792 XVECEXP (restore_all, 0, 0) = gen_rtx_RETURN (VOIDmode);
1793 XVECEXP (restore_all, 0, 1)
1794 = gen_rtx_SET (VOIDmode, stack_pointer_rtx,
1795 gen_rtx_PLUS (Pmode,
1797 GEN_INT (alloc_stack)));
1799 offset = alloc_stack - 4;
1800 for (i = 0; i < num_restore; i++)
1802 XVECEXP (restore_all, 0, i+2)
1803 = gen_rtx_SET (VOIDmode,
1806 plus_constant (stack_pointer_rtx,
1811 code = recog (restore_all, NULL_RTX, NULL);
1817 actual_fsize -= alloc_stack;
1820 if (CONST_OK_FOR_K (actual_fsize))
1821 emit_insn (gen_addsi3 (stack_pointer_rtx,
1823 GEN_INT (actual_fsize)));
1826 rtx reg = gen_rtx_REG (Pmode, 12);
1827 emit_move_insn (reg, GEN_INT (actual_fsize));
1828 emit_insn (gen_addsi3 (stack_pointer_rtx,
1834 insn = emit_jump_insn (restore_all);
1835 INSN_CODE (insn) = code;
1839 Saved %d bytes via epilogue function (%d vs. %d) in function %s\n",
1840 restore_normal_len - restore_func_len,
1841 restore_normal_len, restore_func_len,
1842 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
1845 restore_all = NULL_RTX;
1849 /* If no epilogue save function is available, restore the registers the
1850 old fashioned way (one by one). */
1853 /* If the stack is large, we need to cut it down in 2 pieces. */
1854 if (actual_fsize && !CONST_OK_FOR_K (-actual_fsize))
1855 init_stack_free = 4 * num_restore;
1857 init_stack_free = (signed) actual_fsize;
1859 /* Deallocate the rest of the stack if it is > 32K. */
1860 if (actual_fsize > init_stack_free)
1864 diff = actual_fsize - ((interrupt_handler) ? 0 : init_stack_free);
1866 if (CONST_OK_FOR_K (diff))
1867 emit_insn (gen_addsi3 (stack_pointer_rtx,
1872 rtx reg = gen_rtx_REG (Pmode, 12);
1873 emit_move_insn (reg, GEN_INT (diff));
1874 emit_insn (gen_addsi3 (stack_pointer_rtx,
1880 /* Special case interrupt functions that save all registers
1882 if (interrupt_handler && ((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
1884 if (TARGET_V850E && ! TARGET_DISABLE_CALLT)
1885 emit_insn (gen_callt_restore_all_interrupt ());
1887 emit_insn (gen_restore_all_interrupt ());
1891 /* Restore registers from the beginning of the stack frame. */
1892 offset = init_stack_free - 4;
1894 /* Restore the return pointer first. */
1896 && REGNO (restore_regs [num_restore - 1]) == LINK_POINTER_REGNUM)
1898 emit_move_insn (restore_regs[--num_restore],
1899 gen_rtx_MEM (SImode,
1900 plus_constant (stack_pointer_rtx,
1905 for (i = 0; i < num_restore; i++)
1907 emit_move_insn (restore_regs[i],
1908 gen_rtx_MEM (SImode,
1909 plus_constant (stack_pointer_rtx,
1912 emit_use (restore_regs[i]);
1916 /* Cut back the remainder of the stack. */
1917 if (init_stack_free)
1918 emit_insn (gen_addsi3 (stack_pointer_rtx,
1920 GEN_INT (init_stack_free)));
1923 /* And return or use reti for interrupt handlers. */
1924 if (interrupt_handler)
1926 if (TARGET_V850E && ! TARGET_DISABLE_CALLT)
1927 emit_insn (gen_callt_return_interrupt ());
1929 emit_jump_insn (gen_return_interrupt ());
1931 else if (actual_fsize)
1932 emit_jump_insn (gen_return_internal ());
1934 emit_jump_insn (gen_return_simple ());
1937 v850_interrupt_cache_p = FALSE;
1938 v850_interrupt_p = FALSE;
1942 /* Update the condition code from the insn. */
1945 notice_update_cc (rtx body, rtx insn)
1947 switch (get_attr_cc (insn))
1950 /* Insn does not affect CC at all. */
1954 /* Insn does not change CC, but the 0'th operand has been changed. */
1955 if (cc_status.value1 != 0
1956 && reg_overlap_mentioned_p (recog_data.operand[0], cc_status.value1))
1957 cc_status.value1 = 0;
1961 /* Insn sets the Z,N flags of CC to recog_data.operand[0].
1962 V,C is in an unusable state. */
1964 cc_status.flags |= CC_OVERFLOW_UNUSABLE | CC_NO_CARRY;
1965 cc_status.value1 = recog_data.operand[0];
1969 /* Insn sets the Z,N,V flags of CC to recog_data.operand[0].
1970 C is in an unusable state. */
1972 cc_status.flags |= CC_NO_CARRY;
1973 cc_status.value1 = recog_data.operand[0];
1977 /* The insn is a compare instruction. */
1979 cc_status.value1 = SET_SRC (body);
1983 /* Insn doesn't leave CC in a usable state. */
1989 /* Retrieve the data area that has been chosen for the given decl. */
1992 v850_get_data_area (tree decl)
1994 if (lookup_attribute ("sda", DECL_ATTRIBUTES (decl)) != NULL_TREE)
1995 return DATA_AREA_SDA;
1997 if (lookup_attribute ("tda", DECL_ATTRIBUTES (decl)) != NULL_TREE)
1998 return DATA_AREA_TDA;
2000 if (lookup_attribute ("zda", DECL_ATTRIBUTES (decl)) != NULL_TREE)
2001 return DATA_AREA_ZDA;
2003 return DATA_AREA_NORMAL;
2006 /* Store the indicated data area in the decl's attributes. */
2009 v850_set_data_area (tree decl, v850_data_area data_area)
2015 case DATA_AREA_SDA: name = get_identifier ("sda"); break;
2016 case DATA_AREA_TDA: name = get_identifier ("tda"); break;
2017 case DATA_AREA_ZDA: name = get_identifier ("zda"); break;
2022 DECL_ATTRIBUTES (decl) = tree_cons
2023 (name, NULL, DECL_ATTRIBUTES (decl));
2026 const struct attribute_spec v850_attribute_table[] =
2028 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
2029 { "interrupt_handler", 0, 0, true, false, false, v850_handle_interrupt_attribute },
2030 { "interrupt", 0, 0, true, false, false, v850_handle_interrupt_attribute },
2031 { "sda", 0, 0, true, false, false, v850_handle_data_area_attribute },
2032 { "tda", 0, 0, true, false, false, v850_handle_data_area_attribute },
2033 { "zda", 0, 0, true, false, false, v850_handle_data_area_attribute },
2034 { NULL, 0, 0, false, false, false, NULL }
2037 /* Handle an "interrupt" attribute; arguments as in
2038 struct attribute_spec.handler. */
2040 v850_handle_interrupt_attribute (tree * node,
2042 tree args ATTRIBUTE_UNUSED,
2043 int flags ATTRIBUTE_UNUSED,
2044 bool * no_add_attrs)
2046 if (TREE_CODE (*node) != FUNCTION_DECL)
2048 warning (OPT_Wattributes, "%qE attribute only applies to functions",
2050 *no_add_attrs = true;
2056 /* Handle a "sda", "tda" or "zda" attribute; arguments as in
2057 struct attribute_spec.handler. */
2059 v850_handle_data_area_attribute (tree* node,
2061 tree args ATTRIBUTE_UNUSED,
2062 int flags ATTRIBUTE_UNUSED,
2063 bool * no_add_attrs)
2065 v850_data_area data_area;
2066 v850_data_area area;
2069 /* Implement data area attribute. */
2070 if (is_attribute_p ("sda", name))
2071 data_area = DATA_AREA_SDA;
2072 else if (is_attribute_p ("tda", name))
2073 data_area = DATA_AREA_TDA;
2074 else if (is_attribute_p ("zda", name))
2075 data_area = DATA_AREA_ZDA;
2079 switch (TREE_CODE (decl))
2082 if (current_function_decl != NULL_TREE)
2084 error ("%Jdata area attributes cannot be specified for "
2085 "local variables", decl);
2086 *no_add_attrs = true;
2092 area = v850_get_data_area (decl);
2093 if (area != DATA_AREA_NORMAL && data_area != area)
2095 error ("data area of %q+D conflicts with previous declaration",
2097 *no_add_attrs = true;
2109 /* Return nonzero if FUNC is an interrupt function as specified
2110 by the "interrupt" attribute. */
2113 v850_interrupt_function_p (tree func)
2118 if (v850_interrupt_cache_p)
2119 return v850_interrupt_p;
2121 if (TREE_CODE (func) != FUNCTION_DECL)
2124 a = lookup_attribute ("interrupt_handler", DECL_ATTRIBUTES (func));
2130 a = lookup_attribute ("interrupt", DECL_ATTRIBUTES (func));
2131 ret = a != NULL_TREE;
2134 /* Its not safe to trust global variables until after function inlining has
2136 if (reload_completed | reload_in_progress)
2137 v850_interrupt_p = ret;
2144 v850_encode_data_area (tree decl, rtx symbol)
2148 /* Map explicit sections into the appropriate attribute */
2149 if (v850_get_data_area (decl) == DATA_AREA_NORMAL)
2151 if (DECL_SECTION_NAME (decl))
2153 const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
2155 if (streq (name, ".zdata") || streq (name, ".zbss"))
2156 v850_set_data_area (decl, DATA_AREA_ZDA);
2158 else if (streq (name, ".sdata") || streq (name, ".sbss"))
2159 v850_set_data_area (decl, DATA_AREA_SDA);
2161 else if (streq (name, ".tdata"))
2162 v850_set_data_area (decl, DATA_AREA_TDA);
2165 /* If no attribute, support -m{zda,sda,tda}=n */
2168 int size = int_size_in_bytes (TREE_TYPE (decl));
2172 else if (size <= small_memory [(int) SMALL_MEMORY_TDA].max)
2173 v850_set_data_area (decl, DATA_AREA_TDA);
2175 else if (size <= small_memory [(int) SMALL_MEMORY_SDA].max)
2176 v850_set_data_area (decl, DATA_AREA_SDA);
2178 else if (size <= small_memory [(int) SMALL_MEMORY_ZDA].max)
2179 v850_set_data_area (decl, DATA_AREA_ZDA);
2182 if (v850_get_data_area (decl) == DATA_AREA_NORMAL)
2186 flags = SYMBOL_REF_FLAGS (symbol);
2187 switch (v850_get_data_area (decl))
2189 case DATA_AREA_ZDA: flags |= SYMBOL_FLAG_ZDA; break;
2190 case DATA_AREA_TDA: flags |= SYMBOL_FLAG_TDA; break;
2191 case DATA_AREA_SDA: flags |= SYMBOL_FLAG_SDA; break;
2192 default: gcc_unreachable ();
2194 SYMBOL_REF_FLAGS (symbol) = flags;
2198 v850_encode_section_info (tree decl, rtx rtl, int first)
2200 default_encode_section_info (decl, rtl, first);
2202 if (TREE_CODE (decl) == VAR_DECL
2203 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
2204 v850_encode_data_area (decl, XEXP (rtl, 0));
2207 /* Construct a JR instruction to a routine that will perform the equivalent of
2208 the RTL passed in as an argument. This RTL is a function epilogue that
2209 pops registers off the stack and possibly releases some extra stack space
2210 as well. The code has already verified that the RTL matches these
2213 construct_restore_jr (rtx op)
2215 int count = XVECLEN (op, 0);
2217 unsigned long int mask;
2218 unsigned long int first;
2219 unsigned long int last;
2221 static char buff [100]; /* XXX */
2225 error ("bogus JR construction: %d", count);
2229 /* Work out how many bytes to pop off the stack before retrieving
2231 gcc_assert (GET_CODE (XVECEXP (op, 0, 1)) == SET);
2232 gcc_assert (GET_CODE (SET_SRC (XVECEXP (op, 0, 1))) == PLUS);
2233 gcc_assert (GET_CODE (XEXP (SET_SRC (XVECEXP (op, 0, 1)), 1)) == CONST_INT);
2235 stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 1)), 1));
2237 /* Each pop will remove 4 bytes from the stack.... */
2238 stack_bytes -= (count - 2) * 4;
2240 /* Make sure that the amount we are popping either 0 or 16 bytes. */
2241 if (stack_bytes != 0 && stack_bytes != 16)
2243 error ("bad amount of stack space removal: %d", stack_bytes);
2247 /* Now compute the bit mask of registers to push. */
2249 for (i = 2; i < count; i++)
2251 rtx vector_element = XVECEXP (op, 0, i);
2253 gcc_assert (GET_CODE (vector_element) == SET);
2254 gcc_assert (GET_CODE (SET_DEST (vector_element)) == REG);
2255 gcc_assert (register_is_ok_for_epilogue (SET_DEST (vector_element),
2258 mask |= 1 << REGNO (SET_DEST (vector_element));
2261 /* Scan for the first register to pop. */
2262 for (first = 0; first < 32; first++)
2264 if (mask & (1 << first))
2268 gcc_assert (first < 32);
2270 /* Discover the last register to pop. */
2271 if (mask & (1 << LINK_POINTER_REGNUM))
2273 gcc_assert (stack_bytes == 16);
2275 last = LINK_POINTER_REGNUM;
2279 gcc_assert (!stack_bytes);
2280 gcc_assert (mask & (1 << 29));
2285 /* Note, it is possible to have gaps in the register mask.
2286 We ignore this here, and generate a JR anyway. We will
2287 be popping more registers than is strictly necessary, but
2288 it does save code space. */
2290 if (TARGET_LONG_CALLS)
2295 sprintf (name, "__return_%s", reg_names [first]);
2297 sprintf (name, "__return_%s_%s", reg_names [first], reg_names [last]);
2299 sprintf (buff, "movhi hi(%s), r0, r6\n\tmovea lo(%s), r6, r6\n\tjmp r6",
2305 sprintf (buff, "jr __return_%s", reg_names [first]);
2307 sprintf (buff, "jr __return_%s_%s", reg_names [first], reg_names [last]);
2314 /* Construct a JARL instruction to a routine that will perform the equivalent
2315 of the RTL passed as a parameter. This RTL is a function prologue that
2316 saves some of the registers r20 - r31 onto the stack, and possibly acquires
2317 some stack space as well. The code has already verified that the RTL
2318 matches these requirements. */
2320 construct_save_jarl (rtx op)
2322 int count = XVECLEN (op, 0);
2324 unsigned long int mask;
2325 unsigned long int first;
2326 unsigned long int last;
2328 static char buff [100]; /* XXX */
2332 error ("bogus JARL construction: %d\n", count);
2337 gcc_assert (GET_CODE (XVECEXP (op, 0, 0)) == SET);
2338 gcc_assert (GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) == PLUS);
2339 gcc_assert (GET_CODE (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0)) == REG);
2340 gcc_assert (GET_CODE (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1)) == CONST_INT);
2342 /* Work out how many bytes to push onto the stack after storing the
2344 stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1));
2346 /* Each push will put 4 bytes from the stack.... */
2347 stack_bytes += (count - (TARGET_LONG_CALLS ? 3 : 2)) * 4;
2349 /* Make sure that the amount we are popping either 0 or 16 bytes. */
2350 if (stack_bytes != 0 && stack_bytes != -16)
2352 error ("bad amount of stack space removal: %d", stack_bytes);
2356 /* Now compute the bit mask of registers to push. */
2358 for (i = 1; i < count - (TARGET_LONG_CALLS ? 2 : 1); i++)
2360 rtx vector_element = XVECEXP (op, 0, i);
2362 gcc_assert (GET_CODE (vector_element) == SET);
2363 gcc_assert (GET_CODE (SET_SRC (vector_element)) == REG);
2364 gcc_assert (register_is_ok_for_epilogue (SET_SRC (vector_element),
2367 mask |= 1 << REGNO (SET_SRC (vector_element));
2370 /* Scan for the first register to push. */
2371 for (first = 0; first < 32; first++)
2373 if (mask & (1 << first))
2377 gcc_assert (first < 32);
2379 /* Discover the last register to push. */
2380 if (mask & (1 << LINK_POINTER_REGNUM))
2382 gcc_assert (stack_bytes == -16);
2384 last = LINK_POINTER_REGNUM;
2388 gcc_assert (!stack_bytes);
2389 gcc_assert (mask & (1 << 29));
2394 /* Note, it is possible to have gaps in the register mask.
2395 We ignore this here, and generate a JARL anyway. We will
2396 be pushing more registers than is strictly necessary, but
2397 it does save code space. */
2399 if (TARGET_LONG_CALLS)
2404 sprintf (name, "__save_%s", reg_names [first]);
2406 sprintf (name, "__save_%s_%s", reg_names [first], reg_names [last]);
2408 sprintf (buff, "movhi hi(%s), r0, r11\n\tmovea lo(%s), r11, r11\n\tjarl .+4, r10\n\tadd 4, r10\n\tjmp r11",
2414 sprintf (buff, "jarl __save_%s, r10", reg_names [first]);
2416 sprintf (buff, "jarl __save_%s_%s, r10", reg_names [first],
2423 extern tree last_assemble_variable_decl;
2424 extern int size_directive_output;
2426 /* A version of asm_output_aligned_bss() that copes with the special
2427 data areas of the v850. */
2429 v850_output_aligned_bss (FILE * file,
2432 unsigned HOST_WIDE_INT size,
2435 switch (v850_get_data_area (decl))
2438 switch_to_section (zbss_section);
2442 switch_to_section (sbss_section);
2446 switch_to_section (tdata_section);
2449 switch_to_section (bss_section);
2453 ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
2454 #ifdef ASM_DECLARE_OBJECT_NAME
2455 last_assemble_variable_decl = decl;
2456 ASM_DECLARE_OBJECT_NAME (file, name, decl);
2458 /* Standard thing is just output label for the object. */
2459 ASM_OUTPUT_LABEL (file, name);
2460 #endif /* ASM_DECLARE_OBJECT_NAME */
2461 ASM_OUTPUT_SKIP (file, size ? size : 1);
2464 /* Called via the macro ASM_OUTPUT_DECL_COMMON */
2466 v850_output_common (FILE * file,
2472 if (decl == NULL_TREE)
2474 fprintf (file, "%s", COMMON_ASM_OP);
2478 switch (v850_get_data_area (decl))
2481 fprintf (file, "%s", ZCOMMON_ASM_OP);
2485 fprintf (file, "%s", SCOMMON_ASM_OP);
2489 fprintf (file, "%s", TCOMMON_ASM_OP);
2493 fprintf (file, "%s", COMMON_ASM_OP);
2498 assemble_name (file, name);
2499 fprintf (file, ",%u,%u\n", size, align / BITS_PER_UNIT);
2502 /* Called via the macro ASM_OUTPUT_DECL_LOCAL */
2504 v850_output_local (FILE * file,
2510 fprintf (file, "%s", LOCAL_ASM_OP);
2511 assemble_name (file, name);
2512 fprintf (file, "\n");
2514 ASM_OUTPUT_ALIGNED_DECL_COMMON (file, decl, name, size, align);
2517 /* Add data area to the given declaration if a ghs data area pragma is
2518 currently in effect (#pragma ghs startXXX/endXXX). */
2520 v850_insert_attributes (tree decl, tree * attr_ptr ATTRIBUTE_UNUSED )
2523 && data_area_stack->data_area
2524 && current_function_decl == NULL_TREE
2525 && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == CONST_DECL)
2526 && v850_get_data_area (decl) == DATA_AREA_NORMAL)
2527 v850_set_data_area (decl, data_area_stack->data_area);
2529 /* Initialize the default names of the v850 specific sections,
2530 if this has not been done before. */
2532 if (GHS_default_section_names [(int) GHS_SECTION_KIND_SDATA] == NULL)
2534 GHS_default_section_names [(int) GHS_SECTION_KIND_SDATA]
2535 = build_string (sizeof (".sdata")-1, ".sdata");
2537 GHS_default_section_names [(int) GHS_SECTION_KIND_ROSDATA]
2538 = build_string (sizeof (".rosdata")-1, ".rosdata");
2540 GHS_default_section_names [(int) GHS_SECTION_KIND_TDATA]
2541 = build_string (sizeof (".tdata")-1, ".tdata");
2543 GHS_default_section_names [(int) GHS_SECTION_KIND_ZDATA]
2544 = build_string (sizeof (".zdata")-1, ".zdata");
2546 GHS_default_section_names [(int) GHS_SECTION_KIND_ROZDATA]
2547 = build_string (sizeof (".rozdata")-1, ".rozdata");
2550 if (current_function_decl == NULL_TREE
2551 && (TREE_CODE (decl) == VAR_DECL
2552 || TREE_CODE (decl) == CONST_DECL
2553 || TREE_CODE (decl) == FUNCTION_DECL)
2554 && (!DECL_EXTERNAL (decl) || DECL_INITIAL (decl))
2555 && !DECL_SECTION_NAME (decl))
2557 enum GHS_section_kind kind = GHS_SECTION_KIND_DEFAULT;
2558 tree chosen_section;
2560 if (TREE_CODE (decl) == FUNCTION_DECL)
2561 kind = GHS_SECTION_KIND_TEXT;
2564 /* First choose a section kind based on the data area of the decl. */
2565 switch (v850_get_data_area (decl))
2571 kind = ((TREE_READONLY (decl))
2572 ? GHS_SECTION_KIND_ROSDATA
2573 : GHS_SECTION_KIND_SDATA);
2577 kind = GHS_SECTION_KIND_TDATA;
2581 kind = ((TREE_READONLY (decl))
2582 ? GHS_SECTION_KIND_ROZDATA
2583 : GHS_SECTION_KIND_ZDATA);
2586 case DATA_AREA_NORMAL: /* default data area */
2587 if (TREE_READONLY (decl))
2588 kind = GHS_SECTION_KIND_RODATA;
2589 else if (DECL_INITIAL (decl))
2590 kind = GHS_SECTION_KIND_DATA;
2592 kind = GHS_SECTION_KIND_BSS;
2596 /* Now, if the section kind has been explicitly renamed,
2597 then attach a section attribute. */
2598 chosen_section = GHS_current_section_names [(int) kind];
2600 /* Otherwise, if this kind of section needs an explicit section
2601 attribute, then also attach one. */
2602 if (chosen_section == NULL)
2603 chosen_section = GHS_default_section_names [(int) kind];
2607 /* Only set the section name if specified by a pragma, because
2608 otherwise it will force those variables to get allocated storage
2609 in this module, rather than by the linker. */
2610 DECL_SECTION_NAME (decl) = chosen_section;
2615 /* Construct a DISPOSE instruction that is the equivalent of
2616 the given RTX. We have already verified that this should
2620 construct_dispose_instruction (rtx op)
2622 int count = XVECLEN (op, 0);
2624 unsigned long int mask;
2626 static char buff[ 100 ]; /* XXX */
2631 error ("bogus DISPOSE construction: %d", count);
2635 /* Work out how many bytes to pop off the
2636 stack before retrieving registers. */
2637 gcc_assert (GET_CODE (XVECEXP (op, 0, 1)) == SET);
2638 gcc_assert (GET_CODE (SET_SRC (XVECEXP (op, 0, 1))) == PLUS);
2639 gcc_assert (GET_CODE (XEXP (SET_SRC (XVECEXP (op, 0, 1)), 1)) == CONST_INT);
2641 stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 1)), 1));
2643 /* Each pop will remove 4 bytes from the stack.... */
2644 stack_bytes -= (count - 2) * 4;
2646 /* Make sure that the amount we are popping
2647 will fit into the DISPOSE instruction. */
2648 if (stack_bytes > 128)
2650 error ("too much stack space to dispose of: %d", stack_bytes);
2654 /* Now compute the bit mask of registers to push. */
2657 for (i = 2; i < count; i++)
2659 rtx vector_element = XVECEXP (op, 0, i);
2661 gcc_assert (GET_CODE (vector_element) == SET);
2662 gcc_assert (GET_CODE (SET_DEST (vector_element)) == REG);
2663 gcc_assert (register_is_ok_for_epilogue (SET_DEST (vector_element),
2666 if (REGNO (SET_DEST (vector_element)) == 2)
2669 mask |= 1 << REGNO (SET_DEST (vector_element));
2672 if (! TARGET_DISABLE_CALLT
2673 && (use_callt || stack_bytes == 0 || stack_bytes == 16))
2677 sprintf (buff, "callt ctoff(__callt_return_r2_r%d)", (mask & (1 << 31)) ? 31 : 29);
2682 for (i = 20; i < 32; i++)
2683 if (mask & (1 << i))
2687 sprintf (buff, "callt ctoff(__callt_return_r31c)");
2689 sprintf (buff, "callt ctoff(__callt_return_r%d_r%d%s)",
2690 i, (mask & (1 << 31)) ? 31 : 29, stack_bytes ? "c" : "");
2695 static char regs [100]; /* XXX */
2698 /* Generate the DISPOSE instruction. Note we could just issue the
2699 bit mask as a number as the assembler can cope with this, but for
2700 the sake of our readers we turn it into a textual description. */
2704 for (i = 20; i < 32; i++)
2706 if (mask & (1 << i))
2711 strcat (regs, ", ");
2716 strcat (regs, reg_names[ first ]);
2718 for (i++; i < 32; i++)
2719 if ((mask & (1 << i)) == 0)
2724 strcat (regs, " - ");
2725 strcat (regs, reg_names[ i - 1 ] );
2730 sprintf (buff, "dispose %d {%s}, r31", stack_bytes / 4, regs);
2736 /* Construct a PREPARE instruction that is the equivalent of
2737 the given RTL. We have already verified that this should
2741 construct_prepare_instruction (rtx op)
2743 int count = XVECLEN (op, 0);
2745 unsigned long int mask;
2747 static char buff[ 100 ]; /* XXX */
2752 error ("bogus PREPEARE construction: %d", count);
2756 /* Work out how many bytes to push onto
2757 the stack after storing the registers. */
2758 gcc_assert (GET_CODE (XVECEXP (op, 0, 0)) == SET);
2759 gcc_assert (GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) == PLUS);
2760 gcc_assert (GET_CODE (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1)) == CONST_INT);
2762 stack_bytes = INTVAL (XEXP (SET_SRC (XVECEXP (op, 0, 0)), 1));
2764 /* Each push will put 4 bytes from the stack. */
2765 stack_bytes += (count - 1) * 4;
2767 /* Make sure that the amount we are popping
2768 will fit into the DISPOSE instruction. */
2769 if (stack_bytes < -128)
2771 error ("too much stack space to prepare: %d", stack_bytes);
2775 /* Now compute the bit mask of registers to push. */
2777 for (i = 1; i < count; i++)
2779 rtx vector_element = XVECEXP (op, 0, i);
2781 gcc_assert (GET_CODE (vector_element) == SET);
2782 gcc_assert (GET_CODE (SET_SRC (vector_element)) == REG);
2783 gcc_assert (register_is_ok_for_epilogue (SET_SRC (vector_element),
2786 if (REGNO (SET_SRC (vector_element)) == 2)
2789 mask |= 1 << REGNO (SET_SRC (vector_element));
2792 if ((! TARGET_DISABLE_CALLT)
2793 && (use_callt || stack_bytes == 0 || stack_bytes == -16))
2797 sprintf (buff, "callt ctoff(__callt_save_r2_r%d)", (mask & (1 << 31)) ? 31 : 29 );
2801 for (i = 20; i < 32; i++)
2802 if (mask & (1 << i))
2806 sprintf (buff, "callt ctoff(__callt_save_r31c)");
2808 sprintf (buff, "callt ctoff(__callt_save_r%d_r%d%s)",
2809 i, (mask & (1 << 31)) ? 31 : 29, stack_bytes ? "c" : "");
2813 static char regs [100]; /* XXX */
2817 /* Generate the PREPARE instruction. Note we could just issue the
2818 bit mask as a number as the assembler can cope with this, but for
2819 the sake of our readers we turn it into a textual description. */
2823 for (i = 20; i < 32; i++)
2825 if (mask & (1 << i))
2830 strcat (regs, ", ");
2835 strcat (regs, reg_names[ first ]);
2837 for (i++; i < 32; i++)
2838 if ((mask & (1 << i)) == 0)
2843 strcat (regs, " - ");
2844 strcat (regs, reg_names[ i - 1 ] );
2849 sprintf (buff, "prepare {%s}, %d", regs, (- stack_bytes) / 4);
2855 /* Return an RTX indicating where the return address to the
2856 calling function can be found. */
2859 v850_return_addr (int count)
2864 return get_hard_reg_initial_val (Pmode, LINK_POINTER_REGNUM);
2867 /* Implement TARGET_ASM_INIT_SECTIONS. */
2870 v850_asm_init_sections (void)
2873 = get_unnamed_section (0, output_section_asm_op,
2874 "\t.section .rosdata,\"a\"");
2877 = get_unnamed_section (0, output_section_asm_op,
2878 "\t.section .rozdata,\"a\"");
2881 = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
2882 "\t.section .tdata,\"aw\"");
2885 = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
2886 "\t.section .zdata,\"aw\"");
2889 = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
2890 output_section_asm_op,
2891 "\t.section .zbss,\"aw\"");
2895 v850_select_section (tree exp,
2896 int reloc ATTRIBUTE_UNUSED,
2897 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
2899 if (TREE_CODE (exp) == VAR_DECL)
2902 if (!TREE_READONLY (exp)
2903 || TREE_SIDE_EFFECTS (exp)
2904 || !DECL_INITIAL (exp)
2905 || (DECL_INITIAL (exp) != error_mark_node
2906 && !TREE_CONSTANT (DECL_INITIAL (exp))))
2911 switch (v850_get_data_area (exp))
2914 return is_const ? rozdata_section : zdata_section;
2917 return tdata_section;
2920 return is_const ? rosdata_section : sdata_section;
2923 return is_const ? readonly_data_section : data_section;
2926 return readonly_data_section;
2929 /* Worker function for TARGET_RETURN_IN_MEMORY. */
2932 v850_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
2934 /* Return values > 8 bytes in length in memory. */
2935 return int_size_in_bytes (type) > 8 || TYPE_MODE (type) == BLKmode;
2938 /* Worker function for TARGET_SETUP_INCOMING_VARARGS. */
2941 v850_setup_incoming_varargs (CUMULATIVE_ARGS *ca,
2942 enum machine_mode mode ATTRIBUTE_UNUSED,
2943 tree type ATTRIBUTE_UNUSED,
2944 int *pretend_arg_size ATTRIBUTE_UNUSED,
2945 int second_time ATTRIBUTE_UNUSED)
2947 ca->anonymous_args = (!TARGET_GHS ? 1 : 0);
2950 #include "gt-v850.h"