comparison gcc/lists.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* List management for the GCC expander. 1 /* List management for the GCC expander.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 1999, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
5 3
6 This file is part of GCC. 4 This file is part of GCC.
7 5
8 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
9 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
21 19
22 #include "config.h" 20 #include "config.h"
23 #include "system.h" 21 #include "system.h"
24 #include "coretypes.h" 22 #include "coretypes.h"
25 #include "tm.h" 23 #include "tm.h"
26 #include "diagnostic-core.h"
27 #include "rtl.h" 24 #include "rtl.h"
28 #include "ggc.h"
29 25
30 static void free_list (rtx *, rtx *); 26 static void free_list (rtx *, rtx *);
31 27
32 /* Functions for maintaining cache-able lists of EXPR_LIST and INSN_LISTs. */ 28 /* Functions for maintaining cache-able lists of EXPR_LIST and INSN_LISTs. */
33 29
101 } 97 }
102 98
103 /* This call is used in place of a gen_rtx_INSN_LIST. If there is a cached 99 /* This call is used in place of a gen_rtx_INSN_LIST. If there is a cached
104 node available, we'll use it, otherwise a call to gen_rtx_INSN_LIST 100 node available, we'll use it, otherwise a call to gen_rtx_INSN_LIST
105 is made. */ 101 is made. */
106 rtx 102 rtx_insn_list *
107 alloc_INSN_LIST (rtx val, rtx next) 103 alloc_INSN_LIST (rtx val, rtx next)
108 { 104 {
109 rtx r; 105 rtx_insn_list *r;
110 106
111 if (unused_insn_list) 107 if (unused_insn_list)
112 { 108 {
113 r = unused_insn_list; 109 r = as_a <rtx_insn_list *> (unused_insn_list);
114 unused_insn_list = XEXP (r, 1); 110 unused_insn_list = r->next ();
115 XEXP (r, 0) = val; 111 XEXP (r, 0) = val;
116 XEXP (r, 1) = next; 112 XEXP (r, 1) = next;
117 PUT_REG_NOTE_KIND (r, VOIDmode); 113 PUT_REG_NOTE_KIND (r, VOIDmode);
118 114
119 gcc_assert (GET_CODE (r) == INSN_LIST); 115 gcc_assert (GET_CODE (r) == INSN_LIST);
125 } 121 }
126 122
127 /* This call is used in place of a gen_rtx_EXPR_LIST. If there is a cached 123 /* This call is used in place of a gen_rtx_EXPR_LIST. If there is a cached
128 node available, we'll use it, otherwise a call to gen_rtx_EXPR_LIST 124 node available, we'll use it, otherwise a call to gen_rtx_EXPR_LIST
129 is made. */ 125 is made. */
130 rtx 126 rtx_expr_list *
131 alloc_EXPR_LIST (int kind, rtx val, rtx next) 127 alloc_EXPR_LIST (int kind, rtx val, rtx next)
132 { 128 {
133 rtx r; 129 rtx_expr_list *r;
134 130
135 if (unused_expr_list) 131 if (unused_expr_list)
136 { 132 {
137 r = unused_expr_list; 133 r = as_a <rtx_expr_list *> (unused_expr_list);
138 unused_expr_list = XEXP (r, 1); 134 unused_expr_list = XEXP (r, 1);
139 XEXP (r, 0) = val; 135 XEXP (r, 0) = val;
140 XEXP (r, 1) = next; 136 XEXP (r, 1) = next;
141 PUT_REG_NOTE_KIND (r, kind); 137 PUT_REG_NOTE_KIND (r, kind);
142 } 138 }
143 else 139 else
144 r = gen_rtx_EXPR_LIST ((enum machine_mode) kind, val, next); 140 r = gen_rtx_EXPR_LIST ((machine_mode) kind, val, next);
145 141
146 return r; 142 return r;
147 } 143 }
148 144
149 /* This function will free up an entire list of EXPR_LIST nodes. */ 145 /* This function will free up an entire list of EXPR_LIST nodes. */
150 void 146 void
151 free_EXPR_LIST_list (rtx *listp) 147 free_EXPR_LIST_list (rtx_expr_list **listp)
152 { 148 {
153 if (*listp == 0) 149 if (*listp == 0)
154 return; 150 return;
155 free_list (listp, &unused_expr_list); 151 free_list ((rtx *)listp, &unused_expr_list);
156 } 152 }
157 153
158 /* This function will free up an entire list of INSN_LIST nodes. */ 154 /* This function will free up an entire list of INSN_LIST nodes. */
159 void 155 void
160 free_INSN_LIST_list (rtx *listp) 156 free_INSN_LIST_list (rtx_insn_list **listp)
161 { 157 {
162 if (*listp == 0) 158 if (*listp == 0)
163 return; 159 return;
164 free_list (listp, &unused_insn_list); 160 free_list ((rtx *)listp, &unused_insn_list);
161 }
162
163 /* Make a copy of the INSN_LIST list LINK and return it. */
164 rtx_insn_list *
165 copy_INSN_LIST (rtx_insn_list *link)
166 {
167 rtx_insn_list *new_queue;
168 rtx_insn_list **pqueue = &new_queue;
169
170 for (; link; link = link->next ())
171 {
172 rtx_insn *x = link->insn ();
173 rtx_insn_list *newlink = alloc_INSN_LIST (x, NULL);
174 *pqueue = newlink;
175 pqueue = (rtx_insn_list **)&XEXP (newlink, 1);
176 }
177 *pqueue = NULL;
178 return new_queue;
179 }
180
181 /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD. */
182 rtx_insn_list *
183 concat_INSN_LIST (rtx_insn_list *copy, rtx_insn_list *old)
184 {
185 rtx_insn_list *new_rtx = old;
186 for (; copy ; copy = copy->next ())
187 {
188 new_rtx = alloc_INSN_LIST (copy->insn (), new_rtx);
189 PUT_REG_NOTE_KIND (new_rtx, REG_NOTE_KIND (copy));
190 }
191 return new_rtx;
165 } 192 }
166 193
167 /* This function will free up an individual EXPR_LIST node. */ 194 /* This function will free up an individual EXPR_LIST node. */
168 void 195 void
169 free_EXPR_LIST_node (rtx ptr) 196 free_EXPR_LIST_node (rtx ptr)
182 } 209 }
183 210
184 /* Remove and free corresponding to ELEM node in the INSN_LIST pointed to 211 /* Remove and free corresponding to ELEM node in the INSN_LIST pointed to
185 by LISTP. */ 212 by LISTP. */
186 void 213 void
187 remove_free_INSN_LIST_elem (rtx elem, rtx *listp) 214 remove_free_INSN_LIST_elem (rtx_insn *elem, rtx_insn_list **listp)
188 { 215 {
189 free_INSN_LIST_node (remove_list_elem (elem, listp)); 216 free_INSN_LIST_node (remove_list_elem (elem, (rtx *)listp));
190 } 217 }
191 218
192 /* Remove and free the first node in the INSN_LIST pointed to by LISTP. */ 219 /* Remove and free the first node in the INSN_LIST pointed to by LISTP. */
193 rtx 220 rtx_insn *
194 remove_free_INSN_LIST_node (rtx *listp) 221 remove_free_INSN_LIST_node (rtx_insn_list **listp)
195 { 222 {
196 rtx node = *listp; 223 rtx_insn_list *node = *listp;
197 rtx elem = XEXP (node, 0); 224 rtx_insn *elem = node->insn ();
198 225
199 remove_list_node (listp); 226 remove_list_node ((rtx *)listp);
200 free_INSN_LIST_node (node); 227 free_INSN_LIST_node (node);
201 228
202 return elem; 229 return elem;
203 } 230 }
204 231
205 /* Remove and free the first node in the EXPR_LIST pointed to by LISTP. */ 232 /* Remove and free the first node in the EXPR_LIST pointed to by LISTP. */
206 rtx 233 rtx
207 remove_free_EXPR_LIST_node (rtx *listp) 234 remove_free_EXPR_LIST_node (rtx_expr_list **listp)
208 { 235 {
209 rtx node = *listp; 236 rtx_expr_list *node = *listp;
210 rtx elem = XEXP (node, 0); 237 rtx elem = XEXP (node, 0);
211 238
212 remove_list_node (listp); 239 remove_list_node ((rtx *)listp);
213 free_EXPR_LIST_node (node); 240 free_EXPR_LIST_node (node);
214 241
215 return elem; 242 return elem;
216 } 243 }
217 244