Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/mn10300/mn10300.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
1 /* Subroutines for insn-output.c for Matsushita MN10300 series | 1 /* Subroutines for insn-output.c for Matsushita MN10300 series |
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
3 2005, 2006, 2007, 2008 Free Software Foundation, Inc. | 3 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
4 Contributed by Jeff Law (law@cygnus.com). | 4 Contributed by Jeff Law (law@cygnus.com). |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify | 8 GCC is free software; you can redistribute it and/or modify |
67 + 16 * (df_regs_ever_live_p (14) || df_regs_ever_live_p (15) \ | 67 + 16 * (df_regs_ever_live_p (14) || df_regs_ever_live_p (15) \ |
68 || df_regs_ever_live_p (16) || df_regs_ever_live_p (17))) | 68 || df_regs_ever_live_p (16) || df_regs_ever_live_p (17))) |
69 | 69 |
70 | 70 |
71 static bool mn10300_handle_option (size_t, const char *, int); | 71 static bool mn10300_handle_option (size_t, const char *, int); |
72 static bool mn10300_legitimate_address_p (enum machine_mode, rtx, bool); | |
72 static int mn10300_address_cost_1 (rtx, int *); | 73 static int mn10300_address_cost_1 (rtx, int *); |
73 static int mn10300_address_cost (rtx, bool); | 74 static int mn10300_address_cost (rtx, bool); |
74 static bool mn10300_rtx_costs (rtx, int, int, int *, bool); | 75 static bool mn10300_rtx_costs (rtx, int, int, int *, bool); |
75 static void mn10300_file_start (void); | 76 static void mn10300_file_start (void); |
76 static bool mn10300_return_in_memory (const_tree, const_tree); | 77 static bool mn10300_return_in_memory (const_tree, const_tree); |
77 static rtx mn10300_builtin_saveregs (void); | 78 static rtx mn10300_builtin_saveregs (void); |
78 static void mn10300_va_start (tree, rtx); | 79 static void mn10300_va_start (tree, rtx); |
80 static rtx mn10300_legitimize_address (rtx, rtx, enum machine_mode); | |
79 static bool mn10300_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, | 81 static bool mn10300_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, |
80 const_tree, bool); | 82 const_tree, bool); |
81 static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, | 83 static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode, |
82 tree, bool); | 84 tree, bool); |
85 static unsigned int mn10300_case_values_threshold (void); | |
86 static void mn10300_encode_section_info (tree, rtx, int); | |
87 static void mn10300_asm_trampoline_template (FILE *); | |
88 static void mn10300_trampoline_init (rtx, tree, rtx); | |
89 static rtx mn10300_function_value (const_tree, const_tree, bool); | |
90 static rtx mn10300_libcall_value (enum machine_mode, const_rtx); | |
83 | 91 |
84 /* Initialize the GCC target structure. */ | 92 /* Initialize the GCC target structure. */ |
85 #undef TARGET_ASM_ALIGNED_HI_OP | 93 #undef TARGET_ASM_ALIGNED_HI_OP |
86 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t" | 94 #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t" |
95 | |
96 #undef TARGET_LEGITIMIZE_ADDRESS | |
97 #define TARGET_LEGITIMIZE_ADDRESS mn10300_legitimize_address | |
87 | 98 |
88 #undef TARGET_RTX_COSTS | 99 #undef TARGET_RTX_COSTS |
89 #define TARGET_RTX_COSTS mn10300_rtx_costs | 100 #define TARGET_RTX_COSTS mn10300_rtx_costs |
90 #undef TARGET_ADDRESS_COST | 101 #undef TARGET_ADDRESS_COST |
91 #define TARGET_ADDRESS_COST mn10300_address_cost | 102 #define TARGET_ADDRESS_COST mn10300_address_cost |
117 #undef TARGET_EXPAND_BUILTIN_SAVEREGS | 128 #undef TARGET_EXPAND_BUILTIN_SAVEREGS |
118 #define TARGET_EXPAND_BUILTIN_SAVEREGS mn10300_builtin_saveregs | 129 #define TARGET_EXPAND_BUILTIN_SAVEREGS mn10300_builtin_saveregs |
119 #undef TARGET_EXPAND_BUILTIN_VA_START | 130 #undef TARGET_EXPAND_BUILTIN_VA_START |
120 #define TARGET_EXPAND_BUILTIN_VA_START mn10300_va_start | 131 #define TARGET_EXPAND_BUILTIN_VA_START mn10300_va_start |
121 | 132 |
122 static void mn10300_encode_section_info (tree, rtx, int); | 133 #undef TARGET_CASE_VALUES_THRESHOLD |
134 #define TARGET_CASE_VALUES_THRESHOLD mn10300_case_values_threshold | |
135 | |
136 #undef TARGET_LEGITIMATE_ADDRESS_P | |
137 #define TARGET_LEGITIMATE_ADDRESS_P mn10300_legitimate_address_p | |
138 | |
139 #undef TARGET_ASM_TRAMPOLINE_TEMPLATE | |
140 #define TARGET_ASM_TRAMPOLINE_TEMPLATE mn10300_asm_trampoline_template | |
141 #undef TARGET_TRAMPOLINE_INIT | |
142 #define TARGET_TRAMPOLINE_INIT mn10300_trampoline_init | |
143 | |
144 #undef TARGET_FUNCTION_VALUE | |
145 #define TARGET_FUNCTION_VALUE mn10300_function_value | |
146 #undef TARGET_LIBCALL_VALUE | |
147 #define TARGET_LIBCALL_VALUE mn10300_libcall_value | |
148 | |
123 struct gcc_target targetm = TARGET_INITIALIZER; | 149 struct gcc_target targetm = TARGET_INITIALIZER; |
124 | 150 |
125 /* Implement TARGET_HANDLE_OPTION. */ | 151 /* Implement TARGET_HANDLE_OPTION. */ |
126 | 152 |
127 static bool | 153 static bool |
1603 $d0 for integer functions, $a0 for pointers, or a PARALLEL of both | 1629 $d0 for integer functions, $a0 for pointers, or a PARALLEL of both |
1604 $d0 and $a0 if the -mreturn-pointer-on-do flag is set. Note that | 1630 $d0 and $a0 if the -mreturn-pointer-on-do flag is set. Note that |
1605 we only return the PARALLEL for outgoing values; we do not want | 1631 we only return the PARALLEL for outgoing values; we do not want |
1606 callers relying on this extra copy. */ | 1632 callers relying on this extra copy. */ |
1607 | 1633 |
1608 rtx | 1634 static rtx |
1609 mn10300_function_value (const_tree valtype, const_tree func, int outgoing) | 1635 mn10300_function_value (const_tree valtype, |
1636 const_tree fn_decl_or_type ATTRIBUTE_UNUSED, | |
1637 bool outgoing) | |
1610 { | 1638 { |
1611 rtx rv; | 1639 rtx rv; |
1612 enum machine_mode mode = TYPE_MODE (valtype); | 1640 enum machine_mode mode = TYPE_MODE (valtype); |
1613 | 1641 |
1614 if (! POINTER_TYPE_P (valtype)) | 1642 if (! POINTER_TYPE_P (valtype)) |
1626 XVECEXP (rv, 0, 1) | 1654 XVECEXP (rv, 0, 1) |
1627 = gen_rtx_EXPR_LIST (VOIDmode, | 1655 = gen_rtx_EXPR_LIST (VOIDmode, |
1628 gen_rtx_REG (mode, FIRST_DATA_REGNUM), | 1656 gen_rtx_REG (mode, FIRST_DATA_REGNUM), |
1629 GEN_INT (0)); | 1657 GEN_INT (0)); |
1630 return rv; | 1658 return rv; |
1659 } | |
1660 | |
1661 /* Implements TARGET_LIBCALL_VALUE. */ | |
1662 | |
1663 static rtx | |
1664 mn10300_libcall_value (enum machine_mode mode, | |
1665 const_rtx fun ATTRIBUTE_UNUSED) | |
1666 { | |
1667 return gen_rtx_REG (mode, FIRST_DATA_REGNUM); | |
1668 } | |
1669 | |
1670 /* Implements FUNCTION_VALUE_REGNO_P. */ | |
1671 | |
1672 bool | |
1673 mn10300_function_value_regno_p (const unsigned int regno) | |
1674 { | |
1675 return (regno == FIRST_DATA_REGNUM || regno == FIRST_ADDRESS_REGNUM); | |
1631 } | 1676 } |
1632 | 1677 |
1633 /* Output a tst insn. */ | 1678 /* Output a tst insn. */ |
1634 const char * | 1679 const char * |
1635 output_tst (rtx operand, rtx insn) | 1680 output_tst (rtx operand, rtx insn) |
1780 This macro is used in only one place: `memory_address' in explow.c. | 1825 This macro is used in only one place: `memory_address' in explow.c. |
1781 | 1826 |
1782 OLDX is the address as it was before break_out_memory_refs was called. | 1827 OLDX is the address as it was before break_out_memory_refs was called. |
1783 In some cases it is useful to look at this to decide what needs to be done. | 1828 In some cases it is useful to look at this to decide what needs to be done. |
1784 | 1829 |
1785 MODE and WIN are passed so that this macro can use | |
1786 GO_IF_LEGITIMATE_ADDRESS. | |
1787 | |
1788 Normally it is always safe for this macro to do nothing. It exists to | 1830 Normally it is always safe for this macro to do nothing. It exists to |
1789 recognize opportunities to optimize the output. | 1831 recognize opportunities to optimize the output. |
1790 | 1832 |
1791 But on a few ports with segmented architectures and indexed addressing | 1833 But on a few ports with segmented architectures and indexed addressing |
1792 (mn10300, hppa) it is used to rewrite certain problematical addresses. */ | 1834 (mn10300, hppa) it is used to rewrite certain problematical addresses. */ |
1793 rtx | 1835 rtx |
1794 legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, | 1836 mn10300_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, |
1795 enum machine_mode mode ATTRIBUTE_UNUSED) | 1837 enum machine_mode mode ATTRIBUTE_UNUSED) |
1796 { | 1838 { |
1797 if (flag_pic && ! legitimate_pic_operand_p (x)) | 1839 if (flag_pic && ! legitimate_pic_operand_p (x)) |
1798 x = legitimize_pic_address (oldx, NULL_RTX); | 1840 x = legitimize_pic_address (oldx, NULL_RTX); |
1799 | 1841 |
1800 /* Uh-oh. We might have an address for x[n-100000]. This needs | 1842 /* Uh-oh. We might have an address for x[n-100000]. This needs |
1890 | 1932 |
1891 return 1; | 1933 return 1; |
1892 } | 1934 } |
1893 | 1935 |
1894 /* Return TRUE if the address X, taken from a (MEM:MODE X) rtx, is | 1936 /* Return TRUE if the address X, taken from a (MEM:MODE X) rtx, is |
1895 legitimate, and FALSE otherwise. */ | 1937 legitimate, and FALSE otherwise. |
1938 | |
1939 On the mn10300, the value in the address register must be | |
1940 in the same memory space/segment as the effective address. | |
1941 | |
1942 This is problematical for reload since it does not understand | |
1943 that base+index != index+base in a memory reference. | |
1944 | |
1945 Note it is still possible to use reg+reg addressing modes, | |
1946 it's just much more difficult. For a discussion of a possible | |
1947 workaround and solution, see the comments in pa.c before the | |
1948 function record_unscaled_index_insn_codes. */ | |
1949 | |
1896 bool | 1950 bool |
1897 legitimate_address_p (enum machine_mode mode, rtx x, int strict) | 1951 mn10300_legitimate_address_p (enum machine_mode mode, rtx x, bool strict) |
1898 { | 1952 { |
1899 if (CONSTANT_ADDRESS_P (x) | 1953 if (CONSTANT_ADDRESS_P (x) |
1900 && (! flag_pic || legitimate_pic_operand_p (x))) | 1954 && (! flag_pic || legitimate_pic_operand_p (x))) |
1901 return TRUE; | 1955 return TRUE; |
1902 | 1956 |
2020 { | 2074 { |
2021 switch (code) | 2075 switch (code) |
2022 { | 2076 { |
2023 case CONST_INT: | 2077 case CONST_INT: |
2024 /* Zeros are extremely cheap. */ | 2078 /* Zeros are extremely cheap. */ |
2025 if (INTVAL (x) == 0 && outer_code == SET) | 2079 if (INTVAL (x) == 0 && (outer_code == SET || outer_code == COMPARE)) |
2026 *total = 0; | 2080 *total = 0; |
2027 /* If it fits in 8 bits, then it's still relatively cheap. */ | 2081 /* If it fits in 8 bits, then it's still relatively cheap. */ |
2028 else if (INT_8_BITS (INTVAL (x))) | 2082 else if (INT_8_BITS (INTVAL (x))) |
2029 *total = 1; | 2083 *total = 1; |
2030 /* This is the "base" cost, includes constants where either the | 2084 /* This is the "base" cost, includes constants where either the |
2049 /* We don't optimize CONST_DOUBLEs well nor do we relax them well, | 2103 /* We don't optimize CONST_DOUBLEs well nor do we relax them well, |
2050 so their cost is very high. */ | 2104 so their cost is very high. */ |
2051 *total = 8; | 2105 *total = 8; |
2052 return true; | 2106 return true; |
2053 | 2107 |
2108 case ZERO_EXTRACT: | |
2109 /* This is cheap, we can use btst. */ | |
2110 if (outer_code == COMPARE) | |
2111 *total = 0; | |
2112 return false; | |
2113 | |
2054 /* ??? This probably needs more work. */ | 2114 /* ??? This probably needs more work. */ |
2055 case MOD: | 2115 case MOD: |
2056 case DIV: | 2116 case DIV: |
2057 case MULT: | 2117 case MULT: |
2058 *total = 8; | 2118 *total = 8; |
2124 return; | 2184 return; |
2125 | 2185 |
2126 if (flag_pic) | 2186 if (flag_pic) |
2127 SYMBOL_REF_FLAG (symbol) = (*targetm.binds_local_p) (decl); | 2187 SYMBOL_REF_FLAG (symbol) = (*targetm.binds_local_p) (decl); |
2128 } | 2188 } |
2189 | |
2190 /* Dispatch tables on the mn10300 are extremely expensive in terms of code | |
2191 and readonly data size. So we crank up the case threshold value to | |
2192 encourage a series of if/else comparisons to implement many small switch | |
2193 statements. In theory, this value could be increased much more if we | |
2194 were solely optimizing for space, but we keep it "reasonable" to avoid | |
2195 serious code efficiency lossage. */ | |
2196 | |
2197 unsigned int mn10300_case_values_threshold (void) | |
2198 { | |
2199 return 6; | |
2200 } | |
2201 | |
2202 /* Worker function for TARGET_ASM_TRAMPOLINE_TEMPLATE. */ | |
2203 | |
2204 static void | |
2205 mn10300_asm_trampoline_template (FILE *f) | |
2206 { | |
2207 fprintf (f, "\tadd -4,sp\n"); | |
2208 fprintf (f, "\t.long 0x0004fffa\n"); | |
2209 fprintf (f, "\tmov (0,sp),a0\n"); | |
2210 fprintf (f, "\tadd 4,sp\n"); | |
2211 fprintf (f, "\tmov (13,a0),a1\n"); | |
2212 fprintf (f, "\tmov (17,a0),a0\n"); | |
2213 fprintf (f, "\tjmp (a0)\n"); | |
2214 fprintf (f, "\t.long 0\n"); | |
2215 fprintf (f, "\t.long 0\n"); | |
2216 } | |
2217 | |
2218 /* Worker function for TARGET_TRAMPOLINE_INIT. */ | |
2219 | |
2220 static void | |
2221 mn10300_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) | |
2222 { | |
2223 rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); | |
2224 rtx mem; | |
2225 | |
2226 emit_block_move (m_tramp, assemble_trampoline_template (), | |
2227 GEN_INT (TRAMPOLINE_SIZE), BLOCK_OP_NORMAL); | |
2228 | |
2229 mem = adjust_address (m_tramp, SImode, 0x14); | |
2230 emit_move_insn (mem, chain_value); | |
2231 mem = adjust_address (m_tramp, SImode, 0x18); | |
2232 emit_move_insn (mem, fnaddr); | |
2233 } |