author | jbhateja |
Tue, 26 Nov 2019 16:09:25 +0300 | |
changeset 59278 | 8375560db76b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
2 |
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2129
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2129
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2129
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
// FORMS.CPP - Definitions for ADL Parser Forms Classes |
|
26 |
#include "adlc.hpp" |
|
27 |
||
28 |
//==============================Register Allocation============================ |
|
29 |
int RegisterForm::_reg_ctr = 0; |
|
30 |
||
31 |
//------------------------------RegisterForm----------------------------------- |
|
32 |
// Constructor |
|
33 |
RegisterForm::RegisterForm() |
|
34 |
: _regDef(cmpstr,hashstr, Form::arena), |
|
35 |
_regClass(cmpstr,hashstr, Form::arena), |
|
36 |
_allocClass(cmpstr,hashstr, Form::arena) { |
|
37 |
} |
|
38 |
RegisterForm::~RegisterForm() { |
|
39 |
} |
|
40 |
||
41 |
// record a new register definition |
|
42 |
void RegisterForm::addRegDef(char *name, char *callingConv, char *c_conv, |
|
43 |
char *idealtype, char *encoding, char* concrete) { |
|
44 |
RegDef *regDef = new RegDef(name, callingConv, c_conv, idealtype, encoding, concrete); |
|
45 |
_rdefs.addName(name); |
|
46 |
_regDef.Insert(name,regDef); |
|
47 |
} |
|
48 |
||
49 |
// record a new register class |
|
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
50 |
template <typename T> |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
51 |
T* RegisterForm::addRegClass(const char* className) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
52 |
T* regClass = new T(className); |
1 | 53 |
_rclasses.addName(className); |
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
54 |
_regClass.Insert(className, regClass); |
1 | 55 |
return regClass; |
56 |
} |
|
57 |
||
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
58 |
// Explicit instantiation for all supported register classes. |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
59 |
template RegClass* RegisterForm::addRegClass<RegClass>(const char* className); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
60 |
template CodeSnippetRegClass* RegisterForm::addRegClass<CodeSnippetRegClass>(const char* className); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
61 |
template ConditionalRegClass* RegisterForm::addRegClass<ConditionalRegClass>(const char* className); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
62 |
|
1 | 63 |
// record a new register class |
64 |
AllocClass *RegisterForm::addAllocClass(char *className) { |
|
65 |
AllocClass *allocClass = new AllocClass(className); |
|
66 |
_aclasses.addName(className); |
|
67 |
_allocClass.Insert(className,allocClass); |
|
68 |
return allocClass; |
|
69 |
} |
|
70 |
||
71 |
// Called after parsing the Register block. Record the register class |
|
72 |
// for spill-slots/regs. |
|
73 |
void RegisterForm::addSpillRegClass() { |
|
74 |
// Stack slots start at the next available even register number. |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
75 |
_reg_ctr = (_reg_ctr+7) & ~7; |
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
76 |
const char *rc_name = "stack_slots"; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
77 |
RegClass* reg_class = new RegClass(rc_name); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
78 |
reg_class->set_stack_version(true); |
1 | 79 |
_rclasses.addName(rc_name); |
80 |
_regClass.Insert(rc_name,reg_class); |
|
81 |
} |
|
82 |
||
59278
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
83 |
// Called after parsing the Register block. Record the register class |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
84 |
// for operands which are overwritten after matching. |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
85 |
void RegisterForm::addDynamicRegClass() { |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
86 |
const char *rc_name = "dynamic"; |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
87 |
RegClass* reg_class = new RegClass(rc_name); |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
88 |
reg_class->set_stack_version(false); |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
89 |
_rclasses.addName(rc_name); |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
90 |
_regClass.Insert(rc_name,reg_class); |
8375560db76b
8234394: C2: Dynamic register class support in ADLC
jbhateja
parents:
47216
diff
changeset
|
91 |
} |
1 | 92 |
|
93 |
// Provide iteration over all register definitions |
|
94 |
// in the order used by the register allocator |
|
95 |
void RegisterForm::reset_RegDefs() { |
|
96 |
_current_ac = NULL; |
|
97 |
_aclasses.reset(); |
|
98 |
} |
|
99 |
||
100 |
RegDef *RegisterForm::iter_RegDefs() { |
|
101 |
// Check if we need to get the next AllocClass |
|
102 |
if ( _current_ac == NULL ) { |
|
103 |
const char *ac_name = _aclasses.iter(); |
|
104 |
if( ac_name == NULL ) return NULL; // No more allocation classes |
|
105 |
_current_ac = (AllocClass*)_allocClass[ac_name]; |
|
106 |
_current_ac->_regDefs.reset(); |
|
107 |
assert( _current_ac != NULL, "Name must match an allocation class"); |
|
108 |
} |
|
109 |
||
110 |
const char *rd_name = _current_ac->_regDefs.iter(); |
|
111 |
if( rd_name == NULL ) { |
|
112 |
// At end of this allocation class, check the next |
|
113 |
_current_ac = NULL; |
|
114 |
return iter_RegDefs(); |
|
115 |
} |
|
116 |
RegDef *reg_def = (RegDef*)_current_ac->_regDef[rd_name]; |
|
117 |
assert( reg_def != NULL, "Name must match a register definition"); |
|
118 |
return reg_def; |
|
119 |
} |
|
120 |
||
121 |
// return the register definition with name 'regName' |
|
122 |
RegDef *RegisterForm::getRegDef(const char *regName) { |
|
123 |
RegDef *regDef = (RegDef*)_regDef[regName]; |
|
124 |
return regDef; |
|
125 |
} |
|
126 |
||
127 |
// return the register class with name 'className' |
|
128 |
RegClass *RegisterForm::getRegClass(const char *className) { |
|
129 |
RegClass *regClass = (RegClass*)_regClass[className]; |
|
130 |
return regClass; |
|
131 |
} |
|
132 |
||
133 |
||
134 |
// Check that register classes are compatible with chunks |
|
135 |
bool RegisterForm::verify() { |
|
136 |
bool valid = true; |
|
137 |
||
138 |
// Verify Register Classes |
|
139 |
// check that each register class contains registers from one chunk |
|
140 |
const char *rc_name = NULL; |
|
141 |
_rclasses.reset(); |
|
142 |
while ( (rc_name = _rclasses.iter()) != NULL ) { |
|
143 |
// Check the chunk value for all registers in this class |
|
144 |
RegClass *reg_class = getRegClass(rc_name); |
|
145 |
assert( reg_class != NULL, "InternalError() no matching register class"); |
|
146 |
} // end of RegClasses |
|
147 |
||
148 |
// Verify that every register has been placed into an allocation class |
|
149 |
RegDef *reg_def = NULL; |
|
150 |
reset_RegDefs(); |
|
151 |
uint num_register_zero = 0; |
|
152 |
while ( (reg_def = iter_RegDefs()) != NULL ) { |
|
153 |
if( reg_def->register_num() == 0 ) ++num_register_zero; |
|
154 |
} |
|
155 |
if( num_register_zero > 1 ) { |
|
156 |
fprintf(stderr, |
|
157 |
"ERROR: More than one register has been assigned register-number 0.\n" |
|
158 |
"Probably because a register has not been entered into an allocation class.\n"); |
|
159 |
} |
|
160 |
||
161 |
return valid; |
|
162 |
} |
|
163 |
||
164 |
// Compute RegMask size |
|
165 |
int RegisterForm::RegMask_Size() { |
|
166 |
// Need at least this many words |
|
167 |
int words_for_regs = (_reg_ctr + 31)>>5; |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
168 |
// The array of Register Mask bits should be large enough to cover |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
169 |
// all the machine registers and all parameters that need to be passed |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
170 |
// on the stack (stack registers) up to some interesting limit. Methods |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
171 |
// that need more parameters will NOT be compiled. On Intel, the limit |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
172 |
// is something like 90+ parameters. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
173 |
// Add a few (3 words == 96 bits) for incoming & outgoing arguments to calls. |
1 | 174 |
// Round up to the next doubleword size. |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
11197
diff
changeset
|
175 |
return (words_for_regs + 3 + 1) & ~1; |
1 | 176 |
} |
177 |
||
178 |
void RegisterForm::dump() { // Debug printer |
|
179 |
output(stderr); |
|
180 |
} |
|
181 |
||
182 |
void RegisterForm::output(FILE *fp) { // Write info to output files |
|
183 |
const char *name; |
|
184 |
fprintf(fp,"\n"); |
|
185 |
fprintf(fp,"-------------------- Dump RegisterForm --------------------\n"); |
|
186 |
for(_rdefs.reset(); (name = _rdefs.iter()) != NULL;) { |
|
187 |
((RegDef*)_regDef[name])->output(fp); |
|
188 |
} |
|
189 |
fprintf(fp,"\n"); |
|
190 |
for (_rclasses.reset(); (name = _rclasses.iter()) != NULL;) { |
|
191 |
((RegClass*)_regClass[name])->output(fp); |
|
192 |
} |
|
193 |
fprintf(fp,"\n"); |
|
194 |
for (_aclasses.reset(); (name = _aclasses.iter()) != NULL;) { |
|
195 |
((AllocClass*)_allocClass[name])->output(fp); |
|
196 |
} |
|
197 |
fprintf(fp,"-------------------- end RegisterForm --------------------\n"); |
|
198 |
} |
|
199 |
||
200 |
//------------------------------RegDef----------------------------------------- |
|
201 |
// Constructor |
|
202 |
RegDef::RegDef(char *regname, char *callconv, char *c_conv, char * idealtype, char * encode, char * concrete) |
|
203 |
: _regname(regname), _callconv(callconv), _c_conv(c_conv), |
|
204 |
_idealtype(idealtype), |
|
205 |
_register_encode(encode), |
|
206 |
_concrete(concrete), |
|
207 |
_register_num(0) { |
|
208 |
||
209 |
// Chunk and register mask are determined by the register number |
|
210 |
// _register_num is set when registers are added to an allocation class |
|
211 |
} |
|
212 |
RegDef::~RegDef() { // Destructor |
|
213 |
} |
|
214 |
||
215 |
void RegDef::set_register_num(uint32 register_num) { |
|
216 |
_register_num = register_num; |
|
217 |
} |
|
218 |
||
219 |
// Bit pattern used for generating machine code |
|
220 |
const char* RegDef::register_encode() const { |
|
221 |
return _register_encode; |
|
222 |
} |
|
223 |
||
224 |
// Register number used in machine-independent code |
|
225 |
uint32 RegDef::register_num() const { |
|
226 |
return _register_num; |
|
227 |
} |
|
228 |
||
229 |
void RegDef::dump() { |
|
230 |
output(stderr); |
|
231 |
} |
|
232 |
||
233 |
void RegDef::output(FILE *fp) { // Write info to output files |
|
234 |
fprintf(fp,"RegDef: %s (%s) encode as %s using number %d\n", |
|
235 |
_regname, (_callconv?_callconv:""), _register_encode, _register_num); |
|
236 |
fprintf(fp,"\n"); |
|
237 |
} |
|
238 |
||
239 |
||
240 |
//------------------------------RegClass--------------------------------------- |
|
241 |
// Construct a register class into which registers will be inserted |
|
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
242 |
RegClass::RegClass(const char* classid) : _stack_or_reg(false), _classid(classid), _regDef(cmpstr, hashstr, Form::arena) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
243 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
244 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
245 |
RegClass::~RegClass() { |
1 | 246 |
} |
247 |
||
248 |
// record a register in this class |
|
249 |
void RegClass::addReg(RegDef *regDef) { |
|
250 |
_regDefs.addName(regDef->_regname); |
|
251 |
_regDef.Insert((void*)regDef->_regname, regDef); |
|
252 |
} |
|
253 |
||
254 |
// Number of registers in class |
|
255 |
uint RegClass::size() const { |
|
256 |
return _regDef.Size(); |
|
257 |
} |
|
258 |
||
259 |
const RegDef *RegClass::get_RegDef(const char *rd_name) const { |
|
260 |
return (const RegDef*)_regDef[rd_name]; |
|
261 |
} |
|
262 |
||
263 |
void RegClass::reset() { |
|
264 |
_regDefs.reset(); |
|
265 |
} |
|
266 |
||
267 |
const char *RegClass::rd_name_iter() { |
|
268 |
return _regDefs.iter(); |
|
269 |
} |
|
270 |
||
271 |
RegDef *RegClass::RegDef_iter() { |
|
272 |
const char *rd_name = rd_name_iter(); |
|
273 |
RegDef *reg_def = rd_name ? (RegDef*)_regDef[rd_name] : NULL; |
|
274 |
return reg_def; |
|
275 |
} |
|
276 |
||
277 |
const RegDef* RegClass::find_first_elem() { |
|
278 |
const RegDef* first = NULL; |
|
279 |
const RegDef* def = NULL; |
|
280 |
||
281 |
reset(); |
|
282 |
while ((def = RegDef_iter()) != NULL) { |
|
283 |
if (first == NULL || def->register_num() < first->register_num()) { |
|
284 |
first = def; |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
assert(first != NULL, "empty mask?"); |
|
289 |
return first;; |
|
290 |
} |
|
291 |
||
292 |
// Collect all the registers in this register-word. One bit per register. |
|
293 |
int RegClass::regs_in_word( int wordnum, bool stack_also ) { |
|
294 |
int word = 0; |
|
295 |
const char *name; |
|
296 |
for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) { |
|
297 |
int rnum = ((RegDef*)_regDef[name])->register_num(); |
|
298 |
if( (rnum >> 5) == wordnum ) |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
299 |
word |= (1 << (rnum & 31)); |
1 | 300 |
} |
301 |
if( stack_also ) { |
|
302 |
// Now also collect stack bits |
|
303 |
for( int i = 0; i < 32; i++ ) |
|
304 |
if( wordnum*32+i >= RegisterForm::_reg_ctr ) |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
305 |
word |= (1 << i); |
1 | 306 |
} |
307 |
||
308 |
return word; |
|
309 |
} |
|
310 |
||
311 |
void RegClass::dump() { |
|
312 |
output(stderr); |
|
313 |
} |
|
314 |
||
315 |
void RegClass::output(FILE *fp) { // Write info to output files |
|
316 |
fprintf(fp,"RegClass: %s\n",_classid); |
|
317 |
const char *name; |
|
318 |
for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) { |
|
319 |
((RegDef*)_regDef[name])->output(fp); |
|
320 |
} |
|
321 |
fprintf(fp,"--- done with entries for reg_class %s\n\n",_classid); |
|
322 |
} |
|
323 |
||
30202
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
324 |
void RegClass::declare_register_masks(FILE* fp) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
325 |
const char* prefix = ""; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
326 |
const char* rc_name_to_upper = toUpper(_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
327 |
fprintf(fp, "extern const RegMask _%s%s_mask;\n", prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
328 |
fprintf(fp, "inline const RegMask &%s%s_mask() { return _%s%s_mask; }\n", prefix, rc_name_to_upper, prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
329 |
if (_stack_or_reg) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
330 |
fprintf(fp, "extern const RegMask _%sSTACK_OR_%s_mask;\n", prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
331 |
fprintf(fp, "inline const RegMask &%sSTACK_OR_%s_mask() { return _%sSTACK_OR_%s_mask; }\n", prefix, rc_name_to_upper, prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
332 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
333 |
delete[] rc_name_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
334 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
335 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
336 |
void RegClass::build_register_masks(FILE* fp) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
337 |
int len = RegisterForm::RegMask_Size(); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
338 |
const char *prefix = ""; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
339 |
const char* rc_name_to_upper = toUpper(_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
340 |
fprintf(fp, "const RegMask _%s%s_mask(", prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
341 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
342 |
int i; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
343 |
for(i = 0; i < len - 1; i++) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
344 |
fprintf(fp," 0x%x,", regs_in_word(i, false)); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
345 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
346 |
fprintf(fp," 0x%x );\n", regs_in_word(i, false)); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
347 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
348 |
if (_stack_or_reg) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
349 |
fprintf(fp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, rc_name_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
350 |
for(i = 0; i < len - 1; i++) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
351 |
fprintf(fp," 0x%x,", regs_in_word(i, true)); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
352 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
353 |
fprintf(fp," 0x%x );\n", regs_in_word(i, true)); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
354 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
355 |
delete[] rc_name_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
356 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
357 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
358 |
//------------------------------CodeSnippetRegClass--------------------------- |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
359 |
CodeSnippetRegClass::CodeSnippetRegClass(const char* classid) : RegClass(classid), _code_snippet(NULL) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
360 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
361 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
362 |
CodeSnippetRegClass::~CodeSnippetRegClass() { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
363 |
delete _code_snippet; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
364 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
365 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
366 |
void CodeSnippetRegClass::declare_register_masks(FILE* fp) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
367 |
const char* prefix = ""; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
368 |
const char* rc_name_to_upper = toUpper(_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
369 |
fprintf(fp, "inline const RegMask &%s%s_mask() { %s }\n", prefix, rc_name_to_upper, _code_snippet); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
370 |
delete[] rc_name_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
371 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
372 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
373 |
//------------------------------ConditionalRegClass--------------------------- |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
374 |
ConditionalRegClass::ConditionalRegClass(const char *classid) : RegClass(classid), _condition_code(NULL) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
375 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
376 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
377 |
ConditionalRegClass::~ConditionalRegClass() { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
378 |
delete _condition_code; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
379 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
380 |
|
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
381 |
void ConditionalRegClass::declare_register_masks(FILE* fp) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
382 |
const char* prefix = ""; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
383 |
const char* rc_name_to_upper = toUpper(_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
384 |
const char* rclass_0_to_upper = toUpper(_rclasses[0]->_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
385 |
const char* rclass_1_to_upper = toUpper(_rclasses[1]->_classid); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
386 |
fprintf(fp, "inline const RegMask &%s%s_mask() {" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
387 |
" return (%s) ?" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
388 |
" %s%s_mask() :" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
389 |
" %s%s_mask(); }\n", |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
390 |
prefix, rc_name_to_upper, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
391 |
_condition_code, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
392 |
prefix, rclass_0_to_upper, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
393 |
prefix, rclass_1_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
394 |
if (_stack_or_reg) { |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
395 |
fprintf(fp, "inline const RegMask &%sSTACK_OR_%s_mask() {" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
396 |
" return (%s) ?" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
397 |
" %sSTACK_OR_%s_mask() :" |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
398 |
" %sSTACK_OR_%s_mask(); }\n", |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
399 |
prefix, rc_name_to_upper, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
400 |
_condition_code, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
401 |
prefix, rclass_0_to_upper, |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
402 |
prefix, rclass_1_to_upper); |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
403 |
} |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
404 |
delete[] rc_name_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
405 |
delete[] rclass_0_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
406 |
delete[] rclass_1_to_upper; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
407 |
return; |
6f5c48bd9b82
8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents:
13104
diff
changeset
|
408 |
} |
1 | 409 |
|
410 |
//------------------------------AllocClass------------------------------------- |
|
411 |
AllocClass::AllocClass(char *classid) : _classid(classid), _regDef(cmpstr,hashstr, Form::arena) { |
|
412 |
} |
|
413 |
||
414 |
// record a register in this class |
|
415 |
void AllocClass::addReg(RegDef *regDef) { |
|
416 |
assert( regDef != NULL, "Can not add a NULL to an allocation class"); |
|
417 |
regDef->set_register_num( RegisterForm::_reg_ctr++ ); |
|
418 |
// Add regDef to this allocation class |
|
419 |
_regDefs.addName(regDef->_regname); |
|
420 |
_regDef.Insert((void*)regDef->_regname, regDef); |
|
421 |
} |
|
422 |
||
423 |
void AllocClass::dump() { |
|
424 |
output(stderr); |
|
425 |
} |
|
426 |
||
427 |
void AllocClass::output(FILE *fp) { // Write info to output files |
|
428 |
fprintf(fp,"AllocClass: %s \n",_classid); |
|
429 |
const char *name; |
|
430 |
for(_regDefs.reset(); (name = _regDefs.iter()) != NULL;) { |
|
431 |
((RegDef*)_regDef[name])->output(fp); |
|
432 |
} |
|
433 |
fprintf(fp,"--- done with entries for alloc_class %s\n\n",_classid); |
|
434 |
} |
|
435 |
||
436 |
//==============================Frame Handling================================= |
|
437 |
//------------------------------FrameForm-------------------------------------- |
|
438 |
FrameForm::FrameForm() { |
|
439 |
_frame_pointer = NULL; |
|
440 |
_c_frame_pointer = NULL; |
|
441 |
_alignment = NULL; |
|
442 |
_return_addr = NULL; |
|
443 |
_c_return_addr = NULL; |
|
444 |
_in_preserve_slots = NULL; |
|
445 |
_varargs_C_out_slots_killed = NULL; |
|
446 |
_calling_convention = NULL; |
|
447 |
_c_calling_convention = NULL; |
|
448 |
_return_value = NULL; |
|
449 |
_c_return_value = NULL; |
|
450 |
_interpreter_frame_pointer_reg = NULL; |
|
451 |
} |
|
452 |
||
453 |
FrameForm::~FrameForm() { |
|
454 |
} |
|
455 |
||
456 |
void FrameForm::dump() { |
|
457 |
output(stderr); |
|
458 |
} |
|
459 |
||
460 |
void FrameForm::output(FILE *fp) { // Write info to output files |
|
461 |
fprintf(fp,"\nFrame:\n"); |
|
462 |
} |
|
463 |
||
464 |
//==============================Scheduling===================================== |
|
465 |
//------------------------------PipelineForm----------------------------------- |
|
466 |
PipelineForm::PipelineForm() |
|
467 |
: _reslist () |
|
468 |
, _resdict (cmpstr, hashstr, Form::arena) |
|
469 |
, _classdict (cmpstr, hashstr, Form::arena) |
|
470 |
, _rescount (0) |
|
471 |
, _maxcycleused (0) |
|
472 |
, _stages () |
|
473 |
, _stagecnt (0) |
|
474 |
, _classlist () |
|
475 |
, _classcnt (0) |
|
476 |
, _noplist () |
|
477 |
, _nopcnt (0) |
|
478 |
, _variableSizeInstrs (false) |
|
479 |
, _branchHasDelaySlot (false) |
|
480 |
, _maxInstrsPerBundle (0) |
|
481 |
, _maxBundlesPerCycle (1) |
|
482 |
, _instrUnitSize (0) |
|
483 |
, _bundleUnitSize (0) |
|
484 |
, _instrFetchUnitSize (0) |
|
485 |
, _instrFetchUnits (0) { |
|
486 |
} |
|
487 |
PipelineForm::~PipelineForm() { |
|
488 |
} |
|
489 |
||
490 |
void PipelineForm::dump() { |
|
491 |
output(stderr); |
|
492 |
} |
|
493 |
||
494 |
void PipelineForm::output(FILE *fp) { // Write info to output files |
|
495 |
const char *res; |
|
496 |
const char *stage; |
|
497 |
const char *cls; |
|
498 |
const char *nop; |
|
499 |
int count = 0; |
|
500 |
||
501 |
fprintf(fp,"\nPipeline:"); |
|
502 |
if (_variableSizeInstrs) |
|
503 |
if (_instrUnitSize > 0) |
|
504 |
fprintf(fp," variable-sized instructions in %d byte units", _instrUnitSize); |
|
505 |
else |
|
506 |
fprintf(fp," variable-sized instructions"); |
|
507 |
else |
|
508 |
if (_instrUnitSize > 0) |
|
509 |
fprintf(fp," fixed-sized instructions of %d bytes", _instrUnitSize); |
|
510 |
else if (_bundleUnitSize > 0) |
|
511 |
fprintf(fp," fixed-sized bundles of %d bytes", _bundleUnitSize); |
|
512 |
else |
|
513 |
fprintf(fp," fixed-sized instructions"); |
|
514 |
if (_branchHasDelaySlot) |
|
515 |
fprintf(fp,", branch has delay slot"); |
|
516 |
if (_maxInstrsPerBundle > 0) |
|
517 |
fprintf(fp,", max of %d instruction%s in parallel", |
|
518 |
_maxInstrsPerBundle, _maxInstrsPerBundle > 1 ? "s" : ""); |
|
519 |
if (_maxBundlesPerCycle > 0) |
|
520 |
fprintf(fp,", max of %d bundle%s in parallel", |
|
521 |
_maxBundlesPerCycle, _maxBundlesPerCycle > 1 ? "s" : ""); |
|
522 |
if (_instrFetchUnitSize > 0 && _instrFetchUnits) |
|
523 |
fprintf(fp, ", fetch %d x % d bytes per cycle", _instrFetchUnits, _instrFetchUnitSize); |
|
524 |
||
525 |
fprintf(fp,"\nResource:"); |
|
526 |
for ( _reslist.reset(); (res = _reslist.iter()) != NULL; ) |
|
527 |
fprintf(fp," %s(0x%08x)", res, _resdict[res]->is_resource()->mask()); |
|
528 |
fprintf(fp,"\n"); |
|
529 |
||
530 |
fprintf(fp,"\nDescription:\n"); |
|
531 |
for ( _stages.reset(); (stage = _stages.iter()) != NULL; ) |
|
532 |
fprintf(fp," %s(%d)", stage, count++); |
|
533 |
fprintf(fp,"\n"); |
|
534 |
||
535 |
fprintf(fp,"\nClasses:\n"); |
|
536 |
for ( _classlist.reset(); (cls = _classlist.iter()) != NULL; ) |
|
537 |
_classdict[cls]->is_pipeclass()->output(fp); |
|
538 |
||
539 |
fprintf(fp,"\nNop Instructions:"); |
|
540 |
for ( _noplist.reset(); (nop = _noplist.iter()) != NULL; ) |
|
541 |
fprintf(fp, " \"%s\"", nop); |
|
542 |
fprintf(fp,"\n"); |
|
543 |
} |
|
544 |
||
545 |
||
546 |
//------------------------------ResourceForm----------------------------------- |
|
547 |
ResourceForm::ResourceForm(unsigned resmask) |
|
548 |
: _resmask(resmask) { |
|
549 |
} |
|
550 |
ResourceForm::~ResourceForm() { |
|
551 |
} |
|
552 |
||
553 |
ResourceForm *ResourceForm::is_resource() const { |
|
554 |
return (ResourceForm *)(this); |
|
555 |
} |
|
556 |
||
557 |
void ResourceForm::dump() { |
|
558 |
output(stderr); |
|
559 |
} |
|
560 |
||
561 |
void ResourceForm::output(FILE *fp) { // Write info to output files |
|
562 |
fprintf(fp, "resource: 0x%08x;\n", mask()); |
|
563 |
} |
|
564 |
||
565 |
||
566 |
//------------------------------PipeClassOperandForm---------------------------------- |
|
567 |
||
568 |
void PipeClassOperandForm::dump() { |
|
569 |
output(stderr); |
|
570 |
} |
|
571 |
||
572 |
void PipeClassOperandForm::output(FILE *fp) { // Write info to output files |
|
573 |
fprintf(stderr,"PipeClassOperandForm: %s", _stage); |
|
574 |
fflush(stderr); |
|
575 |
if (_more_instrs > 0) |
|
576 |
fprintf(stderr,"+%d", _more_instrs); |
|
577 |
fprintf(stderr," (%s)\n", _iswrite ? "write" : "read"); |
|
578 |
fflush(stderr); |
|
579 |
fprintf(fp,"PipeClassOperandForm: %s", _stage); |
|
580 |
if (_more_instrs > 0) |
|
581 |
fprintf(fp,"+%d", _more_instrs); |
|
582 |
fprintf(fp," (%s)\n", _iswrite ? "write" : "read"); |
|
583 |
} |
|
584 |
||
585 |
||
586 |
//------------------------------PipeClassResourceForm---------------------------------- |
|
587 |
||
588 |
void PipeClassResourceForm::dump() { |
|
589 |
output(stderr); |
|
590 |
} |
|
591 |
||
592 |
void PipeClassResourceForm::output(FILE *fp) { // Write info to output files |
|
593 |
fprintf(fp,"PipeClassResourceForm: %s at stage %s for %d cycles\n", |
|
594 |
_resource, _stage, _cycles); |
|
595 |
} |
|
596 |
||
597 |
||
598 |
//------------------------------PipeClassForm---------------------------------- |
|
599 |
PipeClassForm::PipeClassForm(const char *id, int num) |
|
600 |
: _ident(id) |
|
601 |
, _num(num) |
|
602 |
, _localNames(cmpstr, hashstr, Form::arena) |
|
603 |
, _localUsage(cmpstr, hashstr, Form::arena) |
|
604 |
, _has_fixed_latency(0) |
|
605 |
, _fixed_latency(0) |
|
606 |
, _instruction_count(0) |
|
607 |
, _has_multiple_bundles(false) |
|
608 |
, _has_branch_delay_slot(false) |
|
609 |
, _force_serialization(false) |
|
610 |
, _may_have_no_code(false) { |
|
611 |
} |
|
612 |
||
613 |
PipeClassForm::~PipeClassForm() { |
|
614 |
} |
|
615 |
||
616 |
PipeClassForm *PipeClassForm::is_pipeclass() const { |
|
617 |
return (PipeClassForm *)(this); |
|
618 |
} |
|
619 |
||
620 |
void PipeClassForm::dump() { |
|
621 |
output(stderr); |
|
622 |
} |
|
623 |
||
624 |
void PipeClassForm::output(FILE *fp) { // Write info to output files |
|
625 |
fprintf(fp,"PipeClassForm: #%03d", _num); |
|
626 |
if (_ident) |
|
627 |
fprintf(fp," \"%s\":", _ident); |
|
628 |
if (_has_fixed_latency) |
|
629 |
fprintf(fp," latency %d", _fixed_latency); |
|
630 |
if (_force_serialization) |
|
631 |
fprintf(fp, ", force serialization"); |
|
632 |
if (_may_have_no_code) |
|
633 |
fprintf(fp, ", may have no code"); |
|
634 |
fprintf(fp, ", %d instruction%s\n", InstructionCount(), InstructionCount() != 1 ? "s" : ""); |
|
635 |
} |
|
636 |
||
637 |
||
638 |
//==============================Peephole Optimization========================== |
|
639 |
int Peephole::_peephole_counter = 0; |
|
640 |
//------------------------------Peephole--------------------------------------- |
|
641 |
Peephole::Peephole() : _match(NULL), _constraint(NULL), _replace(NULL), _next(NULL) { |
|
642 |
_peephole_number = _peephole_counter++; |
|
643 |
} |
|
644 |
Peephole::~Peephole() { |
|
645 |
} |
|
646 |
||
647 |
// Append a peephole rule with the same root instruction |
|
648 |
void Peephole::append_peephole(Peephole *next_peephole) { |
|
649 |
if( _next == NULL ) { |
|
650 |
_next = next_peephole; |
|
651 |
} else { |
|
652 |
_next->append_peephole( next_peephole ); |
|
653 |
} |
|
654 |
} |
|
655 |
||
656 |
// Store the components of this peephole rule |
|
657 |
void Peephole::add_match(PeepMatch *match) { |
|
658 |
assert( _match == NULL, "fatal()" ); |
|
659 |
_match = match; |
|
660 |
} |
|
661 |
||
662 |
void Peephole::append_constraint(PeepConstraint *next_constraint) { |
|
663 |
if( _constraint == NULL ) { |
|
664 |
_constraint = next_constraint; |
|
665 |
} else { |
|
666 |
_constraint->append( next_constraint ); |
|
667 |
} |
|
668 |
} |
|
669 |
||
670 |
void Peephole::add_replace(PeepReplace *replace) { |
|
671 |
assert( _replace == NULL, "fatal()" ); |
|
672 |
_replace = replace; |
|
673 |
} |
|
674 |
||
675 |
// class Peephole accessor methods are in the declaration. |
|
676 |
||
677 |
||
678 |
void Peephole::dump() { |
|
679 |
output(stderr); |
|
680 |
} |
|
681 |
||
682 |
void Peephole::output(FILE *fp) { // Write info to output files |
|
683 |
fprintf(fp,"Peephole:\n"); |
|
684 |
if( _match != NULL ) _match->output(fp); |
|
685 |
if( _constraint != NULL ) _constraint->output(fp); |
|
686 |
if( _replace != NULL ) _replace->output(fp); |
|
687 |
// Output the next entry |
|
688 |
if( _next ) _next->output(fp); |
|
689 |
} |
|
690 |
||
691 |
//------------------------------PeepMatch-------------------------------------- |
|
692 |
PeepMatch::PeepMatch(char *rule) : _max_position(0), _rule(rule) { |
|
693 |
} |
|
694 |
PeepMatch::~PeepMatch() { |
|
695 |
} |
|
696 |
||
697 |
||
698 |
// Insert info into the match-rule |
|
699 |
void PeepMatch::add_instruction(int parent, int position, const char *name, |
|
700 |
int input) { |
|
701 |
if( position > _max_position ) _max_position = position; |
|
702 |
||
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
703 |
_parent.addName((char*) (intptr_t) parent); |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
704 |
_position.addName((char*) (intptr_t) position); |
1 | 705 |
_instrs.addName(name); |
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
706 |
_input.addName((char*) (intptr_t) input); |
1 | 707 |
} |
708 |
||
709 |
// Access info about instructions in the peep-match rule |
|
710 |
int PeepMatch::max_position() { |
|
711 |
return _max_position; |
|
712 |
} |
|
713 |
||
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
714 |
const char *PeepMatch::instruction_name(int position) { |
1 | 715 |
return _instrs.name(position); |
716 |
} |
|
717 |
||
718 |
// Iterate through all info on matched instructions |
|
719 |
void PeepMatch::reset() { |
|
720 |
_parent.reset(); |
|
721 |
_position.reset(); |
|
722 |
_instrs.reset(); |
|
723 |
_input.reset(); |
|
724 |
} |
|
725 |
||
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
726 |
void PeepMatch::next_instruction(int &parent, int &position, const char* &name, int &input) { |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
727 |
parent = (int) (intptr_t) _parent.iter(); |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
728 |
position = (int) (intptr_t) _position.iter(); |
1 | 729 |
name = _instrs.iter(); |
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
730 |
input = (int) (intptr_t) _input.iter(); |
1 | 731 |
} |
732 |
||
733 |
// 'true' if current position in iteration is a placeholder, not matched. |
|
734 |
bool PeepMatch::is_placeholder() { |
|
735 |
return _instrs.current_is_signal(); |
|
736 |
} |
|
737 |
||
738 |
||
739 |
void PeepMatch::dump() { |
|
740 |
output(stderr); |
|
741 |
} |
|
742 |
||
743 |
void PeepMatch::output(FILE *fp) { // Write info to output files |
|
744 |
fprintf(fp,"PeepMatch:\n"); |
|
745 |
} |
|
746 |
||
747 |
//------------------------------PeepConstraint--------------------------------- |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
748 |
PeepConstraint::PeepConstraint(int left_inst, char* left_op, char* relation, |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
749 |
int right_inst, char* right_op) |
1 | 750 |
: _left_inst(left_inst), _left_op(left_op), _relation(relation), |
751 |
_right_inst(right_inst), _right_op(right_op), _next(NULL) {} |
|
752 |
PeepConstraint::~PeepConstraint() { |
|
753 |
} |
|
754 |
||
755 |
// Check if constraints use instruction at position |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
756 |
bool PeepConstraint::constrains_instruction(int position) { |
1 | 757 |
// Check local instruction constraints |
758 |
if( _left_inst == position ) return true; |
|
759 |
if( _right_inst == position ) return true; |
|
760 |
||
761 |
// Check remaining constraints in list |
|
762 |
if( _next == NULL ) return false; |
|
763 |
else return _next->constrains_instruction(position); |
|
764 |
} |
|
765 |
||
766 |
// Add another constraint |
|
767 |
void PeepConstraint::append(PeepConstraint *next_constraint) { |
|
768 |
if( _next == NULL ) { |
|
769 |
_next = next_constraint; |
|
770 |
} else { |
|
771 |
_next->append( next_constraint ); |
|
772 |
} |
|
773 |
} |
|
774 |
||
775 |
// Access the next constraint in the list |
|
776 |
PeepConstraint *PeepConstraint::next() { |
|
777 |
return _next; |
|
778 |
} |
|
779 |
||
780 |
||
781 |
void PeepConstraint::dump() { |
|
782 |
output(stderr); |
|
783 |
} |
|
784 |
||
785 |
void PeepConstraint::output(FILE *fp) { // Write info to output files |
|
786 |
fprintf(fp,"PeepConstraint:\n"); |
|
787 |
} |
|
788 |
||
789 |
//------------------------------PeepReplace------------------------------------ |
|
790 |
PeepReplace::PeepReplace(char *rule) : _rule(rule) { |
|
791 |
} |
|
792 |
PeepReplace::~PeepReplace() { |
|
793 |
} |
|
794 |
||
795 |
// Add contents of peepreplace |
|
796 |
void PeepReplace::add_instruction(char *root) { |
|
797 |
_instruction.addName(root); |
|
798 |
_operand_inst_num.add_signal(); |
|
799 |
_operand_op_name.add_signal(); |
|
800 |
} |
|
801 |
void PeepReplace::add_operand( int inst_num, char *inst_operand ) { |
|
802 |
_instruction.add_signal(); |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
803 |
_operand_inst_num.addName((char*) (intptr_t) inst_num); |
1 | 804 |
_operand_op_name.addName(inst_operand); |
805 |
} |
|
806 |
||
807 |
// Access contents of peepreplace |
|
808 |
void PeepReplace::reset() { |
|
809 |
_instruction.reset(); |
|
810 |
_operand_inst_num.reset(); |
|
811 |
_operand_op_name.reset(); |
|
812 |
} |
|
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
813 |
void PeepReplace::next_instruction(const char* &inst){ |
1 | 814 |
inst = _instruction.iter(); |
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
815 |
int inst_num = (int) (intptr_t) _operand_inst_num.iter(); |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
816 |
const char* inst_operand = _operand_op_name.iter(); |
1 | 817 |
} |
2129
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
818 |
void PeepReplace::next_operand(int &inst_num, const char* &inst_operand) { |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
819 |
const char* inst = _instruction.iter(); |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
820 |
inst_num = (int) (intptr_t) _operand_inst_num.iter(); |
e810a33b5c67
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
1
diff
changeset
|
821 |
inst_operand = _operand_op_name.iter(); |
1 | 822 |
} |
823 |
||
824 |
||
825 |
||
826 |
void PeepReplace::dump() { |
|
827 |
output(stderr); |
|
828 |
} |
|
829 |
||
830 |
void PeepReplace::output(FILE *fp) { // Write info to output files |
|
831 |
fprintf(fp,"PeepReplace:\n"); |
|
832 |
} |