comparison gcc/config/mcore/mcore.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Output routines for Motorola MCore processor 1 /* Output routines for Motorola MCore processor
2 Copyright (C) 1993-2018 Free Software Foundation, Inc. 2 Copyright (C) 1993-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it 6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published 7 under the terms of the GNU General Public License as published
97 static void output_stack_adjust (int, int); 97 static void output_stack_adjust (int, int);
98 static int calc_live_regs (int *); 98 static int calc_live_regs (int *);
99 static int try_constant_tricks (HOST_WIDE_INT, HOST_WIDE_INT *, HOST_WIDE_INT *); 99 static int try_constant_tricks (HOST_WIDE_INT, HOST_WIDE_INT *, HOST_WIDE_INT *);
100 static const char * output_inline_const (machine_mode, rtx *); 100 static const char * output_inline_const (machine_mode, rtx *);
101 static void layout_mcore_frame (struct mcore_frame *); 101 static void layout_mcore_frame (struct mcore_frame *);
102 static void mcore_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int); 102 static void mcore_setup_incoming_varargs (cumulative_args_t,
103 const function_arg_info &,
104 int *, int);
103 static cond_type is_cond_candidate (rtx); 105 static cond_type is_cond_candidate (rtx);
104 static rtx_insn *emit_new_cond_insn (rtx_insn *, int); 106 static rtx_insn *emit_new_cond_insn (rtx_insn *, int);
105 static rtx_insn *conditionalize_block (rtx_insn *); 107 static rtx_insn *conditionalize_block (rtx_insn *);
106 static void conditionalize_optimization (void); 108 static void conditionalize_optimization (void);
107 static void mcore_reorg (void); 109 static void mcore_reorg (void);
127 static bool mcore_rtx_costs (rtx, machine_mode, int, int, 129 static bool mcore_rtx_costs (rtx, machine_mode, int, int,
128 int *, bool); 130 int *, bool);
129 static void mcore_external_libcall (rtx); 131 static void mcore_external_libcall (rtx);
130 static bool mcore_return_in_memory (const_tree, const_tree); 132 static bool mcore_return_in_memory (const_tree, const_tree);
131 static int mcore_arg_partial_bytes (cumulative_args_t, 133 static int mcore_arg_partial_bytes (cumulative_args_t,
132 machine_mode, 134 const function_arg_info &);
133 tree, bool);
134 static rtx mcore_function_arg (cumulative_args_t, 135 static rtx mcore_function_arg (cumulative_args_t,
135 machine_mode, 136 const function_arg_info &);
136 const_tree, bool);
137 static void mcore_function_arg_advance (cumulative_args_t, 137 static void mcore_function_arg_advance (cumulative_args_t,
138 machine_mode, 138 const function_arg_info &);
139 const_tree, bool);
140 static unsigned int mcore_function_arg_boundary (machine_mode, 139 static unsigned int mcore_function_arg_boundary (machine_mode,
141 const_tree); 140 const_tree);
142 static void mcore_asm_trampoline_template (FILE *); 141 static void mcore_asm_trampoline_template (FILE *);
143 static void mcore_trampoline_init (rtx, tree, rtx); 142 static void mcore_trampoline_init (rtx, tree, rtx);
144 static bool mcore_warn_func_return (tree); 143 static bool mcore_warn_func_return (tree);
315 314
316 * count = 0; 315 * count = 0;
317 316
318 for (reg = 0; reg < FIRST_PSEUDO_REGISTER; reg++) 317 for (reg = 0; reg < FIRST_PSEUDO_REGISTER; reg++)
319 { 318 {
320 if (df_regs_ever_live_p (reg) && !call_used_regs[reg]) 319 if (df_regs_ever_live_p (reg) && !call_used_or_fixed_reg_p (reg))
321 { 320 {
322 (*count)++; 321 (*count)++;
323 live_regs_mask |= (1 << reg); 322 live_regs_mask |= (1 << reg);
324 } 323 }
325 } 324 }
1941 1940
1942 /* Keep track of some information about varargs for the prolog. */ 1941 /* Keep track of some information about varargs for the prolog. */
1943 1942
1944 static void 1943 static void
1945 mcore_setup_incoming_varargs (cumulative_args_t args_so_far_v, 1944 mcore_setup_incoming_varargs (cumulative_args_t args_so_far_v,
1946 machine_mode mode, tree type, 1945 const function_arg_info &arg,
1947 int * ptr_pretend_size ATTRIBUTE_UNUSED, 1946 int * ptr_pretend_size ATTRIBUTE_UNUSED,
1948 int second_time ATTRIBUTE_UNUSED) 1947 int second_time ATTRIBUTE_UNUSED)
1949 { 1948 {
1950 CUMULATIVE_ARGS *args_so_far = get_cumulative_args (args_so_far_v); 1949 CUMULATIVE_ARGS *args_so_far = get_cumulative_args (args_so_far_v);
1951 1950
1952 current_function_anonymous_args = 1; 1951 current_function_anonymous_args = 1;
1953 1952
1954 /* We need to know how many argument registers are used before 1953 /* We need to know how many argument registers are used before
1955 the varargs start, so that we can push the remaining argument 1954 the varargs start, so that we can push the remaining argument
1956 registers during the prologue. */ 1955 registers during the prologue. */
1957 number_of_regs_before_varargs = *args_so_far + mcore_num_arg_regs (mode, type); 1956 number_of_regs_before_varargs
1957 = *args_so_far + mcore_num_arg_regs (arg.mode, arg.type);
1958 1958
1959 /* There is a bug somewhere in the arg handling code. 1959 /* There is a bug somewhere in the arg handling code.
1960 Until I can find it this workaround always pushes the 1960 Until I can find it this workaround always pushes the
1961 last named argument onto the stack. */ 1961 last named argument onto the stack. */
1962 number_of_regs_before_varargs = *args_so_far; 1962 number_of_regs_before_varargs = *args_so_far;
2711 int 2711 int
2712 mcore_num_arg_regs (machine_mode mode, const_tree type) 2712 mcore_num_arg_regs (machine_mode mode, const_tree type)
2713 { 2713 {
2714 int size; 2714 int size;
2715 2715
2716 if (targetm.calls.must_pass_in_stack (mode, type)) 2716 function_arg_info arg (const_cast<tree> (type), mode, /*named=*/true);
2717 if (targetm.calls.must_pass_in_stack (arg))
2717 return 0; 2718 return 0;
2718 2719
2719 if (type && mode == BLKmode) 2720 if (type && mode == BLKmode)
2720 size = int_size_in_bytes (type); 2721 size = int_size_in_bytes (type);
2721 else 2722 else
2784 2785
2785 /* Define where to put the arguments to a function. 2786 /* Define where to put the arguments to a function.
2786 Value is zero to push the argument on the stack, 2787 Value is zero to push the argument on the stack,
2787 or a hard register in which to store the argument. 2788 or a hard register in which to store the argument.
2788 2789
2789 MODE is the argument's machine mode.
2790 TYPE is the data type of the argument (as a tree).
2791 This is null for libcalls where that information may
2792 not be available.
2793 CUM is a variable of type CUMULATIVE_ARGS which gives info about 2790 CUM is a variable of type CUMULATIVE_ARGS which gives info about
2794 the preceding args and about the function being called. 2791 the preceding args and about the function being called.
2795 NAMED is nonzero if this argument is a named parameter 2792 ARG is a description of the argument.
2796 (otherwise it is an extra parameter matching an ellipsis).
2797 2793
2798 On MCore the first args are normally in registers 2794 On MCore the first args are normally in registers
2799 and the rest are pushed. Any arg that starts within the first 2795 and the rest are pushed. Any arg that starts within the first
2800 NPARM_REGS words is at least partially passed in a register unless 2796 NPARM_REGS words is at least partially passed in a register unless
2801 its data type forbids. */ 2797 its data type forbids. */
2802 2798
2803 static rtx 2799 static rtx
2804 mcore_function_arg (cumulative_args_t cum, machine_mode mode, 2800 mcore_function_arg (cumulative_args_t cum, const function_arg_info &arg)
2805 const_tree type, bool named)
2806 { 2801 {
2807 int arg_reg; 2802 int arg_reg;
2808 2803
2809 if (! named || mode == VOIDmode) 2804 if (!arg.named || arg.end_marker_p ())
2810 return 0; 2805 return 0;
2811 2806
2812 if (targetm.calls.must_pass_in_stack (mode, type)) 2807 if (targetm.calls.must_pass_in_stack (arg))
2813 return 0; 2808 return 0;
2814 2809
2815 arg_reg = ROUND_REG (*get_cumulative_args (cum), mode); 2810 arg_reg = ROUND_REG (*get_cumulative_args (cum), arg.mode);
2816 2811
2817 if (arg_reg < NPARM_REGS) 2812 if (arg_reg < NPARM_REGS)
2818 return handle_structs_in_regs (mode, type, FIRST_PARM_REG + arg_reg); 2813 return handle_structs_in_regs (arg.mode, arg.type,
2814 FIRST_PARM_REG + arg_reg);
2819 2815
2820 return 0; 2816 return 0;
2821 } 2817 }
2822 2818
2823 static void 2819 static void
2824 mcore_function_arg_advance (cumulative_args_t cum_v, machine_mode mode, 2820 mcore_function_arg_advance (cumulative_args_t cum_v,
2825 const_tree type, bool named ATTRIBUTE_UNUSED) 2821 const function_arg_info &arg)
2826 { 2822 {
2827 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); 2823 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
2828 2824
2829 *cum = (ROUND_REG (*cum, mode) 2825 *cum = (ROUND_REG (*cum, arg.mode)
2830 + (int)named * mcore_num_arg_regs (mode, type)); 2826 + (int) arg.named * mcore_num_arg_regs (arg.mode, arg.type));
2831 } 2827 }
2832 2828
2833 static unsigned int 2829 static unsigned int
2834 mcore_function_arg_boundary (machine_mode mode, 2830 mcore_function_arg_boundary (machine_mode mode,
2835 const_tree type ATTRIBUTE_UNUSED) 2831 const_tree type ATTRIBUTE_UNUSED)
2839 ? BIGGEST_ALIGNMENT 2835 ? BIGGEST_ALIGNMENT
2840 : PARM_BOUNDARY); 2836 : PARM_BOUNDARY);
2841 } 2837 }
2842 2838
2843 /* Returns the number of bytes of argument registers required to hold *part* 2839 /* Returns the number of bytes of argument registers required to hold *part*
2844 of a parameter of machine mode MODE and type TYPE (which may be NULL if 2840 of argument ARG. If the argument fits entirely in the argument registers,
2845 the type is not known). If the argument fits entirely in the argument 2841 or entirely on the stack, then 0 is returned. CUM is the number of
2846 registers, or entirely on the stack, then 0 is returned. CUM is the 2842 argument registers already used by earlier parameters to the function. */
2847 number of argument registers already used by earlier parameters to
2848 the function. */
2849 2843
2850 static int 2844 static int
2851 mcore_arg_partial_bytes (cumulative_args_t cum, machine_mode mode, 2845 mcore_arg_partial_bytes (cumulative_args_t cum, const function_arg_info &arg)
2852 tree type, bool named) 2846 {
2853 { 2847 int reg = ROUND_REG (*get_cumulative_args (cum), arg.mode);
2854 int reg = ROUND_REG (*get_cumulative_args (cum), mode); 2848
2855 2849 if (!arg.named)
2856 if (named == 0)
2857 return 0; 2850 return 0;
2858 2851
2859 if (targetm.calls.must_pass_in_stack (mode, type)) 2852 if (targetm.calls.must_pass_in_stack (arg))
2860 return 0; 2853 return 0;
2861 2854
2862 /* REG is not the *hardware* register number of the register that holds 2855 /* REG is not the *hardware* register number of the register that holds
2863 the argument, it is the *argument* register number. So for example, 2856 the argument, it is the *argument* register number. So for example,
2864 the first argument to a function goes in argument register 0, which 2857 the first argument to a function goes in argument register 0, which
2869 the target. */ 2862 the target. */
2870 if (reg >= NPARM_REGS) 2863 if (reg >= NPARM_REGS)
2871 return 0; 2864 return 0;
2872 2865
2873 /* If the argument fits entirely in registers, return 0. */ 2866 /* If the argument fits entirely in registers, return 0. */
2874 if (reg + mcore_num_arg_regs (mode, type) <= NPARM_REGS) 2867 if (reg + mcore_num_arg_regs (arg.mode, arg.type) <= NPARM_REGS)
2875 return 0; 2868 return 0;
2876 2869
2877 /* The argument overflows the number of available argument registers. 2870 /* The argument overflows the number of available argument registers.
2878 Compute how many argument registers have not yet been assigned to 2871 Compute how many argument registers have not yet been assigned to
2879 hold an argument. */ 2872 hold an argument. */