Mercurial > hg > CbC > CbC_gcc
comparison gcc/rtl.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 /* RTL utility routines. | 1 /* RTL utility routines. |
2 Copyright (C) 1987-2018 Free Software Foundation, Inc. | 2 Copyright (C) 1987-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 under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
104 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS, | 104 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS, |
105 #include "rtl.def" /* rtl expressions are defined here */ | 105 #include "rtl.def" /* rtl expressions are defined here */ |
106 #undef DEF_RTL_EXPR | 106 #undef DEF_RTL_EXPR |
107 }; | 107 }; |
108 | 108 |
109 /* Whether rtxs with the given code code store data in the hwint field. */ | |
110 | |
111 #define RTX_CODE_HWINT_P_1(ENUM) \ | |
112 ((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \ | |
113 || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT) | |
114 #ifdef GENERATOR_FILE | |
115 #define RTX_CODE_HWINT_P(ENUM) \ | |
116 (RTX_CODE_HWINT_P_1 (ENUM) || (ENUM) == EQ_ATTR_ALT) | |
117 #else | |
118 #define RTX_CODE_HWINT_P RTX_CODE_HWINT_P_1 | |
119 #endif | |
120 | |
109 /* Indexed by rtx code, gives the size of the rtx in bytes. */ | 121 /* Indexed by rtx code, gives the size of the rtx in bytes. */ |
110 | 122 |
111 const unsigned char rtx_code_size[NUM_RTX_CODE] = { | 123 const unsigned char rtx_code_size[NUM_RTX_CODE] = { |
112 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \ | 124 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \ |
113 ((FORMAT)[0] == 'w' \ | 125 (RTX_CODE_HWINT_P (ENUM) \ |
114 ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \ | 126 ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \ |
115 : (ENUM) == REG \ | 127 : (ENUM) == REG \ |
116 ? RTX_HDR_SIZE + sizeof (reg_info) \ | 128 ? RTX_HDR_SIZE + sizeof (reg_info) \ |
117 : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)), | 129 : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)), |
118 | 130 |
134 #define DEF_REG_NOTE(NAME) #NAME, | 146 #define DEF_REG_NOTE(NAME) #NAME, |
135 #include "reg-notes.def" | 147 #include "reg-notes.def" |
136 #undef DEF_REG_NOTE | 148 #undef DEF_REG_NOTE |
137 }; | 149 }; |
138 | 150 |
139 static int rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE]; | 151 static size_t rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE]; |
140 static int rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE]; | 152 static size_t rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE]; |
141 static int rtvec_alloc_counts; | 153 static size_t rtvec_alloc_counts; |
142 static int rtvec_alloc_sizes; | 154 static size_t rtvec_alloc_sizes; |
143 | 155 |
144 | 156 |
145 /* Allocate an rtx vector of N elements. | 157 /* Allocate an rtx vector of N elements. |
146 Store the length, and initialize all elements to zero. */ | 158 Store the length, and initialize all elements to zero. */ |
147 | 159 |
205 rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra) | 217 rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra) |
206 { | 218 { |
207 rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra | 219 rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra |
208 PASS_MEM_STAT); | 220 PASS_MEM_STAT); |
209 | 221 |
210 /* We want to clear everything up to the FLD array. Normally, this | 222 rtx_init (rt, code); |
211 is one int, but we don't want to assume that and it isn't very | |
212 portable anyway; this is. */ | |
213 | |
214 memset (rt, 0, RTX_HDR_SIZE); | |
215 PUT_CODE (rt, code); | |
216 | 223 |
217 if (GATHER_STATISTICS) | 224 if (GATHER_STATISTICS) |
218 { | 225 { |
219 rtx_alloc_counts[code]++; | 226 rtx_alloc_counts[code]++; |
220 rtx_alloc_sizes[code] += RTX_CODE_SIZE (code); | 227 rtx_alloc_sizes[code] += RTX_CODE_SIZE (code); |
301 if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER | 308 if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER |
302 && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0))) | 309 && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0))) |
303 return orig; | 310 return orig; |
304 break; | 311 break; |
305 | 312 |
306 case CLOBBER_HIGH: | |
307 gcc_assert (REG_P (XEXP (orig, 0))); | |
308 return orig; | |
309 | |
310 case CONST: | 313 case CONST: |
311 if (shared_const_p (orig)) | 314 if (shared_const_p (orig)) |
312 return orig; | 315 return orig; |
313 break; | 316 break; |
314 | 317 |
732 return CODE_LABEL; | 735 return CODE_LABEL; |
733 if (GET_CODE (x) == CALL) | 736 if (GET_CODE (x) == CALL) |
734 return CALL_INSN; | 737 return CALL_INSN; |
735 if (ANY_RETURN_P (x)) | 738 if (ANY_RETURN_P (x)) |
736 return JUMP_INSN; | 739 return JUMP_INSN; |
740 if (GET_CODE (x) == ASM_OPERANDS && ASM_OPERANDS_LABEL_VEC (x)) | |
741 return JUMP_INSN; | |
737 if (GET_CODE (x) == SET) | 742 if (GET_CODE (x) == SET) |
738 { | 743 { |
739 if (GET_CODE (SET_DEST (x)) == PC) | 744 if (GET_CODE (SET_DEST (x)) == PC) |
740 return JUMP_INSN; | 745 return JUMP_INSN; |
741 else if (GET_CODE (SET_SRC (x)) == CALL) | 746 else if (GET_CODE (SET_SRC (x)) == CALL) |
758 else if (GET_CODE (XVECEXP (x, 0, j)) == SET | 763 else if (GET_CODE (XVECEXP (x, 0, j)) == SET |
759 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL) | 764 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL) |
760 return CALL_INSN; | 765 return CALL_INSN; |
761 if (has_return_p) | 766 if (has_return_p) |
762 return JUMP_INSN; | 767 return JUMP_INSN; |
768 if (GET_CODE (XVECEXP (x, 0, 0)) == ASM_OPERANDS | |
769 && ASM_OPERANDS_LABEL_VEC (XVECEXP (x, 0, 0))) | |
770 return JUMP_INSN; | |
763 } | 771 } |
764 #ifdef GENERATOR_FILE | 772 #ifdef GENERATOR_FILE |
765 if (GET_CODE (x) == MATCH_OPERAND | 773 if (GET_CODE (x) == MATCH_OPERAND |
766 || GET_CODE (x) == MATCH_OPERATOR | 774 || GET_CODE (x) == MATCH_OPERATOR |
767 || GET_CODE (x) == MATCH_PARALLEL | 775 || GET_CODE (x) == MATCH_PARALLEL |
771 return UNKNOWN; | 779 return UNKNOWN; |
772 #endif | 780 #endif |
773 return INSN; | 781 return INSN; |
774 } | 782 } |
775 | 783 |
784 /* Comparator of indices based on rtx_alloc_counts. */ | |
785 | |
786 static int | |
787 rtx_count_cmp (const void *p1, const void *p2) | |
788 { | |
789 const unsigned *n1 = (const unsigned *)p1; | |
790 const unsigned *n2 = (const unsigned *)p2; | |
791 | |
792 return rtx_alloc_counts[*n1] - rtx_alloc_counts[*n2]; | |
793 } | |
794 | |
776 void | 795 void |
777 dump_rtx_statistics (void) | 796 dump_rtx_statistics (void) |
778 { | 797 { |
779 int i; | |
780 int total_counts = 0; | 798 int total_counts = 0; |
781 int total_sizes = 0; | 799 int total_sizes = 0; |
782 | 800 |
783 if (! GATHER_STATISTICS) | 801 if (! GATHER_STATISTICS) |
784 { | 802 { |
785 fprintf (stderr, "No RTX statistics\n"); | 803 fprintf (stderr, "No RTX statistics\n"); |
786 return; | 804 return; |
787 } | 805 } |
788 | 806 |
789 fprintf (stderr, "\nRTX Kind Count Bytes\n"); | 807 fprintf (stderr, "\nRTX Kind Count Bytes\n"); |
790 fprintf (stderr, "---------------------------------------\n"); | 808 fprintf (stderr, "-------------------------------------------\n"); |
791 for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++) | 809 |
792 if (rtx_alloc_counts[i]) | 810 auto_vec<unsigned> indices (LAST_AND_UNUSED_RTX_CODE); |
793 { | 811 for (unsigned i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++) |
794 fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i), | 812 indices.quick_push (i); |
795 rtx_alloc_counts[i], rtx_alloc_sizes[i]); | 813 indices.qsort (rtx_count_cmp); |
796 total_counts += rtx_alloc_counts[i]; | 814 |
797 total_sizes += rtx_alloc_sizes[i]; | 815 for (unsigned i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++) |
798 } | 816 { |
817 unsigned j = indices[i]; | |
818 if (rtx_alloc_counts[j]) | |
819 { | |
820 fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", | |
821 GET_RTX_NAME (j), | |
822 SIZE_AMOUNT (rtx_alloc_counts[j]), | |
823 SIZE_AMOUNT (rtx_alloc_sizes[j])); | |
824 total_counts += rtx_alloc_counts[j]; | |
825 total_sizes += rtx_alloc_sizes[j]; | |
826 } | |
827 } | |
828 | |
799 if (rtvec_alloc_counts) | 829 if (rtvec_alloc_counts) |
800 { | 830 { |
801 fprintf (stderr, "%-20s %7d %10d\n", "rtvec", | 831 fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", "rtvec", |
802 rtvec_alloc_counts, rtvec_alloc_sizes); | 832 SIZE_AMOUNT (rtvec_alloc_counts), |
833 SIZE_AMOUNT (rtvec_alloc_sizes)); | |
803 total_counts += rtvec_alloc_counts; | 834 total_counts += rtvec_alloc_counts; |
804 total_sizes += rtvec_alloc_sizes; | 835 total_sizes += rtvec_alloc_sizes; |
805 } | 836 } |
806 fprintf (stderr, "---------------------------------------\n"); | 837 fprintf (stderr, "-----------------------------------------------\n"); |
807 fprintf (stderr, "%-20s %7d %10d\n", | 838 fprintf (stderr, "%-24s " PRsa (6) " " PRsa (9) "\n", |
808 "Total", total_counts, total_sizes); | 839 "Total", SIZE_AMOUNT (total_counts), |
809 fprintf (stderr, "---------------------------------------\n"); | 840 SIZE_AMOUNT (total_sizes)); |
841 fprintf (stderr, "-----------------------------------------------\n"); | |
810 } | 842 } |
811 | 843 |
812 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) | 844 #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007) |
813 void | 845 void |
814 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line, | 846 rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line, |