Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/mep/mep.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
41 #include "function.h" | 41 #include "function.h" |
42 #include "optabs.h" | 42 #include "optabs.h" |
43 #include "reload.h" | 43 #include "reload.h" |
44 #include "tm_p.h" | 44 #include "tm_p.h" |
45 #include "ggc.h" | 45 #include "ggc.h" |
46 #include "toplev.h" | 46 #include "diagnostic-core.h" |
47 #include "integrate.h" | 47 #include "integrate.h" |
48 #include "target.h" | 48 #include "target.h" |
49 #include "target-def.h" | 49 #include "target-def.h" |
50 #include "langhooks.h" | 50 #include "langhooks.h" |
51 #include "df.h" | 51 #include "df.h" |
118 int asms_without_operands; | 118 int asms_without_operands; |
119 }; | 119 }; |
120 | 120 |
121 #define MEP_CONTROL_REG(x) \ | 121 #define MEP_CONTROL_REG(x) \ |
122 (GET_CODE (x) == REG && ANY_CONTROL_REGNO_P (REGNO (x))) | 122 (GET_CODE (x) == REG && ANY_CONTROL_REGNO_P (REGNO (x))) |
123 | |
124 static const struct attribute_spec mep_attribute_table[11]; | |
125 | 123 |
126 static GTY(()) section * based_section; | 124 static GTY(()) section * based_section; |
127 static GTY(()) section * tinybss_section; | 125 static GTY(()) section * tinybss_section; |
128 static GTY(()) section * far_section; | 126 static GTY(()) section * far_section; |
129 static GTY(()) section * farbss_section; | 127 static GTY(()) section * farbss_section; |
215 static int mep_address_cost (rtx, bool); | 213 static int mep_address_cost (rtx, bool); |
216 static void mep_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode, | 214 static void mep_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode, |
217 tree, int *, int); | 215 tree, int *, int); |
218 static bool mep_pass_by_reference (CUMULATIVE_ARGS * cum, enum machine_mode, | 216 static bool mep_pass_by_reference (CUMULATIVE_ARGS * cum, enum machine_mode, |
219 const_tree, bool); | 217 const_tree, bool); |
218 static rtx mep_function_arg (CUMULATIVE_ARGS *, enum machine_mode, | |
219 const_tree, bool); | |
220 static void mep_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, | |
221 const_tree, bool); | |
220 static bool mep_vector_mode_supported_p (enum machine_mode); | 222 static bool mep_vector_mode_supported_p (enum machine_mode); |
221 static bool mep_handle_option (size_t, const char *, int); | 223 static bool mep_handle_option (size_t, const char *, int); |
222 static rtx mep_allocate_initial_value (rtx); | 224 static rtx mep_allocate_initial_value (rtx); |
223 static void mep_asm_init_sections (void); | 225 static void mep_asm_init_sections (void); |
224 static int mep_comp_type_attributes (const_tree, const_tree); | 226 static int mep_comp_type_attributes (const_tree, const_tree); |
226 static rtx mep_expand_builtin_saveregs (void); | 228 static rtx mep_expand_builtin_saveregs (void); |
227 static tree mep_build_builtin_va_list (void); | 229 static tree mep_build_builtin_va_list (void); |
228 static void mep_expand_va_start (tree, rtx); | 230 static void mep_expand_va_start (tree, rtx); |
229 static tree mep_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *); | 231 static tree mep_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *); |
230 static bool mep_can_eliminate (const int, const int); | 232 static bool mep_can_eliminate (const int, const int); |
233 static void mep_conditional_register_usage (void); | |
231 static void mep_trampoline_init (rtx, tree, rtx); | 234 static void mep_trampoline_init (rtx, tree, rtx); |
232 | |
233 /* Initialize the GCC target structure. */ | |
234 | |
235 #undef TARGET_ASM_FUNCTION_PROLOGUE | |
236 #define TARGET_ASM_FUNCTION_PROLOGUE mep_start_function | |
237 #undef TARGET_ATTRIBUTE_TABLE | |
238 #define TARGET_ATTRIBUTE_TABLE mep_attribute_table | |
239 #undef TARGET_COMP_TYPE_ATTRIBUTES | |
240 #define TARGET_COMP_TYPE_ATTRIBUTES mep_comp_type_attributes | |
241 #undef TARGET_INSERT_ATTRIBUTES | |
242 #define TARGET_INSERT_ATTRIBUTES mep_insert_attributes | |
243 #undef TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P | |
244 #define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P mep_function_attribute_inlinable_p | |
245 #undef TARGET_CAN_INLINE_P | |
246 #define TARGET_CAN_INLINE_P mep_can_inline_p | |
247 #undef TARGET_SECTION_TYPE_FLAGS | |
248 #define TARGET_SECTION_TYPE_FLAGS mep_section_type_flags | |
249 #undef TARGET_ASM_NAMED_SECTION | |
250 #define TARGET_ASM_NAMED_SECTION mep_asm_named_section | |
251 #undef TARGET_INIT_BUILTINS | |
252 #define TARGET_INIT_BUILTINS mep_init_builtins | |
253 #undef TARGET_EXPAND_BUILTIN | |
254 #define TARGET_EXPAND_BUILTIN mep_expand_builtin | |
255 #undef TARGET_SCHED_ADJUST_COST | |
256 #define TARGET_SCHED_ADJUST_COST mep_adjust_cost | |
257 #undef TARGET_SCHED_ISSUE_RATE | |
258 #define TARGET_SCHED_ISSUE_RATE mep_issue_rate | |
259 #undef TARGET_SCHED_REORDER | |
260 #define TARGET_SCHED_REORDER mep_sched_reorder | |
261 #undef TARGET_STRIP_NAME_ENCODING | |
262 #define TARGET_STRIP_NAME_ENCODING mep_strip_name_encoding | |
263 #undef TARGET_ASM_SELECT_SECTION | |
264 #define TARGET_ASM_SELECT_SECTION mep_select_section | |
265 #undef TARGET_ASM_UNIQUE_SECTION | |
266 #define TARGET_ASM_UNIQUE_SECTION mep_unique_section | |
267 #undef TARGET_ENCODE_SECTION_INFO | |
268 #define TARGET_ENCODE_SECTION_INFO mep_encode_section_info | |
269 #undef TARGET_FUNCTION_OK_FOR_SIBCALL | |
270 #define TARGET_FUNCTION_OK_FOR_SIBCALL mep_function_ok_for_sibcall | |
271 #undef TARGET_RTX_COSTS | |
272 #define TARGET_RTX_COSTS mep_rtx_cost | |
273 #undef TARGET_ADDRESS_COST | |
274 #define TARGET_ADDRESS_COST mep_address_cost | |
275 #undef TARGET_MACHINE_DEPENDENT_REORG | |
276 #define TARGET_MACHINE_DEPENDENT_REORG mep_reorg | |
277 #undef TARGET_SETUP_INCOMING_VARARGS | |
278 #define TARGET_SETUP_INCOMING_VARARGS mep_setup_incoming_varargs | |
279 #undef TARGET_PASS_BY_REFERENCE | |
280 #define TARGET_PASS_BY_REFERENCE mep_pass_by_reference | |
281 #undef TARGET_VECTOR_MODE_SUPPORTED_P | |
282 #define TARGET_VECTOR_MODE_SUPPORTED_P mep_vector_mode_supported_p | |
283 #undef TARGET_HANDLE_OPTION | |
284 #define TARGET_HANDLE_OPTION mep_handle_option | |
285 #undef TARGET_DEFAULT_TARGET_FLAGS | |
286 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT | |
287 #undef TARGET_ALLOCATE_INITIAL_VALUE | |
288 #define TARGET_ALLOCATE_INITIAL_VALUE mep_allocate_initial_value | |
289 #undef TARGET_ASM_INIT_SECTIONS | |
290 #define TARGET_ASM_INIT_SECTIONS mep_asm_init_sections | |
291 #undef TARGET_RETURN_IN_MEMORY | |
292 #define TARGET_RETURN_IN_MEMORY mep_return_in_memory | |
293 #undef TARGET_NARROW_VOLATILE_BITFIELD | |
294 #define TARGET_NARROW_VOLATILE_BITFIELD mep_narrow_volatile_bitfield | |
295 #undef TARGET_EXPAND_BUILTIN_SAVEREGS | |
296 #define TARGET_EXPAND_BUILTIN_SAVEREGS mep_expand_builtin_saveregs | |
297 #undef TARGET_BUILD_BUILTIN_VA_LIST | |
298 #define TARGET_BUILD_BUILTIN_VA_LIST mep_build_builtin_va_list | |
299 #undef TARGET_EXPAND_BUILTIN_VA_START | |
300 #define TARGET_EXPAND_BUILTIN_VA_START mep_expand_va_start | |
301 #undef TARGET_GIMPLIFY_VA_ARG_EXPR | |
302 #define TARGET_GIMPLIFY_VA_ARG_EXPR mep_gimplify_va_arg_expr | |
303 #undef TARGET_CAN_ELIMINATE | |
304 #define TARGET_CAN_ELIMINATE mep_can_eliminate | |
305 #undef TARGET_TRAMPOLINE_INIT | |
306 #define TARGET_TRAMPOLINE_INIT mep_trampoline_init | |
307 | |
308 struct gcc_target targetm = TARGET_INITIALIZER; | |
309 | 235 |
310 #define WANT_GCC_DEFINITIONS | 236 #define WANT_GCC_DEFINITIONS |
311 #include "mep-intrin.h" | 237 #include "mep-intrin.h" |
312 #undef WANT_GCC_DEFINITIONS | 238 #undef WANT_GCC_DEFINITIONS |
313 | 239 |
350 if (mep_leaf_registers[0] != enable) | 276 if (mep_leaf_registers[0] != enable) |
351 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) | 277 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) |
352 mep_leaf_registers[i] = enable; | 278 mep_leaf_registers[i] = enable; |
353 } | 279 } |
354 | 280 |
355 void | 281 static void |
356 mep_conditional_register_usage (char *fixed_regs, char *call_used_regs) | 282 mep_conditional_register_usage (void) |
357 { | 283 { |
358 int i; | 284 int i; |
359 | 285 |
360 if (!TARGET_OPT_MULT && !TARGET_OPT_DIV) | 286 if (!TARGET_OPT_MULT && !TARGET_OPT_DIV) |
361 { | 287 { |
367 | 293 |
368 for (i = FIRST_SHADOW_REGISTER; i <= LAST_SHADOW_REGISTER; i++) | 294 for (i = FIRST_SHADOW_REGISTER; i <= LAST_SHADOW_REGISTER; i++) |
369 global_regs[i] = 1; | 295 global_regs[i] = 1; |
370 } | 296 } |
371 | 297 |
372 void | 298 |
373 mep_optimization_options (void) | 299 static const struct default_options mep_option_optimization_table[] = |
374 { | 300 { |
375 /* The first scheduling pass often increases register pressure and tends | 301 /* The first scheduling pass often increases register pressure and |
376 to result in more spill code. Only run it when specifically asked. */ | 302 tends to result in more spill code. Only run it when |
377 flag_schedule_insns = 0; | 303 specifically asked. */ |
378 | 304 { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 }, |
379 /* Using $fp doesn't gain us much, even when debugging is important. */ | 305 |
380 flag_omit_frame_pointer = 1; | 306 /* Using $fp doesn't gain us much, even when debugging is |
381 } | 307 important. */ |
382 | 308 { OPT_LEVELS_ALL, OPT_fomit_frame_pointer, NULL, 1 }, |
383 void | 309 |
384 mep_override_options (void) | 310 { OPT_LEVELS_NONE, 0, NULL, 0 } |
311 }; | |
312 | |
313 static void | |
314 mep_option_override (void) | |
385 { | 315 { |
386 if (flag_pic == 1) | 316 if (flag_pic == 1) |
387 warning (OPT_fpic, "-fpic is not supported"); | 317 warning (OPT_fpic, "-fpic is not supported"); |
388 if (flag_pic == 2) | 318 if (flag_pic == 2) |
389 warning (OPT_fPIC, "-fPIC is not supported"); | 319 warning (OPT_fPIC, "-fPIC is not supported"); |
1338 return false; | 1268 return false; |
1339 } | 1269 } |
1340 | 1270 |
1341 int | 1271 int |
1342 mep_legitimize_reload_address (rtx *x, enum machine_mode mode, int opnum, | 1272 mep_legitimize_reload_address (rtx *x, enum machine_mode mode, int opnum, |
1343 enum reload_type type, | 1273 int type_i, |
1344 int ind_levels ATTRIBUTE_UNUSED) | 1274 int ind_levels ATTRIBUTE_UNUSED) |
1345 { | 1275 { |
1276 enum reload_type type = (enum reload_type) type_i; | |
1277 | |
1346 if (GET_CODE (*x) == PLUS | 1278 if (GET_CODE (*x) == PLUS |
1347 && GET_CODE (XEXP (*x, 0)) == MEM | 1279 && GET_CODE (XEXP (*x, 0)) == MEM |
1348 && GET_CODE (XEXP (*x, 1)) == REG) | 1280 && GET_CODE (XEXP (*x, 1)) == REG) |
1349 { | 1281 { |
1350 /* GCC will by default copy the MEM into a REG, which results in | 1282 /* GCC will by default copy the MEM into a REG, which results in |
2165 return GENERAL_REGS; | 2097 return GENERAL_REGS; |
2166 } | 2098 } |
2167 | 2099 |
2168 /* Copying X to register in RCLASS. */ | 2100 /* Copying X to register in RCLASS. */ |
2169 | 2101 |
2170 int | 2102 enum reg_class |
2171 mep_secondary_input_reload_class (enum reg_class rclass, | 2103 mep_secondary_input_reload_class (enum reg_class rclass, |
2172 enum machine_mode mode ATTRIBUTE_UNUSED, | 2104 enum machine_mode mode ATTRIBUTE_UNUSED, |
2173 rtx x) | 2105 rtx x) |
2174 { | 2106 { |
2175 int rv = NO_REGS; | 2107 int rv = NO_REGS; |
2186 rv = GENERAL_REGS; | 2118 rv = GENERAL_REGS; |
2187 | 2119 |
2188 #if DEBUG_RELOAD | 2120 #if DEBUG_RELOAD |
2189 fprintf (stderr, " - requires %s\n", reg_class_names[rv]); | 2121 fprintf (stderr, " - requires %s\n", reg_class_names[rv]); |
2190 #endif | 2122 #endif |
2191 return rv; | 2123 return (enum reg_class) rv; |
2192 } | 2124 } |
2193 | 2125 |
2194 /* Copying register in RCLASS to X. */ | 2126 /* Copying register in RCLASS to X. */ |
2195 | 2127 |
2196 int | 2128 enum reg_class |
2197 mep_secondary_output_reload_class (enum reg_class rclass, | 2129 mep_secondary_output_reload_class (enum reg_class rclass, |
2198 enum machine_mode mode ATTRIBUTE_UNUSED, | 2130 enum machine_mode mode ATTRIBUTE_UNUSED, |
2199 rtx x) | 2131 rtx x) |
2200 { | 2132 { |
2201 int rv = NO_REGS; | 2133 int rv = NO_REGS; |
2213 | 2145 |
2214 #if DEBUG_RELOAD | 2146 #if DEBUG_RELOAD |
2215 fprintf (stderr, " - requires %s\n", reg_class_names[rv]); | 2147 fprintf (stderr, " - requires %s\n", reg_class_names[rv]); |
2216 #endif | 2148 #endif |
2217 | 2149 |
2218 return rv; | 2150 return (enum reg_class) rv; |
2219 } | 2151 } |
2220 | 2152 |
2221 /* Implement SECONDARY_MEMORY_NEEDED. */ | 2153 /* Implement SECONDARY_MEMORY_NEEDED. */ |
2222 | 2154 |
2223 bool | 2155 bool |
2367 /* Functions to save and restore machine-specific function data. */ | 2299 /* Functions to save and restore machine-specific function data. */ |
2368 | 2300 |
2369 static struct machine_function * | 2301 static struct machine_function * |
2370 mep_init_machine_status (void) | 2302 mep_init_machine_status (void) |
2371 { | 2303 { |
2372 struct machine_function *f; | 2304 return ggc_alloc_cleared_machine_function (); |
2373 | |
2374 f = (struct machine_function *) ggc_alloc_cleared (sizeof (struct machine_function)); | |
2375 | |
2376 return f; | |
2377 } | 2305 } |
2378 | 2306 |
2379 static rtx | 2307 static rtx |
2380 mep_allocate_initial_value (rtx reg) | 2308 mep_allocate_initial_value (rtx reg) |
2381 { | 2309 { |
3478 case CONST_DOUBLE: | 3406 case CONST_DOUBLE: |
3479 fprintf(file, "[const_double 0x%lx]", | 3407 fprintf(file, "[const_double 0x%lx]", |
3480 (unsigned long) CONST_DOUBLE_HIGH(r)); | 3408 (unsigned long) CONST_DOUBLE_HIGH(r)); |
3481 break; | 3409 break; |
3482 case SYMBOL_REF: | 3410 case SYMBOL_REF: |
3483 real_name = TARGET_STRIP_NAME_ENCODING (XSTR (r, 0)); | 3411 real_name = targetm.strip_name_encoding (XSTR (r, 0)); |
3484 assemble_name (file, real_name); | 3412 assemble_name (file, real_name); |
3485 break; | 3413 break; |
3486 case LABEL_REF: | 3414 case LABEL_REF: |
3487 output_asm_label (r); | 3415 output_asm_label (r); |
3488 break; | 3416 break; |
3612 DECL_FIELD_CONTEXT (f_next_gp_limit) = record; | 3540 DECL_FIELD_CONTEXT (f_next_gp_limit) = record; |
3613 DECL_FIELD_CONTEXT (f_next_cop) = record; | 3541 DECL_FIELD_CONTEXT (f_next_cop) = record; |
3614 DECL_FIELD_CONTEXT (f_next_stack) = record; | 3542 DECL_FIELD_CONTEXT (f_next_stack) = record; |
3615 | 3543 |
3616 TYPE_FIELDS (record) = f_next_gp; | 3544 TYPE_FIELDS (record) = f_next_gp; |
3617 TREE_CHAIN (f_next_gp) = f_next_gp_limit; | 3545 DECL_CHAIN (f_next_gp) = f_next_gp_limit; |
3618 TREE_CHAIN (f_next_gp_limit) = f_next_cop; | 3546 DECL_CHAIN (f_next_gp_limit) = f_next_cop; |
3619 TREE_CHAIN (f_next_cop) = f_next_stack; | 3547 DECL_CHAIN (f_next_cop) = f_next_stack; |
3620 | 3548 |
3621 layout_type (record); | 3549 layout_type (record); |
3622 | 3550 |
3623 return record; | 3551 return record; |
3624 } | 3552 } |
3632 int ns; | 3560 int ns; |
3633 | 3561 |
3634 ns = cfun->machine->arg_regs_to_save; | 3562 ns = cfun->machine->arg_regs_to_save; |
3635 | 3563 |
3636 f_next_gp = TYPE_FIELDS (va_list_type_node); | 3564 f_next_gp = TYPE_FIELDS (va_list_type_node); |
3637 f_next_gp_limit = TREE_CHAIN (f_next_gp); | 3565 f_next_gp_limit = DECL_CHAIN (f_next_gp); |
3638 f_next_cop = TREE_CHAIN (f_next_gp_limit); | 3566 f_next_cop = DECL_CHAIN (f_next_gp_limit); |
3639 f_next_stack = TREE_CHAIN (f_next_cop); | 3567 f_next_stack = DECL_CHAIN (f_next_cop); |
3640 | 3568 |
3641 next_gp = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp), valist, f_next_gp, | 3569 next_gp = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp), valist, f_next_gp, |
3642 NULL_TREE); | 3570 NULL_TREE); |
3643 next_gp_limit = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp_limit), | 3571 next_gp_limit = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp_limit), |
3644 valist, f_next_gp_limit, NULL_TREE); | 3572 valist, f_next_gp_limit, NULL_TREE); |
3698 size = 4; | 3626 size = 4; |
3699 } | 3627 } |
3700 rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD; | 3628 rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD; |
3701 | 3629 |
3702 f_next_gp = TYPE_FIELDS (va_list_type_node); | 3630 f_next_gp = TYPE_FIELDS (va_list_type_node); |
3703 f_next_gp_limit = TREE_CHAIN (f_next_gp); | 3631 f_next_gp_limit = DECL_CHAIN (f_next_gp); |
3704 f_next_cop = TREE_CHAIN (f_next_gp_limit); | 3632 f_next_cop = DECL_CHAIN (f_next_gp_limit); |
3705 f_next_stack = TREE_CHAIN (f_next_cop); | 3633 f_next_stack = DECL_CHAIN (f_next_cop); |
3706 | 3634 |
3707 next_gp = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp), valist, f_next_gp, | 3635 next_gp = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp), valist, f_next_gp, |
3708 NULL_TREE); | 3636 NULL_TREE); |
3709 next_gp_limit = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp_limit), | 3637 next_gp_limit = build3 (COMPONENT_REF, TREE_TYPE (f_next_gp_limit), |
3710 valist, f_next_gp_limit, NULL_TREE); | 3638 valist, f_next_gp_limit, NULL_TREE); |
3797 pcum->vliw = 1; | 3725 pcum->vliw = 1; |
3798 else | 3726 else |
3799 pcum->vliw = 0; | 3727 pcum->vliw = 0; |
3800 } | 3728 } |
3801 | 3729 |
3802 rtx | 3730 /* The ABI is thus: Arguments are in $1, $2, $3, $4, stack. Arguments |
3803 mep_function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, | 3731 larger than 4 bytes are passed indirectly. Return value in 0, |
3804 tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED) | 3732 unless bigger than 4 bytes, then the caller passes a pointer as the |
3733 first arg. For varargs, we copy $1..$4 to the stack. */ | |
3734 | |
3735 static rtx | |
3736 mep_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, | |
3737 const_tree type ATTRIBUTE_UNUSED, | |
3738 bool named ATTRIBUTE_UNUSED) | |
3805 { | 3739 { |
3806 /* VOIDmode is a signal for the backend to pass data to the call | 3740 /* VOIDmode is a signal for the backend to pass data to the call |
3807 expander via the second operand to the call pattern. We use | 3741 expander via the second operand to the call pattern. We use |
3808 this to determine whether to use "jsr" or "jsrv". */ | 3742 this to determine whether to use "jsr" or "jsrv". */ |
3809 if (mode == VOIDmode) | 3743 if (mode == VOIDmode) |
3810 return GEN_INT (cum.vliw); | 3744 return GEN_INT (cum->vliw); |
3811 | 3745 |
3812 /* If we havn't run out of argument registers, return the next. */ | 3746 /* If we havn't run out of argument registers, return the next. */ |
3813 if (cum.nregs < 4) | 3747 if (cum->nregs < 4) |
3814 { | 3748 { |
3815 if (type && TARGET_IVC2 && VECTOR_TYPE_P (type)) | 3749 if (type && TARGET_IVC2 && VECTOR_TYPE_P (type)) |
3816 return gen_rtx_REG (mode, cum.nregs + 49); | 3750 return gen_rtx_REG (mode, cum->nregs + 49); |
3817 else | 3751 else |
3818 return gen_rtx_REG (mode, cum.nregs + 1); | 3752 return gen_rtx_REG (mode, cum->nregs + 1); |
3819 } | 3753 } |
3820 | 3754 |
3821 /* Otherwise the argument goes on the stack. */ | 3755 /* Otherwise the argument goes on the stack. */ |
3822 return NULL_RTX; | 3756 return NULL_RTX; |
3823 } | 3757 } |
3842 if (TARGET_IVC2 && cum->nregs < 4 && type != NULL_TREE && VECTOR_TYPE_P (type)) | 3776 if (TARGET_IVC2 && cum->nregs < 4 && type != NULL_TREE && VECTOR_TYPE_P (type)) |
3843 return false; | 3777 return false; |
3844 return true; | 3778 return true; |
3845 } | 3779 } |
3846 | 3780 |
3847 void | 3781 static void |
3848 mep_arg_advance (CUMULATIVE_ARGS *pcum, | 3782 mep_function_arg_advance (CUMULATIVE_ARGS *pcum, |
3849 enum machine_mode mode ATTRIBUTE_UNUSED, | 3783 enum machine_mode mode ATTRIBUTE_UNUSED, |
3850 tree type ATTRIBUTE_UNUSED, int named ATTRIBUTE_UNUSED) | 3784 const_tree type ATTRIBUTE_UNUSED, |
3785 bool named ATTRIBUTE_UNUSED) | |
3851 { | 3786 { |
3852 pcum->nregs += 1; | 3787 pcum->nregs += 1; |
3853 } | 3788 } |
3854 | 3789 |
3855 bool | 3790 bool |
3869 } | 3804 } |
3870 | 3805 |
3871 /* Implement FUNCTION_VALUE. All values are returned in $0. */ | 3806 /* Implement FUNCTION_VALUE. All values are returned in $0. */ |
3872 | 3807 |
3873 rtx | 3808 rtx |
3874 mep_function_value (tree type, tree func ATTRIBUTE_UNUSED) | 3809 mep_function_value (const_tree type, const_tree func ATTRIBUTE_UNUSED) |
3875 { | 3810 { |
3876 if (TARGET_IVC2 && VECTOR_TYPE_P (type)) | 3811 if (TARGET_IVC2 && VECTOR_TYPE_P (type)) |
3877 return gen_rtx_REG (TYPE_MODE (type), 48); | 3812 return gen_rtx_REG (TYPE_MODE (type), 48); |
3878 return gen_rtx_REG (TYPE_MODE (type), RETURN_VALUE_REGNUM); | 3813 return gen_rtx_REG (TYPE_MODE (type), RETURN_VALUE_REGNUM); |
3879 } | 3814 } |
4064 function_type = TREE_TYPE (*node); | 3999 function_type = TREE_TYPE (*node); |
4065 | 4000 |
4066 if (TREE_TYPE (function_type) != void_type_node) | 4001 if (TREE_TYPE (function_type) != void_type_node) |
4067 error ("interrupt function must have return type of void"); | 4002 error ("interrupt function must have return type of void"); |
4068 | 4003 |
4069 if (TYPE_ARG_TYPES (function_type) | 4004 if (prototype_p (function_type) |
4070 && (TREE_VALUE (TYPE_ARG_TYPES (function_type)) != void_type_node | 4005 && (TREE_VALUE (TYPE_ARG_TYPES (function_type)) != void_type_node |
4071 || TREE_CHAIN (TYPE_ARG_TYPES (function_type)) != NULL_TREE)) | 4006 || TREE_CHAIN (TYPE_ARG_TYPES (function_type)) != NULL_TREE)) |
4072 error ("interrupt function must have no arguments"); | 4007 error ("interrupt function must have no arguments"); |
4073 | 4008 |
4074 return NULL_TREE; | 4009 return NULL_TREE; |
4131 *no_add = true; | 4066 *no_add = true; |
4132 | 4067 |
4133 if (TREE_CODE (*node) == POINTER_TYPE | 4068 if (TREE_CODE (*node) == POINTER_TYPE |
4134 && !gave_pointer_note) | 4069 && !gave_pointer_note) |
4135 { | 4070 { |
4136 inform (input_location, "To describe a pointer to a VLIW function, use syntax like this:"); | 4071 inform (input_location, "to describe a pointer to a VLIW function, use syntax like this:"); |
4137 inform (input_location, " typedef int (__vliw *vfuncptr) ();"); | 4072 inform (input_location, " typedef int (__vliw *vfuncptr) ();"); |
4138 gave_pointer_note = 1; | 4073 gave_pointer_note = 1; |
4139 } | 4074 } |
4140 | 4075 |
4141 if (TREE_CODE (*node) == ARRAY_TYPE | 4076 if (TREE_CODE (*node) == ARRAY_TYPE |
4142 && !gave_array_note) | 4077 && !gave_array_note) |
4143 { | 4078 { |
4144 inform (input_location, "To describe an array of VLIW function pointers, use syntax like this:"); | 4079 inform (input_location, "to describe an array of VLIW function pointers, use syntax like this:"); |
4145 inform (input_location, " typedef int (__vliw *vfuncptr[]) ();"); | 4080 inform (input_location, " typedef int (__vliw *vfuncptr[]) ();"); |
4146 gave_array_note = 1; | 4081 gave_array_note = 1; |
4147 } | 4082 } |
4148 } | 4083 } |
4149 if (!TARGET_VLIW) | 4084 if (!TARGET_VLIW) |
4232 htab_find_slot_with_hash (pragma_htab, funcname, | 4167 htab_find_slot_with_hash (pragma_htab, funcname, |
4233 htab_hash_string (funcname), INSERT); | 4168 htab_hash_string (funcname), INSERT); |
4234 | 4169 |
4235 if (!*slot) | 4170 if (!*slot) |
4236 { | 4171 { |
4237 *slot = GGC_NEW (pragma_entry); | 4172 *slot = ggc_alloc_pragma_entry (); |
4238 (*slot)->flag = 0; | 4173 (*slot)->flag = 0; |
4239 (*slot)->used = 0; | 4174 (*slot)->used = 0; |
4240 (*slot)->funcname = ggc_strdup (funcname); | 4175 (*slot)->funcname = ggc_strdup (funcname); |
4241 } | 4176 } |
4242 (*slot)->flag |= flag; | 4177 (*slot)->flag |= flag; |
4303 mep_file_cleanups (void) | 4238 mep_file_cleanups (void) |
4304 { | 4239 { |
4305 if (pragma_htab) | 4240 if (pragma_htab) |
4306 htab_traverse (pragma_htab, note_unused_pragma_disinterrupt, NULL); | 4241 htab_traverse (pragma_htab, note_unused_pragma_disinterrupt, NULL); |
4307 } | 4242 } |
4243 | |
4244 /* These three functions provide a bridge between the pramgas that | |
4245 affect register classes, and the functions that maintain them. We | |
4246 can't call those functions directly as pragma handling is part of | |
4247 the front end and doesn't have direct access to them. */ | |
4248 | |
4249 void | |
4250 mep_save_register_info (void) | |
4251 { | |
4252 save_register_info (); | |
4253 } | |
4254 | |
4255 void | |
4256 mep_reinit_regs (void) | |
4257 { | |
4258 reinit_regs (); | |
4259 } | |
4260 | |
4261 void | |
4262 mep_init_regs (void) | |
4263 { | |
4264 init_regs (); | |
4265 } | |
4266 | |
4308 | 4267 |
4309 | 4268 |
4310 static int | 4269 static int |
4311 mep_attrlist_to_encoding (tree list, tree decl) | 4270 mep_attrlist_to_encoding (tree list, tree decl) |
4312 { | 4271 { |
4879 while (align > BITS_PER_UNIT) | 4838 while (align > BITS_PER_UNIT) |
4880 { | 4839 { |
4881 align /= 2; | 4840 align /= 2; |
4882 p2align ++; | 4841 p2align ++; |
4883 } | 4842 } |
4884 name2 = TARGET_STRIP_NAME_ENCODING (name); | 4843 name2 = targetm.strip_name_encoding (name); |
4885 if (global) | 4844 if (global) |
4886 fprintf (stream, "\t.globl\t%s\n", name2); | 4845 fprintf (stream, "\t.globl\t%s\n", name2); |
4887 fprintf (stream, "\t.p2align %d\n", p2align); | 4846 fprintf (stream, "\t.p2align %d\n", p2align); |
4888 fprintf (stream, "\t.type\t%s,@object\n", name2); | 4847 fprintf (stream, "\t.type\t%s,@object\n", name2); |
4889 fprintf (stream, "\t.size\t%s,%d\n", name2, size); | 4848 fprintf (stream, "\t.size\t%s,%d\n", name2, size); |
5630 } | 5589 } |
5631 | 5590 |
5632 static void | 5591 static void |
5633 mep_reorg_erepeat (rtx insns) | 5592 mep_reorg_erepeat (rtx insns) |
5634 { | 5593 { |
5635 rtx insn, prev, label_before, l, x; | 5594 rtx insn, prev, l, x; |
5636 int count; | 5595 int count; |
5637 | 5596 |
5638 for (insn = insns; insn; insn = NEXT_INSN (insn)) | 5597 for (insn = insns; insn; insn = NEXT_INSN (insn)) |
5639 if (JUMP_P (insn) | 5598 if (JUMP_P (insn) |
5640 && ! JUMP_TABLE_DATA_P (insn) | 5599 && ! JUMP_TABLE_DATA_P (insn) |
5645 fprintf (dump_file, "\n------------------------------\n"); | 5604 fprintf (dump_file, "\n------------------------------\n"); |
5646 fprintf (dump_file, "erepeat: considering this jump:\n"); | 5605 fprintf (dump_file, "erepeat: considering this jump:\n"); |
5647 print_rtl_single (dump_file, insn); | 5606 print_rtl_single (dump_file, insn); |
5648 } | 5607 } |
5649 count = simplejump_p (insn) ? 0 : 1; | 5608 count = simplejump_p (insn) ? 0 : 1; |
5650 label_before = 0; | |
5651 for (prev = PREV_INSN (insn); prev; prev = PREV_INSN (prev)) | 5609 for (prev = PREV_INSN (insn); prev; prev = PREV_INSN (prev)) |
5652 { | 5610 { |
5653 if (GET_CODE (prev) == CALL_INSN | 5611 if (GET_CODE (prev) == CALL_INSN |
5654 || BARRIER_P (prev)) | 5612 || BARRIER_P (prev)) |
5655 break; | 5613 break; |
5734 } | 5692 } |
5735 | 5693 |
5736 if (INSN_P (prev)) | 5694 if (INSN_P (prev)) |
5737 { | 5695 { |
5738 count ++; | 5696 count ++; |
5739 if (count == 2) | |
5740 label_before = prev; | |
5741 } | 5697 } |
5742 } | 5698 } |
5743 } | 5699 } |
5744 if (dump_file) | 5700 if (dump_file) |
5745 fprintf (dump_file, "\n==============================\n"); | 5701 fprintf (dump_file, "\n==============================\n"); |
6331 int opindex, unsigned_p[10]; | 6287 int opindex, unsigned_p[10]; |
6332 tree fndecl, args; | 6288 tree fndecl, args; |
6333 unsigned int n_args; | 6289 unsigned int n_args; |
6334 tree fnname; | 6290 tree fnname; |
6335 const struct cgen_insn *cgen_insn; | 6291 const struct cgen_insn *cgen_insn; |
6336 const struct insn_data *idata; | 6292 const struct insn_data_d *idata; |
6337 unsigned int first_arg = 0; | 6293 unsigned int first_arg = 0; |
6338 tree return_type = void_type_node; | |
6339 unsigned int builtin_n_args; | 6294 unsigned int builtin_n_args; |
6340 | 6295 |
6341 fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); | 6296 fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); |
6342 fnname = DECL_NAME (fndecl); | 6297 fnname = DECL_NAME (fndecl); |
6343 | 6298 |
6355 if (cgen_insn->cret_p) | 6310 if (cgen_insn->cret_p) |
6356 { | 6311 { |
6357 if (cgen_insn->cret_p > 1) | 6312 if (cgen_insn->cret_p > 1) |
6358 builtin_n_args ++; | 6313 builtin_n_args ++; |
6359 first_arg = 1; | 6314 first_arg = 1; |
6360 return_type = mep_cgen_regnum_to_type (cgen_insn->regnums[0].type); | 6315 mep_cgen_regnum_to_type (cgen_insn->regnums[0].type); |
6361 builtin_n_args --; | 6316 builtin_n_args --; |
6362 } | 6317 } |
6363 | 6318 |
6364 /* Evaluate each argument. */ | 6319 /* Evaluate each argument. */ |
6365 n_args = call_expr_nargs (exp); | 6320 n_args = call_expr_nargs (exp); |
7211 | 7166 |
7212 bool | 7167 bool |
7213 mep_emit_intrinsic (int intrinsic, const rtx *operands) | 7168 mep_emit_intrinsic (int intrinsic, const rtx *operands) |
7214 { | 7169 { |
7215 const struct cgen_insn *cgen_insn; | 7170 const struct cgen_insn *cgen_insn; |
7216 const struct insn_data *idata; | 7171 const struct insn_data_d *idata; |
7217 rtx newop[10]; | 7172 rtx newop[10]; |
7218 int i; | 7173 int i; |
7219 | 7174 |
7220 if (!mep_get_intrinsic_insn (intrinsic, &cgen_insn)) | 7175 if (!mep_get_intrinsic_insn (intrinsic, &cgen_insn)) |
7221 return false; | 7176 return false; |
7416 ftext_section | 7371 ftext_section |
7417 = get_unnamed_section (SECTION_CODE, output_section_asm_op, | 7372 = get_unnamed_section (SECTION_CODE, output_section_asm_op, |
7418 "\t.section .ftext,\"ax\"\n\t.core"); | 7373 "\t.section .ftext,\"ax\"\n\t.core"); |
7419 | 7374 |
7420 } | 7375 } |
7376 | |
7377 /* Initialize the GCC target structure. */ | |
7378 | |
7379 #undef TARGET_ASM_FUNCTION_PROLOGUE | |
7380 #define TARGET_ASM_FUNCTION_PROLOGUE mep_start_function | |
7381 #undef TARGET_ATTRIBUTE_TABLE | |
7382 #define TARGET_ATTRIBUTE_TABLE mep_attribute_table | |
7383 #undef TARGET_COMP_TYPE_ATTRIBUTES | |
7384 #define TARGET_COMP_TYPE_ATTRIBUTES mep_comp_type_attributes | |
7385 #undef TARGET_INSERT_ATTRIBUTES | |
7386 #define TARGET_INSERT_ATTRIBUTES mep_insert_attributes | |
7387 #undef TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P | |
7388 #define TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P mep_function_attribute_inlinable_p | |
7389 #undef TARGET_CAN_INLINE_P | |
7390 #define TARGET_CAN_INLINE_P mep_can_inline_p | |
7391 #undef TARGET_SECTION_TYPE_FLAGS | |
7392 #define TARGET_SECTION_TYPE_FLAGS mep_section_type_flags | |
7393 #undef TARGET_ASM_NAMED_SECTION | |
7394 #define TARGET_ASM_NAMED_SECTION mep_asm_named_section | |
7395 #undef TARGET_INIT_BUILTINS | |
7396 #define TARGET_INIT_BUILTINS mep_init_builtins | |
7397 #undef TARGET_EXPAND_BUILTIN | |
7398 #define TARGET_EXPAND_BUILTIN mep_expand_builtin | |
7399 #undef TARGET_SCHED_ADJUST_COST | |
7400 #define TARGET_SCHED_ADJUST_COST mep_adjust_cost | |
7401 #undef TARGET_SCHED_ISSUE_RATE | |
7402 #define TARGET_SCHED_ISSUE_RATE mep_issue_rate | |
7403 #undef TARGET_SCHED_REORDER | |
7404 #define TARGET_SCHED_REORDER mep_sched_reorder | |
7405 #undef TARGET_STRIP_NAME_ENCODING | |
7406 #define TARGET_STRIP_NAME_ENCODING mep_strip_name_encoding | |
7407 #undef TARGET_ASM_SELECT_SECTION | |
7408 #define TARGET_ASM_SELECT_SECTION mep_select_section | |
7409 #undef TARGET_ASM_UNIQUE_SECTION | |
7410 #define TARGET_ASM_UNIQUE_SECTION mep_unique_section | |
7411 #undef TARGET_ENCODE_SECTION_INFO | |
7412 #define TARGET_ENCODE_SECTION_INFO mep_encode_section_info | |
7413 #undef TARGET_FUNCTION_OK_FOR_SIBCALL | |
7414 #define TARGET_FUNCTION_OK_FOR_SIBCALL mep_function_ok_for_sibcall | |
7415 #undef TARGET_RTX_COSTS | |
7416 #define TARGET_RTX_COSTS mep_rtx_cost | |
7417 #undef TARGET_ADDRESS_COST | |
7418 #define TARGET_ADDRESS_COST mep_address_cost | |
7419 #undef TARGET_MACHINE_DEPENDENT_REORG | |
7420 #define TARGET_MACHINE_DEPENDENT_REORG mep_reorg | |
7421 #undef TARGET_SETUP_INCOMING_VARARGS | |
7422 #define TARGET_SETUP_INCOMING_VARARGS mep_setup_incoming_varargs | |
7423 #undef TARGET_PASS_BY_REFERENCE | |
7424 #define TARGET_PASS_BY_REFERENCE mep_pass_by_reference | |
7425 #undef TARGET_FUNCTION_ARG | |
7426 #define TARGET_FUNCTION_ARG mep_function_arg | |
7427 #undef TARGET_FUNCTION_ARG_ADVANCE | |
7428 #define TARGET_FUNCTION_ARG_ADVANCE mep_function_arg_advance | |
7429 #undef TARGET_VECTOR_MODE_SUPPORTED_P | |
7430 #define TARGET_VECTOR_MODE_SUPPORTED_P mep_vector_mode_supported_p | |
7431 #undef TARGET_HANDLE_OPTION | |
7432 #define TARGET_HANDLE_OPTION mep_handle_option | |
7433 #undef TARGET_OPTION_OVERRIDE | |
7434 #define TARGET_OPTION_OVERRIDE mep_option_override | |
7435 #undef TARGET_OPTION_OPTIMIZATION_TABLE | |
7436 #define TARGET_OPTION_OPTIMIZATION_TABLE mep_option_optimization_table | |
7437 #undef TARGET_DEFAULT_TARGET_FLAGS | |
7438 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT | |
7439 #undef TARGET_ALLOCATE_INITIAL_VALUE | |
7440 #define TARGET_ALLOCATE_INITIAL_VALUE mep_allocate_initial_value | |
7441 #undef TARGET_ASM_INIT_SECTIONS | |
7442 #define TARGET_ASM_INIT_SECTIONS mep_asm_init_sections | |
7443 #undef TARGET_RETURN_IN_MEMORY | |
7444 #define TARGET_RETURN_IN_MEMORY mep_return_in_memory | |
7445 #undef TARGET_NARROW_VOLATILE_BITFIELD | |
7446 #define TARGET_NARROW_VOLATILE_BITFIELD mep_narrow_volatile_bitfield | |
7447 #undef TARGET_EXPAND_BUILTIN_SAVEREGS | |
7448 #define TARGET_EXPAND_BUILTIN_SAVEREGS mep_expand_builtin_saveregs | |
7449 #undef TARGET_BUILD_BUILTIN_VA_LIST | |
7450 #define TARGET_BUILD_BUILTIN_VA_LIST mep_build_builtin_va_list | |
7451 #undef TARGET_EXPAND_BUILTIN_VA_START | |
7452 #define TARGET_EXPAND_BUILTIN_VA_START mep_expand_va_start | |
7453 #undef TARGET_GIMPLIFY_VA_ARG_EXPR | |
7454 #define TARGET_GIMPLIFY_VA_ARG_EXPR mep_gimplify_va_arg_expr | |
7455 #undef TARGET_CAN_ELIMINATE | |
7456 #define TARGET_CAN_ELIMINATE mep_can_eliminate | |
7457 #undef TARGET_CONDITIONAL_REGISTER_USAGE | |
7458 #define TARGET_CONDITIONAL_REGISTER_USAGE mep_conditional_register_usage | |
7459 #undef TARGET_TRAMPOLINE_INIT | |
7460 #define TARGET_TRAMPOLINE_INIT mep_trampoline_init | |
7461 | |
7462 struct gcc_target targetm = TARGET_INITIALIZER; | |
7421 | 7463 |
7422 #include "gt-mep.h" | 7464 #include "gt-mep.h" |