Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/lm32/lm32.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 /* Subroutines used for code generation on the Lattice Mico32 architecture. | 1 /* Subroutines used for code generation on the Lattice Mico32 architecture. |
2 Contributed by Jon Beniston <jon@beniston.com> | 2 Contributed by Jon Beniston <jon@beniston.com> |
3 | 3 |
4 Copyright (C) 2009-2018 Free Software Foundation, Inc. | 4 Copyright (C) 2009-2020 Free Software Foundation, Inc. |
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 it | 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 | 9 under the terms of the GNU General Public License as published |
62 static rtx emit_add (rtx dest, rtx src0, rtx src1); | 62 static rtx emit_add (rtx dest, rtx src0, rtx src1); |
63 static void expand_save_restore (struct lm32_frame_info *info, int op); | 63 static void expand_save_restore (struct lm32_frame_info *info, int op); |
64 static void stack_adjust (HOST_WIDE_INT amount); | 64 static void stack_adjust (HOST_WIDE_INT amount); |
65 static bool lm32_in_small_data_p (const_tree); | 65 static bool lm32_in_small_data_p (const_tree); |
66 static void lm32_setup_incoming_varargs (cumulative_args_t cum, | 66 static void lm32_setup_incoming_varargs (cumulative_args_t cum, |
67 machine_mode mode, tree type, | 67 const function_arg_info &, |
68 int *pretend_size, int no_rtl); | 68 int *pretend_size, int no_rtl); |
69 static bool lm32_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, | 69 static bool lm32_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, |
70 int *total, bool speed); | 70 int *total, bool speed); |
71 static bool lm32_can_eliminate (const int, const int); | 71 static bool lm32_can_eliminate (const int, const int); |
72 static bool | 72 static bool |
73 lm32_legitimate_address_p (machine_mode mode, rtx x, bool strict); | 73 lm32_legitimate_address_p (machine_mode mode, rtx x, bool strict); |
74 static HOST_WIDE_INT lm32_compute_frame_size (int size); | 74 static HOST_WIDE_INT lm32_compute_frame_size (int size); |
75 static void lm32_option_override (void); | 75 static void lm32_option_override (void); |
76 static rtx lm32_function_arg (cumulative_args_t cum, | 76 static rtx lm32_function_arg (cumulative_args_t, const function_arg_info &); |
77 machine_mode mode, const_tree type, | |
78 bool named); | |
79 static void lm32_function_arg_advance (cumulative_args_t cum, | 77 static void lm32_function_arg_advance (cumulative_args_t cum, |
80 machine_mode mode, | 78 const function_arg_info &); |
81 const_tree type, bool named); | |
82 static bool lm32_hard_regno_mode_ok (unsigned int, machine_mode); | 79 static bool lm32_hard_regno_mode_ok (unsigned int, machine_mode); |
83 static bool lm32_modes_tieable_p (machine_mode, machine_mode); | 80 static bool lm32_modes_tieable_p (machine_mode, machine_mode); |
84 static HOST_WIDE_INT lm32_starting_frame_offset (void); | 81 static HOST_WIDE_INT lm32_starting_frame_offset (void); |
85 | 82 |
86 #undef TARGET_OPTION_OVERRIDE | 83 #undef TARGET_OPTION_OVERRIDE |
458 | 455 |
459 /* Build mask that actually determines which regsiters we save | 456 /* Build mask that actually determines which regsiters we save |
460 and calculate size required to store them in the stack. */ | 457 and calculate size required to store them in the stack. */ |
461 for (regno = 1; regno < SP_REGNUM; regno++) | 458 for (regno = 1; regno < SP_REGNUM; regno++) |
462 { | 459 { |
463 if (df_regs_ever_live_p (regno) && !call_used_regs[regno]) | 460 if (df_regs_ever_live_p (regno) && !call_used_or_fixed_reg_p (regno)) |
464 { | 461 { |
465 reg_save_mask |= 1 << regno; | 462 reg_save_mask |= 1 << regno; |
466 callee_size += UNITS_PER_WORD; | 463 callee_size += UNITS_PER_WORD; |
467 } | 464 } |
468 } | 465 } |
617 | 614 |
618 /* Determine where to put an argument to a function. | 615 /* Determine where to put an argument to a function. |
619 Value is zero to push the argument on the stack, | 616 Value is zero to push the argument on the stack, |
620 or a hard register in which to store the argument. | 617 or a hard register in which to store the argument. |
621 | 618 |
622 MODE is the argument's machine mode. | |
623 TYPE is the data type of the argument (as a tree). | |
624 This is null for libcalls where that information may | |
625 not be available. | |
626 CUM is a variable of type CUMULATIVE_ARGS which gives info about | 619 CUM is a variable of type CUMULATIVE_ARGS which gives info about |
627 the preceding args and about the function being called. | 620 the preceding args and about the function being called. |
628 NAMED is nonzero if this argument is a named parameter | 621 ARG is a description of the argument. */ |
629 (otherwise it is an extra parameter matching an ellipsis). */ | |
630 | 622 |
631 static rtx | 623 static rtx |
632 lm32_function_arg (cumulative_args_t cum_v, machine_mode mode, | 624 lm32_function_arg (cumulative_args_t cum_v, const function_arg_info &arg) |
633 const_tree type, bool named) | |
634 { | 625 { |
635 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); | 626 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); |
636 | 627 |
637 if (mode == VOIDmode) | 628 if (arg.end_marker_p ()) |
638 /* Compute operand 2 of the call insn. */ | 629 /* Compute operand 2 of the call insn. */ |
639 return GEN_INT (0); | 630 return GEN_INT (0); |
640 | 631 |
641 if (targetm.calls.must_pass_in_stack (mode, type)) | 632 if (targetm.calls.must_pass_in_stack (arg)) |
642 return NULL_RTX; | 633 return NULL_RTX; |
643 | 634 |
644 if (!named || (*cum + LM32_NUM_REGS2 (mode, type) > LM32_NUM_ARG_REGS)) | 635 if (!arg.named |
636 || *cum + LM32_NUM_REGS2 (arg.mode, arg.type) > LM32_NUM_ARG_REGS) | |
645 return NULL_RTX; | 637 return NULL_RTX; |
646 | 638 |
647 return gen_rtx_REG (mode, *cum + LM32_FIRST_ARG_REG); | 639 return gen_rtx_REG (arg.mode, *cum + LM32_FIRST_ARG_REG); |
648 } | 640 } |
649 | 641 |
650 static void | 642 static void |
651 lm32_function_arg_advance (cumulative_args_t cum, machine_mode mode, | 643 lm32_function_arg_advance (cumulative_args_t cum, |
652 const_tree type, bool named ATTRIBUTE_UNUSED) | 644 const function_arg_info &arg) |
653 { | 645 { |
654 *get_cumulative_args (cum) += LM32_NUM_REGS2 (mode, type); | 646 *get_cumulative_args (cum) += LM32_NUM_REGS2 (arg.mode, arg.type); |
655 } | 647 } |
656 | 648 |
657 HOST_WIDE_INT | 649 HOST_WIDE_INT |
658 lm32_compute_initial_elimination_offset (int from, int to) | 650 lm32_compute_initial_elimination_offset (int from, int to) |
659 { | 651 { |
682 | 674 |
683 return offset; | 675 return offset; |
684 } | 676 } |
685 | 677 |
686 static void | 678 static void |
687 lm32_setup_incoming_varargs (cumulative_args_t cum_v, machine_mode mode, | 679 lm32_setup_incoming_varargs (cumulative_args_t cum_v, |
688 tree type, int *pretend_size, int no_rtl) | 680 const function_arg_info &arg, |
681 int *pretend_size, int no_rtl) | |
689 { | 682 { |
690 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); | 683 CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); |
691 int first_anon_arg; | 684 int first_anon_arg; |
692 tree fntype; | 685 tree fntype; |
693 | 686 |
700 /* this is the common case, we have been passed details setup | 693 /* this is the common case, we have been passed details setup |
701 for the last named argument, we want to skip over the | 694 for the last named argument, we want to skip over the |
702 registers, if any used in passing this named paramter in | 695 registers, if any used in passing this named paramter in |
703 order to determine which is the first registers used to pass | 696 order to determine which is the first registers used to pass |
704 anonymous arguments. */ | 697 anonymous arguments. */ |
705 int size; | 698 int size = arg.promoted_size_in_bytes (); |
706 | |
707 if (mode == BLKmode) | |
708 size = int_size_in_bytes (type); | |
709 else | |
710 size = GET_MODE_SIZE (mode); | |
711 | 699 |
712 first_anon_arg = | 700 first_anon_arg = |
713 *cum + LM32_FIRST_ARG_REG + | 701 *cum + LM32_FIRST_ARG_REG + |
714 ((size + UNITS_PER_WORD - 1) / UNITS_PER_WORD); | 702 ((size + UNITS_PER_WORD - 1) / UNITS_PER_WORD); |
715 } | 703 } |
866 if (offset < length) | 854 if (offset < length) |
867 { | 855 { |
868 src = adjust_address (src, BLKmode, offset); | 856 src = adjust_address (src, BLKmode, offset); |
869 dest = adjust_address (dest, BLKmode, offset); | 857 dest = adjust_address (dest, BLKmode, offset); |
870 move_by_pieces (dest, src, length - offset, | 858 move_by_pieces (dest, src, length - offset, |
871 MIN (MEM_ALIGN (src), MEM_ALIGN (dest)), 0); | 859 MIN (MEM_ALIGN (src), MEM_ALIGN (dest)), RETURN_BEGIN); |
872 } | 860 } |
873 } | 861 } |
874 | 862 |
875 /* Expand string/block move operations. | 863 /* Expand string/block move operations. |
876 | 864 |