CACAO
Grammar.inc
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/GrammarBase.brg - Generated Basic Grammar
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 /*
26 WARNING: THIS FILE IS AUTO-GENERATED! DO NOT ALTER!
27 Instead have a look at the generator (src/vm/jit/compiler2/instruction_gen.py and contrib/patternmatching/)
28 and the input file (instruction_table.csv).
29 */
30 
31 /* src/vm/jit/Grammar.inc - Generated Pattern Matching include file
32 
33 Copyright (C) 1996-2013
34 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
35 
36 This file is part of CACAO.
37 This program is free software; you can redistribute it and/or
38 modify it under the terms of the GNU General Public License as
39 published by the Free Software Foundation; either version 2, or (at
40 your option) any later version.
41 
42 This program is distributed in the hope that it will be useful, but
43 WITHOUT ANY WARRANTY; without even the implied warranty of
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45 General Public License for more details.
46 You should have received a copy of the GNU General Public License
47 along with this program; if not, write to the Free Software
48 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
49 02110-1301, USA.
50 
51 */
52 
53 /* THIS FILE IS GENERATED!!! DO NOT EDIT!!!
54  See contrib/patternmatching for further information
55 */
56 
57 #ifdef GLOBALDEFS
58 #undef GLOBALDEFS
59 
60 enum RuleId {
61 /* 0 */ NoRule,
62 /* 1 */ NOPInstID, /* stm: NOPInstID */
63 /* 2 */ POPInstID, /* stm: POPInstID */
64 /* 3 */ CHECKNULLInstID, /* stm: CHECKNULLInstID */
65 /* 4 */ ARRAYLENGTHInstID, /* stm: ARRAYLENGTHInstID(stm) */
66 /* 5 */ ARRAYBOUNDSCHECKInstID, /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
67 /* 6 */ NEGInstID, /* stm: NEGInstID(stm) */
68 /* 7 */ CASTInstID, /* stm: CASTInstID(stm) */
69 /* 8 */ ADDInstID, /* stm: ADDInstID(stm,stm) */
70 /* 9 */ SUBInstID, /* stm: SUBInstID(stm,stm) */
71 /* 10 */ MULInstID, /* stm: MULInstID(stm,stm) */
72 /* 11 */ DIVInstID, /* stm: DIVInstID(stm,stm) */
73 /* 12 */ REMInstID, /* stm: REMInstID(stm,stm) */
74 /* 13 */ SHLInstID, /* stm: SHLInstID */
75 /* 14 */ USHRInstID, /* stm: USHRInstID */
76 /* 15 */ ANDInstID, /* stm: ANDInstID(stm,stm) */
77 /* 16 */ ORInstID, /* stm: ORInstID(stm,stm) */
78 /* 17 */ XORInstID, /* stm: XORInstID(stm,stm) */
79 /* 18 */ CMPInstID, /* stm: CMPInstID(stm,stm) */
80 /* 19 */ CONSTInstID, /* stm: CONSTInstID */
81 /* 20 */ AREFInstID, /* stm: AREFInstID(stm,stm) */
82 /* 21 */ ASTOREInstID, /* stm: ASTOREInstID(stm,stm) */
83 /* 22 */ ALOADInstID, /* stm: ALOADInstID(stm) */
84 /* 23 */ LOADInstID, /* stm: LOADInstID */
85 /* 24 */ IFInstID, /* stm: IFInstID(stm,stm) */
86 /* 25 */ TABLESWITCHInstID, /* stm: TABLESWITCHInstID(stm) */
87 /* 26 */ LOOKUPSWITCHInstID, /* stm: LOOKUPSWITCHInstID(stm) */
88 /* 27 */ RETURNInstID, /* stm: RETURNInstID(stm) */
89 /* 28 */ NoInstID, /* stm: NoInstID */
90 /* 29 */ AddImmImm, /* stm: ADDInstID(CONSTInstID,CONSTInstID) */
91 /* 30 */ AddRegImm, /* stm: ADDInstID(stm,CONSTInstID) */
92 /* 31 */ SubRegImm, /* stm: SUBInstID(stm,CONSTInstID) */
93 /* 32 */ MulRegImm, /* stm: MULInstID(stm,CONSTInstID) */
94 /* 33 */ BaseIndexDisplacement, /* stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID) */
95 /* 34 */ BaseIndexDisplacement2, /* stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID)) */
96 /* 35 */ BaseIndexMultiplier, /* stm: ADDInstID(stm,MULInstID(stm,CONSTInstID)) */
97 /* 36 */ BaseIndexMultiplier2, /* stm: ADDInstID(MULInstID(stm,CONSTInstID),stm) */
98 /* 37 */ BaseIndexMultiplierDisplacement, /* stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID) */
99 /* 38 */ BaseIndexMultiplierDisplacement2, /* stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID)) */
100 /* 39 */ ARef, /* stm: AREFInstID(stm,stm) */
101 /* 40 */ ALoad, /* stm: ALOADInstID(AREFInstID(stm,stm)) */
102 /* 41 */ AStore, /* stm: ASTOREInstID(AREFInstID(stm,stm),stm) */
103 /* 42 */ AStoreImm, /* stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID) */
104 /* 0 */DUMMYREMOVE
105 };
106 #endif
107 
108 #ifdef GENDEFS
109 #undef GENDEFS
110 
111 #define burm_stm_NT 1
112 
113 struct burm_state {
114  burm_state(NODEPTR_TYPE root) : root(root) {
115  for (int i=1; i <= 1; ++i) cost[i] = 0x7fff;
116  };
117 
118  short cost[2];
119  struct {
120  unsigned int burm_stm:6;
121  } rule;
122  bool isLeaf;
124 };
125 
126 
127 #endif
128 
129 #ifdef GENSTATIC
130 #undef GENSTATIC
131 
132 static short burm_nts_0[] = { 0 };
133 static short burm_nts_1[] = { burm_stm_NT, 0 };
134 static short burm_nts_2[] = { burm_stm_NT, burm_stm_NT, 0 };
135 static short burm_nts_3[] = { burm_stm_NT, burm_stm_NT, burm_stm_NT, 0 };
136 
137 static short *burm_nts[] = {
138  0, /* 0 */
139  burm_nts_0, /* 1 */
140  burm_nts_0, /* 2 */
141  burm_nts_0, /* 3 */
142  burm_nts_1, /* 4 */
143  burm_nts_2, /* 5 */
144  burm_nts_1, /* 6 */
145  burm_nts_1, /* 7 */
146  burm_nts_2, /* 8 */
147  burm_nts_2, /* 9 */
148  burm_nts_2, /* 10 */
149  burm_nts_2, /* 11 */
150  burm_nts_2, /* 12 */
151  burm_nts_0, /* 13 */
152  burm_nts_0, /* 14 */
153  burm_nts_2, /* 15 */
154  burm_nts_2, /* 16 */
155  burm_nts_2, /* 17 */
156  burm_nts_2, /* 18 */
157  burm_nts_0, /* 19 */
158  burm_nts_2, /* 20 */
159  burm_nts_2, /* 21 */
160  burm_nts_1, /* 22 */
161  burm_nts_0, /* 23 */
162  burm_nts_2, /* 24 */
163  burm_nts_1, /* 25 */
164  burm_nts_1, /* 26 */
165  burm_nts_1, /* 27 */
166  burm_nts_0, /* 28 */
167  burm_nts_0, /* 29 */
168  burm_nts_1, /* 30 */
169  burm_nts_1, /* 31 */
170  burm_nts_1, /* 32 */
171  burm_nts_2, /* 33 */
172  burm_nts_2, /* 34 */
173  burm_nts_2, /* 35 */
174  burm_nts_2, /* 36 */
175  burm_nts_2, /* 37 */
176  burm_nts_2, /* 38 */
177  burm_nts_2, /* 39 */
178  burm_nts_2, /* 40 */
179  burm_nts_3, /* 41 */
180  burm_nts_2, /* 42 */
181 };
182 
183 static const char *burm_templates[] = {
184 /* 0 */ 0,
185 /* 1 */ "NOPInstID", /* stm: NOPInstID */
186 /* 2 */ "POPInstID", /* stm: POPInstID */
187 /* 3 */ "CHECKNULLInstID", /* stm: CHECKNULLInstID */
188 /* 4 */ "ARRAYLENGTHInstID", /* stm: ARRAYLENGTHInstID(stm) */
189 /* 5 */ "ARRAYBOUNDSCHECKInstID", /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
190 /* 6 */ "NEGInstID", /* stm: NEGInstID(stm) */
191 /* 7 */ "CASTInstID", /* stm: CASTInstID(stm) */
192 /* 8 */ "ADDInstID", /* stm: ADDInstID(stm,stm) */
193 /* 9 */ "SUBInstID", /* stm: SUBInstID(stm,stm) */
194 /* 10 */ "MULInstID", /* stm: MULInstID(stm,stm) */
195 /* 11 */ "DIVInstID", /* stm: DIVInstID(stm,stm) */
196 /* 12 */ "REMInstID", /* stm: REMInstID(stm,stm) */
197 /* 13 */ "SHLInstID", /* stm: SHLInstID */
198 /* 14 */ "USHRInstID", /* stm: USHRInstID */
199 /* 15 */ "ANDInstID", /* stm: ANDInstID(stm,stm) */
200 /* 16 */ "ORInstID", /* stm: ORInstID(stm,stm) */
201 /* 17 */ "XORInstID", /* stm: XORInstID(stm,stm) */
202 /* 18 */ "CMPInstID", /* stm: CMPInstID(stm,stm) */
203 /* 19 */ "CONSTInstID", /* stm: CONSTInstID */
204 /* 20 */ "AREFInstID", /* stm: AREFInstID(stm,stm) */
205 /* 21 */ "ASTOREInstID", /* stm: ASTOREInstID(stm,stm) */
206 /* 22 */ "ALOADInstID", /* stm: ALOADInstID(stm) */
207 /* 23 */ "LOADInstID", /* stm: LOADInstID */
208 /* 24 */ "IFInstID", /* stm: IFInstID(stm,stm) */
209 /* 25 */ "TABLESWITCHInstID", /* stm: TABLESWITCHInstID(stm) */
210 /* 26 */ "LOOKUPSWITCHInstID", /* stm: LOOKUPSWITCHInstID(stm) */
211 /* 27 */ "RETURNInstID", /* stm: RETURNInstID(stm) */
212 /* 28 */ "NoInstID", /* stm: NoInstID */
213 /* 29 */ "AddImmImm", /* stm: ADDInstID(CONSTInstID,CONSTInstID) */
214 /* 30 */ "AddRegImm", /* stm: ADDInstID(stm,CONSTInstID) */
215 /* 31 */ "SubRegImm", /* stm: SUBInstID(stm,CONSTInstID) */
216 /* 32 */ "MulRegImm", /* stm: MULInstID(stm,CONSTInstID) */
217 /* 33 */ "BaseIndexDisplacement", /* stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID) */
218 /* 34 */ "BaseIndexDisplacement2", /* stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID)) */
219 /* 35 */ "BaseIndexMultiplier", /* stm: ADDInstID(stm,MULInstID(stm,CONSTInstID)) */
220 /* 36 */ "BaseIndexMultiplier2", /* stm: ADDInstID(MULInstID(stm,CONSTInstID),stm) */
221 /* 37 */ "BaseIndexMultiplierDisplacement", /* stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID) */
222 /* 38 */ "BaseIndexMultiplierDisplacement2", /* stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID)) */
223 /* 39 */ "ARef", /* stm: AREFInstID(stm,stm) */
224 /* 40 */ "ALoad", /* stm: ALOADInstID(AREFInstID(stm,stm)) */
225 /* 41 */ "AStore", /* stm: ASTOREInstID(AREFInstID(stm,stm),stm) */
226 /* 42 */ "AStoreImm", /* stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID) */
227 };
228 
229 static char burm_isinstruction[] = {
230 /* 0 */ 0,
231 /* 1 */ 1, /* NOPInstID */
232 /* 2 */ 1, /* POPInstID */
233 /* 3 */ 1, /* CHECKNULLInstID */
234 /* 4 */ 1, /* ARRAYLENGTHInstID */
235 /* 5 */ 1, /* ARRAYBOUNDSCHECKInstID */
236 /* 6 */ 1, /* NEGInstID */
237 /* 7 */ 1, /* CASTInstID */
238 /* 8 */ 1, /* ADDInstID */
239 /* 9 */ 1, /* SUBInstID */
240 /* 10 */ 1, /* MULInstID */
241 /* 11 */ 1, /* DIVInstID */
242 /* 12 */ 1, /* REMInstID */
243 /* 13 */ 1, /* SHLInstID */
244 /* 14 */ 1, /* USHRInstID */
245 /* 15 */ 1, /* ANDInstID */
246 /* 16 */ 1, /* ORInstID */
247 /* 17 */ 1, /* XORInstID */
248 /* 18 */ 1, /* CMPInstID */
249 /* 19 */ 1, /* CONSTInstID */
250 /* 20 */ 1, /* AREFInstID */
251 /* 21 */ 1, /* ASTOREInstID */
252 /* 22 */ 1, /* ALOADInstID */
253 /* 23 */ 1, /* LOADInstID */
254 /* 24 */ 1, /* IFInstID */
255 /* 25 */ 1, /* TABLESWITCHInstID */
256 /* 26 */ 1, /* LOOKUPSWITCHInstID */
257 /* 27 */ 1, /* RETURNInstID */
258 /* 28 */ 1, /* NoInstID */
259 /* 29 */ 0, /* AddImmImm */
260 /* 30 */ 0, /* AddRegImm */
261 /* 31 */ 0, /* SubRegImm */
262 /* 32 */ 0, /* MulRegImm */
263 /* 33 */ 0, /* BaseIndexDisplacement */
264 /* 34 */ 0, /* BaseIndexDisplacement2 */
265 /* 35 */ 0, /* BaseIndexMultiplier */
266 /* 36 */ 0, /* BaseIndexMultiplier2 */
267 /* 37 */ 0, /* BaseIndexMultiplierDisplacement */
268 /* 38 */ 0, /* BaseIndexMultiplierDisplacement2 */
269 /* 39 */ 0, /* ARef */
270 /* 40 */ 0, /* ALoad */
271 /* 41 */ 0, /* AStore */
272 /* 42 */ 0, /* AStoreImm */
273 };
274 
275 static const char *burm_string[] = {
276 /* 0 */ 0,
277 /* 1 */ "stm: NOPInstID",
278 /* 2 */ "stm: POPInstID",
279 /* 3 */ "stm: CHECKNULLInstID",
280 /* 4 */ "stm: ARRAYLENGTHInstID(stm)",
281 /* 5 */ "stm: ARRAYBOUNDSCHECKInstID(stm,stm)",
282 /* 6 */ "stm: NEGInstID(stm)",
283 /* 7 */ "stm: CASTInstID(stm)",
284 /* 8 */ "stm: ADDInstID(stm,stm)",
285 /* 9 */ "stm: SUBInstID(stm,stm)",
286 /* 10 */ "stm: MULInstID(stm,stm)",
287 /* 11 */ "stm: DIVInstID(stm,stm)",
288 /* 12 */ "stm: REMInstID(stm,stm)",
289 /* 13 */ "stm: SHLInstID",
290 /* 14 */ "stm: USHRInstID",
291 /* 15 */ "stm: ANDInstID(stm,stm)",
292 /* 16 */ "stm: ORInstID(stm,stm)",
293 /* 17 */ "stm: XORInstID(stm,stm)",
294 /* 18 */ "stm: CMPInstID(stm,stm)",
295 /* 19 */ "stm: CONSTInstID",
296 /* 20 */ "stm: AREFInstID(stm,stm)",
297 /* 21 */ "stm: ASTOREInstID(stm,stm)",
298 /* 22 */ "stm: ALOADInstID(stm)",
299 /* 23 */ "stm: LOADInstID",
300 /* 24 */ "stm: IFInstID(stm,stm)",
301 /* 25 */ "stm: TABLESWITCHInstID(stm)",
302 /* 26 */ "stm: LOOKUPSWITCHInstID(stm)",
303 /* 27 */ "stm: RETURNInstID(stm)",
304 /* 28 */ "stm: NoInstID",
305 /* 29 */ "stm: ADDInstID(CONSTInstID,CONSTInstID)",
306 /* 30 */ "stm: ADDInstID(stm,CONSTInstID)",
307 /* 31 */ "stm: SUBInstID(stm,CONSTInstID)",
308 /* 32 */ "stm: MULInstID(stm,CONSTInstID)",
309 /* 33 */ "stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID)",
310 /* 34 */ "stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID))",
311 /* 35 */ "stm: ADDInstID(stm,MULInstID(stm,CONSTInstID))",
312 /* 36 */ "stm: ADDInstID(MULInstID(stm,CONSTInstID),stm)",
313 /* 37 */ "stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID)",
314 /* 38 */ "stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID))",
315 /* 39 */ "stm: AREFInstID(stm,stm)",
316 /* 40 */ "stm: ALOADInstID(AREFInstID(stm,stm))",
317 /* 41 */ "stm: ASTOREInstID(AREFInstID(stm,stm),stm)",
318 /* 42 */ "stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID)",
319 };
320 
321 static short burm_decode_stm[] = {
322  0,
323  1,
324  2,
325  3,
326  4,
327  5,
328  6,
329  7,
330  8,
331  9,
332  10,
333  11,
334  12,
335  13,
336  14,
337  15,
338  16,
339  17,
340  18,
341  19,
342  20,
343  21,
344  22,
345  23,
346  24,
347  25,
348  26,
349  27,
350  28,
351  29,
352  30,
353  31,
354  32,
355  33,
356  34,
357  35,
358  36,
359  37,
360  38,
361  39,
362  40,
363  41,
364  42,
365 };
366 
367 
368 #endif
369 
370 #ifdef GENMETHODDEFS
371 #undef GENMETHODDEFS
372 
373 int burm_rule(shared_ptr<STATE_TYPE> state, int goalnt);
374 void burm_label(NODEPTR_TYPE a, NODEPTR_TYPE root);
375 void burm_kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]);
376 
377 #endif
378 
379 #ifdef GENMETHODS
380 #undef GENMETHODS
381 
382 
383 namespace {
384 
385  /*
386 
387 
388  TODO
389 
390  displacement with SUBInst!!!
391  indexmultiplierdisplacement
392 
393 
394 
395  */
396 
397  bool isMultiplier(CONSTInst* c){
398  s8 val = c->get_value();
399  if ((val == 2) || (val == 4) || (val == 8)) return true;
400  return false;
401  }
402 
403  bool isConstEncodable(CONSTInst* c){
404  return fits_into<s4>(c->get_value());
405  }
406 
407  bool isDiscreteValue(Instruction* a){
408  return (a->get_type() == Type::ByteTypeID ||
409  a->get_type() == Type::IntTypeID ||
410  a->get_type() == Type::LongTypeID);
411  }
412 
413  int encodeDiscreteCost(Instruction* a, Value* c){
414  if (!isDiscreteValue(a))
415  return 0x7fff;
416  if (!isConstEncodable(c->to_Instruction()->to_CONSTInst()))
417  return 0x7fff;
418  return 1;
419  }
420 
421  /*
422  LEA Encodings
423  * CONSTInst is always assumed to be second parameter due to how SSA Graph is created
424  If it is also used as first parameter, handle all other permutations as well
425  * Permutations in nesting MULInst/stm within the add have to be handled,
426  hence the rules and methods with "...2"
427  */
428 
429  int calcBaseIndexDisplacementCost(Instruction* a){
430  /*
431  ADDInstID
432  ADDInstID
433  stm,
434  stm
435  CONSTInstID
436  */
437  if (isConstEncodable(a->get_operand(1)->to_Instruction()->to_CONSTInst()))
438  return 1;
439  return 0x7fff;
440  }
441 
442  int calcBaseIndexDisplacement2Cost(Instruction* a){
443  /*
444  ADDInstID
445  stm
446  ADDInstID
447  stm
448  CONSTInstID
449  */
450  if (isConstEncodable(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
451  return 1;
452  return 0x7fff;
453  }
454 
455  int calcBaseIndexMultiplierCost(Instruction* a){
456  /*
457  ADDInstID
458  stm,
459  MULInstID
460  stm,
461  CONSTInstID
462  */
463  if (isMultiplier(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
464  return 1;
465  return 0x7fff;
466  }
467 
468  int calcBaseIndexMultiplier2Cost(Instruction* a){
469  /*
470  ADDInstID
471  MULInstID
472  stm,
473  CONSTInstID
474  stm
475  */
476  if (isMultiplier(a->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
477  return 1;
478  return 0x7fff;
479  }
480 
481  int calcBaseIndexMultiplierDisplacementCost(Instruction* a){
482  /*
483  ADDInstID
484  ADDInstID
485  stm,
486  MULInstID
487  stm,
488  CONSTInstID
489  CONSTInstID
490  */
491 
492  if ((isConstEncodable(a->get_operand(1)->to_Instruction()->to_CONSTInst())) &&
493  (isMultiplier(a->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())))
494  return 1;
495  return 0x7fff;
496  }
497 
498  int calcBaseIndexMultiplierDisplacement2Cost(Instruction* a){
499  /*
500  ADDInstID
501  stm,
502  ADDInstID
503  MULInstID
504  stm,
505  CONSTInstID
506  CONSTInstID
507  */
508  if ((isConstEncodable(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())) &&
509  (isMultiplier(a->get_operand(1)->to_Instruction()->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())))
510  return 1;
511  return 0x7fff;
512  }
513 
514 }
515 
516 int Matcher::burm_rule(shared_ptr<STATE_TYPE> state, int goalnt) {
517  if (goalnt < 1 || goalnt > 1)
518  ABORT_MSG("burm_rule", "Bad goal nonterminal " << goalnt << nl);
519  if (!state)
520  return 0;
521  switch (goalnt) {
522  case burm_stm_NT: return burm_decode_stm[state->rule.burm_stm];
523  default:
524  ABORT_MSG("burm_rule", "Bad goal nonterminal " << goalnt << nl);
525  return 0;
526  }
527 }
528 
529 
530 void Matcher::burm_label(NODEPTR_TYPE a, NODEPTR_TYPE root) {
531  int c;
532  shared_ptr<STATE_TYPE> p;
533 
534  if (!a)
535  ABORT_MSG("burm_label", "Null tree");
536  STATE_LABEL(a) = p = shared_ptr<STATE_TYPE>(new STATE_TYPE(root));
537  switch (OP_LABEL(a)) {
538  case 3: /* NOPInstID */
539  /* stm: NOPInstID */
540  if (1 + 0 < p->cost[burm_stm_NT]) {
541  p->cost[burm_stm_NT] = 1 + 0;
542  p->rule.burm_stm = 1;
543  }
544  break;
545  case 4: /* POPInstID */
546  /* stm: POPInstID */
547  if (1 + 0 < p->cost[burm_stm_NT]) {
548  p->cost[burm_stm_NT] = 1 + 0;
549  p->rule.burm_stm = 2;
550  }
551  break;
552  case 5: /* CHECKNULLInstID */
553  /* stm: CHECKNULLInstID */
554  if (1 + 0 < p->cost[burm_stm_NT]) {
555  p->cost[burm_stm_NT] = 1 + 0;
556  p->rule.burm_stm = 3;
557  }
558  break;
559  case 6: /* ARRAYLENGTHInstID */
560  burm_label(LEFT_CHILD(a), root);
561  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
562  /* stm: ARRAYLENGTHInstID(stm) */
563  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
564  if (c + 0 < p->cost[burm_stm_NT]) {
565  p->cost[burm_stm_NT] = c + 0;
566  p->rule.burm_stm = 4;
567  }
568  break;
569  case 7: /* ARRAYBOUNDSCHECKInstID */
570  burm_label(LEFT_CHILD(a), root);
571  burm_label(RIGHT_CHILD(a), root);
572  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
573  /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
574  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
575  if (c + 0 < p->cost[burm_stm_NT]) {
576  p->cost[burm_stm_NT] = c + 0;
577  p->rule.burm_stm = 5;
578  }
579  break;
580  case 8: /* NEGInstID */
581  burm_label(LEFT_CHILD(a), root);
582  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
583  /* stm: NEGInstID(stm) */
584  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
585  if (c + 0 < p->cost[burm_stm_NT]) {
586  p->cost[burm_stm_NT] = c + 0;
587  p->rule.burm_stm = 6;
588  }
589  break;
590  case 9: /* CASTInstID */
591  burm_label(LEFT_CHILD(a), root);
592  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
593  /* stm: CASTInstID(stm) */
594  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
595  if (c + 0 < p->cost[burm_stm_NT]) {
596  p->cost[burm_stm_NT] = c + 0;
597  p->rule.burm_stm = 7;
598  }
599  break;
600  case 10: /* ADDInstID */
601  burm_label(LEFT_CHILD(a), root);
602  burm_label(RIGHT_CHILD(a), root);
603  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
604  /* stm: ADDInstID(stm,stm) */
605  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
606  if (c + 0 < p->cost[burm_stm_NT]) {
607  p->cost[burm_stm_NT] = c + 0;
608  p->rule.burm_stm = 8;
609  }
610  if ( /* stm: ADDInstID(CONSTInstID,CONSTInstID) */
611  OP_LABEL(LEFT_CHILD(a)) == 21 && /* CONSTInstID */
612  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
613  ) {
614  c = 1;
615  if (c + 0 < p->cost[burm_stm_NT]) {
616  p->cost[burm_stm_NT] = c + 0;
617  p->rule.burm_stm = 29;
618  }
619  }
620  if ( /* stm: ADDInstID(stm,CONSTInstID) */
621  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
622  ) {
623  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (encodeDiscreteCost(a, a->get_operand(1)));
624  if (c + 0 < p->cost[burm_stm_NT]) {
625  p->cost[burm_stm_NT] = c + 0;
626  p->rule.burm_stm = 30;
627  }
628  }
629  if ( /* stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID) */
630  OP_LABEL(LEFT_CHILD(a)) == 10 && /* ADDInstID */
631  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
632  ) {
633  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (calcBaseIndexDisplacementCost(a));
634  if (c + 0 < p->cost[burm_stm_NT]) {
635  p->cost[burm_stm_NT] = c + 0;
636  p->rule.burm_stm = 33;
637  }
638  }
639  if ( /* stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID)) */
640  OP_LABEL(RIGHT_CHILD(a)) == 10 && /* ADDInstID */
641  OP_LABEL(RIGHT_CHILD(RIGHT_CHILD(a))) == 21 /* CONSTInstID */
642  ) {
643  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(LEFT_CHILD(RIGHT_CHILD(a))))->cost[burm_stm_NT] + (calcBaseIndexDisplacement2Cost(a));
644  if (c + 0 < p->cost[burm_stm_NT]) {
645  p->cost[burm_stm_NT] = c + 0;
646  p->rule.burm_stm = 34;
647  }
648  }
649  if ( /* stm: ADDInstID(stm,MULInstID(stm,CONSTInstID)) */
650  OP_LABEL(RIGHT_CHILD(a)) == 12 && /* MULInstID */
651  OP_LABEL(RIGHT_CHILD(RIGHT_CHILD(a))) == 21 /* CONSTInstID */
652  ) {
653  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(LEFT_CHILD(RIGHT_CHILD(a))))->cost[burm_stm_NT] + (calcBaseIndexMultiplierCost(a));
654  if (c + 0 < p->cost[burm_stm_NT]) {
655  p->cost[burm_stm_NT] = c + 0;
656  p->rule.burm_stm = 35;
657  }
658  }
659  if ( /* stm: ADDInstID(MULInstID(stm,CONSTInstID),stm) */
660  OP_LABEL(LEFT_CHILD(a)) == 12 && /* MULInstID */
661  OP_LABEL(RIGHT_CHILD(LEFT_CHILD(a))) == 21 /* CONSTInstID */
662  ) {
663  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + (calcBaseIndexMultiplier2Cost(a));
664  if (c + 0 < p->cost[burm_stm_NT]) {
665  p->cost[burm_stm_NT] = c + 0;
666  p->rule.burm_stm = 36;
667  }
668  }
669  if ( /* stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID) */
670  OP_LABEL(LEFT_CHILD(a)) == 10 && /* ADDInstID */
671  OP_LABEL(RIGHT_CHILD(LEFT_CHILD(a))) == 12 && /* MULInstID */
672  OP_LABEL(RIGHT_CHILD(RIGHT_CHILD(LEFT_CHILD(a)))) == 21 && /* CONSTInstID */
673  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
674  ) {
675  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(LEFT_CHILD(RIGHT_CHILD(LEFT_CHILD(a)))))->cost[burm_stm_NT] + (calcBaseIndexMultiplierDisplacementCost(a));
676  if (c + 0 < p->cost[burm_stm_NT]) {
677  p->cost[burm_stm_NT] = c + 0;
678  p->rule.burm_stm = 37;
679  }
680  }
681  if ( /* stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID)) */
682  OP_LABEL(RIGHT_CHILD(a)) == 10 && /* ADDInstID */
683  OP_LABEL(LEFT_CHILD(RIGHT_CHILD(a))) == 12 && /* MULInstID */
684  OP_LABEL(RIGHT_CHILD(LEFT_CHILD(RIGHT_CHILD(a)))) == 21 && /* CONSTInstID */
685  OP_LABEL(RIGHT_CHILD(RIGHT_CHILD(a))) == 21 /* CONSTInstID */
686  ) {
687  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(RIGHT_CHILD(a)))))->cost[burm_stm_NT] + (calcBaseIndexMultiplierDisplacement2Cost(a));
688  if (c + 0 < p->cost[burm_stm_NT]) {
689  p->cost[burm_stm_NT] = c + 0;
690  p->rule.burm_stm = 38;
691  }
692  }
693  break;
694  case 11: /* SUBInstID */
695  burm_label(LEFT_CHILD(a), root);
696  burm_label(RIGHT_CHILD(a), root);
697  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
698  /* stm: SUBInstID(stm,stm) */
699  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
700  if (c + 0 < p->cost[burm_stm_NT]) {
701  p->cost[burm_stm_NT] = c + 0;
702  p->rule.burm_stm = 9;
703  }
704  if ( /* stm: SUBInstID(stm,CONSTInstID) */
705  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
706  ) {
707  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (encodeDiscreteCost(a, a->get_operand(1)));
708  if (c + 0 < p->cost[burm_stm_NT]) {
709  p->cost[burm_stm_NT] = c + 0;
710  p->rule.burm_stm = 31;
711  }
712  }
713  break;
714  case 12: /* MULInstID */
715  burm_label(LEFT_CHILD(a), root);
716  burm_label(RIGHT_CHILD(a), root);
717  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
718  /* stm: MULInstID(stm,stm) */
719  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
720  if (c + 0 < p->cost[burm_stm_NT]) {
721  p->cost[burm_stm_NT] = c + 0;
722  p->rule.burm_stm = 10;
723  }
724  if ( /* stm: MULInstID(stm,CONSTInstID) */
725  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
726  ) {
727  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (encodeDiscreteCost(a, a->get_operand(1)));
728  if (c + 0 < p->cost[burm_stm_NT]) {
729  p->cost[burm_stm_NT] = c + 0;
730  p->rule.burm_stm = 32;
731  }
732  }
733  break;
734  case 13: /* DIVInstID */
735  burm_label(LEFT_CHILD(a), root);
736  burm_label(RIGHT_CHILD(a), root);
737  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
738  /* stm: DIVInstID(stm,stm) */
739  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
740  if (c + 0 < p->cost[burm_stm_NT]) {
741  p->cost[burm_stm_NT] = c + 0;
742  p->rule.burm_stm = 11;
743  }
744  break;
745  case 14: /* REMInstID */
746  burm_label(LEFT_CHILD(a), root);
747  burm_label(RIGHT_CHILD(a), root);
748  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
749  /* stm: REMInstID(stm,stm) */
750  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
751  if (c + 0 < p->cost[burm_stm_NT]) {
752  p->cost[burm_stm_NT] = c + 0;
753  p->rule.burm_stm = 12;
754  }
755  break;
756  case 15: /* SHLInstID */
757  /* stm: SHLInstID */
758  if (1 + 0 < p->cost[burm_stm_NT]) {
759  p->cost[burm_stm_NT] = 1 + 0;
760  p->rule.burm_stm = 13;
761  }
762  break;
763  case 16: /* USHRInstID */
764  /* stm: USHRInstID */
765  if (1 + 0 < p->cost[burm_stm_NT]) {
766  p->cost[burm_stm_NT] = 1 + 0;
767  p->rule.burm_stm = 14;
768  }
769  break;
770  case 17: /* ANDInstID */
771  burm_label(LEFT_CHILD(a), root);
772  burm_label(RIGHT_CHILD(a), root);
773  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
774  /* stm: ANDInstID(stm,stm) */
775  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
776  if (c + 0 < p->cost[burm_stm_NT]) {
777  p->cost[burm_stm_NT] = c + 0;
778  p->rule.burm_stm = 15;
779  }
780  break;
781  case 18: /* ORInstID */
782  burm_label(LEFT_CHILD(a), root);
783  burm_label(RIGHT_CHILD(a), root);
784  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
785  /* stm: ORInstID(stm,stm) */
786  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
787  if (c + 0 < p->cost[burm_stm_NT]) {
788  p->cost[burm_stm_NT] = c + 0;
789  p->rule.burm_stm = 16;
790  }
791  break;
792  case 19: /* XORInstID */
793  burm_label(LEFT_CHILD(a), root);
794  burm_label(RIGHT_CHILD(a), root);
795  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
796  /* stm: XORInstID(stm,stm) */
797  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
798  if (c + 0 < p->cost[burm_stm_NT]) {
799  p->cost[burm_stm_NT] = c + 0;
800  p->rule.burm_stm = 17;
801  }
802  break;
803  case 20: /* CMPInstID */
804  burm_label(LEFT_CHILD(a), root);
805  burm_label(RIGHT_CHILD(a), root);
806  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
807  /* stm: CMPInstID(stm,stm) */
808  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
809  if (c + 0 < p->cost[burm_stm_NT]) {
810  p->cost[burm_stm_NT] = c + 0;
811  p->rule.burm_stm = 18;
812  }
813  break;
814  case 21: /* CONSTInstID */
815  /* stm: CONSTInstID */
816  if (1 + 0 < p->cost[burm_stm_NT]) {
817  p->cost[burm_stm_NT] = 1 + 0;
818  p->rule.burm_stm = 19;
819  }
820  break;
821  case 27: /* AREFInstID */
822  burm_label(LEFT_CHILD(a), root);
823  burm_label(RIGHT_CHILD(a), root);
824  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
825  /* stm: AREFInstID(stm,stm) */
826  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
827  if (c + 0 < p->cost[burm_stm_NT]) {
828  p->cost[burm_stm_NT] = c + 0;
829  p->rule.burm_stm = 20;
830  }
831  /* stm: AREFInstID(stm,stm) */
832  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
833  if (c + 0 < p->cost[burm_stm_NT]) {
834  p->cost[burm_stm_NT] = c + 0;
835  p->rule.burm_stm = 39;
836  }
837  break;
838  case 28: /* ASTOREInstID */
839  burm_label(LEFT_CHILD(a), root);
840  burm_label(RIGHT_CHILD(a), root);
841  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
842  /* stm: ASTOREInstID(stm,stm) */
843  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
844  if (c + 0 < p->cost[burm_stm_NT]) {
845  p->cost[burm_stm_NT] = c + 0;
846  p->rule.burm_stm = 21;
847  }
848  if ( /* stm: ASTOREInstID(AREFInstID(stm,stm),stm) */
849  OP_LABEL(LEFT_CHILD(a)) == 27 /* AREFInstID */
850  ) {
851  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
852  if (c + 0 < p->cost[burm_stm_NT]) {
853  p->cost[burm_stm_NT] = c + 0;
854  p->rule.burm_stm = 41;
855  }
856  }
857  if ( /* stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID) */
858  OP_LABEL(LEFT_CHILD(a)) == 27 && /* AREFInstID */
859  OP_LABEL(RIGHT_CHILD(a)) == 21 /* CONSTInstID */
860  ) {
861  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + 1;
862  if (c + 0 < p->cost[burm_stm_NT]) {
863  p->cost[burm_stm_NT] = c + 0;
864  p->rule.burm_stm = 42;
865  }
866  }
867  break;
868  case 29: /* ALOADInstID */
869  burm_label(LEFT_CHILD(a), root);
870  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
871  /* stm: ALOADInstID(stm) */
872  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
873  if (c + 0 < p->cost[burm_stm_NT]) {
874  p->cost[burm_stm_NT] = c + 0;
875  p->rule.burm_stm = 22;
876  }
877  if ( /* stm: ALOADInstID(AREFInstID(stm,stm)) */
878  OP_LABEL(LEFT_CHILD(a)) == 27 /* AREFInstID */
879  ) {
880  c = (STATE_LABEL(LEFT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(LEFT_CHILD(a))))->cost[burm_stm_NT] + 1;
881  if (c + 0 < p->cost[burm_stm_NT]) {
882  p->cost[burm_stm_NT] = c + 0;
883  p->rule.burm_stm = 40;
884  }
885  }
886  break;
887  case 31: /* LOADInstID */
888  /* stm: LOADInstID */
889  if (1 + 0 < p->cost[burm_stm_NT]) {
890  p->cost[burm_stm_NT] = 1 + 0;
891  p->rule.burm_stm = 23;
892  }
893  break;
894  case 46: /* IFInstID */
895  burm_label(LEFT_CHILD(a), root);
896  burm_label(RIGHT_CHILD(a), root);
897  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
898  /* stm: IFInstID(stm,stm) */
899  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
900  if (c + 0 < p->cost[burm_stm_NT]) {
901  p->cost[burm_stm_NT] = c + 0;
902  p->rule.burm_stm = 24;
903  }
904  break;
905  case 48: /* TABLESWITCHInstID */
906  burm_label(LEFT_CHILD(a), root);
907  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
908  /* stm: TABLESWITCHInstID(stm) */
909  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
910  if (c + 0 < p->cost[burm_stm_NT]) {
911  p->cost[burm_stm_NT] = c + 0;
912  p->rule.burm_stm = 25;
913  }
914  break;
915  case 49: /* LOOKUPSWITCHInstID */
916  burm_label(LEFT_CHILD(a), root);
917  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
918  /* stm: LOOKUPSWITCHInstID(stm) */
919  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
920  if (c + 0 < p->cost[burm_stm_NT]) {
921  p->cost[burm_stm_NT] = c + 0;
922  p->rule.burm_stm = 26;
923  }
924  break;
925  case 50: /* RETURNInstID */
926  burm_label(LEFT_CHILD(a), root);
927  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
928  /* stm: RETURNInstID(stm) */
929  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
930  if (c + 0 < p->cost[burm_stm_NT]) {
931  p->cost[burm_stm_NT] = c + 0;
932  p->rule.burm_stm = 27;
933  }
934  break;
935  case 59: /* NoInstID */
936  /* stm: NoInstID */
937  if (1 + 0 < p->cost[burm_stm_NT]) {
938  p->cost[burm_stm_NT] = 1 + 0;
939  p->rule.burm_stm = 28;
940  }
941  break;
942  default:
943  ABORT_MSG("burm_label", "Bad terminal " << OP_LABEL(a) << nl);
944  }
945 }
946 
947 void Matcher::burm_kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]) {
948  if (!p)
949  ABORT_MSG("burm_kids", "Null tree");
950  if (!kids)
951  ABORT_MSG("burm_kids", "Null kids");
952  switch (eruleno) {
953  case 29: /* stm: ADDInstID(CONSTInstID,CONSTInstID) */
954  case 28: /* stm: NoInstID */
955  case 23: /* stm: LOADInstID */
956  case 19: /* stm: CONSTInstID */
957  case 14: /* stm: USHRInstID */
958  case 13: /* stm: SHLInstID */
959  case 3: /* stm: CHECKNULLInstID */
960  case 2: /* stm: POPInstID */
961  case 1: /* stm: NOPInstID */
962  break;
963  case 32: /* stm: MULInstID(stm,CONSTInstID) */
964  case 31: /* stm: SUBInstID(stm,CONSTInstID) */
965  case 30: /* stm: ADDInstID(stm,CONSTInstID) */
966  case 27: /* stm: RETURNInstID(stm) */
967  case 26: /* stm: LOOKUPSWITCHInstID(stm) */
968  case 25: /* stm: TABLESWITCHInstID(stm) */
969  case 22: /* stm: ALOADInstID(stm) */
970  case 7: /* stm: CASTInstID(stm) */
971  case 6: /* stm: NEGInstID(stm) */
972  case 4: /* stm: ARRAYLENGTHInstID(stm) */
973  kids[0] = LEFT_CHILD(p);
974  break;
975  case 39: /* stm: AREFInstID(stm,stm) */
976  case 24: /* stm: IFInstID(stm,stm) */
977  case 21: /* stm: ASTOREInstID(stm,stm) */
978  case 20: /* stm: AREFInstID(stm,stm) */
979  case 18: /* stm: CMPInstID(stm,stm) */
980  case 17: /* stm: XORInstID(stm,stm) */
981  case 16: /* stm: ORInstID(stm,stm) */
982  case 15: /* stm: ANDInstID(stm,stm) */
983  case 12: /* stm: REMInstID(stm,stm) */
984  case 11: /* stm: DIVInstID(stm,stm) */
985  case 10: /* stm: MULInstID(stm,stm) */
986  case 9: /* stm: SUBInstID(stm,stm) */
987  case 8: /* stm: ADDInstID(stm,stm) */
988  case 5: /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
989  kids[0] = LEFT_CHILD(p);
990  kids[1] = RIGHT_CHILD(p);
991  break;
992  case 42: /* stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID) */
993  case 40: /* stm: ALOADInstID(AREFInstID(stm,stm)) */
994  case 33: /* stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID) */
995  kids[0] = LEFT_CHILD(LEFT_CHILD(p));
996  kids[1] = RIGHT_CHILD(LEFT_CHILD(p));
997  break;
998  case 35: /* stm: ADDInstID(stm,MULInstID(stm,CONSTInstID)) */
999  case 34: /* stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID)) */
1000  kids[0] = LEFT_CHILD(p);
1001  kids[1] = LEFT_CHILD(RIGHT_CHILD(p));
1002  break;
1003  case 36: /* stm: ADDInstID(MULInstID(stm,CONSTInstID),stm) */
1004  kids[0] = LEFT_CHILD(LEFT_CHILD(p));
1005  kids[1] = RIGHT_CHILD(p);
1006  break;
1007  case 37: /* stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID) */
1008  kids[0] = LEFT_CHILD(LEFT_CHILD(p));
1009  kids[1] = LEFT_CHILD(RIGHT_CHILD(LEFT_CHILD(p)));
1010  break;
1011  case 38: /* stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID)) */
1012  kids[0] = LEFT_CHILD(p);
1013  kids[1] = LEFT_CHILD(LEFT_CHILD(RIGHT_CHILD(p)));
1014  break;
1015  case 41: /* stm: ASTOREInstID(AREFInstID(stm,stm),stm) */
1016  kids[0] = LEFT_CHILD(LEFT_CHILD(p));
1017  kids[1] = RIGHT_CHILD(LEFT_CHILD(p));
1018  kids[2] = RIGHT_CHILD(p);
1019  break;
1020  default:
1021  ABORT_MSG("burm_kids", "Bad rule number " << eruleno << nl);
1022  }
1023 }
1024 
1025 
1026 #endif
1027 
1028 /*
1029 * These are local overrides for various environment variables in Emacs.
1030 * Please do not remove this and leave it at the end of the file, where
1031 * Emacs will automagically detect them.
1032 * ---------------------------------------------------------------------
1033 * Local variables:
1034 * mode: c++
1035 * indent-tabs-mode: t
1036 * c-basic-offset: 4
1037 * tab-width: 4
1038 * End:
1039 * vim:noexpandtab:sw=4:ts=4:
1040 */
#define STATE_LABEL(p)
Definition: Matcher.cpp:35
#define RIGHT_CHILD(p)
Definition: Matcher.cpp:34
Instruction * NODEPTR_TYPE
Definition: Matcher.hpp:48
int64_t s8
Definition: types.hpp:48
OptionPrefix & root()
Definition: Option.cpp:34
#define LEFT_CHILD(p)
Definition: Matcher.cpp:33
MIIterator i
#define OP_LABEL(p)
Definition: Matcher.cpp:32
Represents the result of the addition of a certain IR-variable with a certain constant.
Definition: Value.hpp:36
#define ABORT_MSG(EXPR_SHORT, EXPR_LONG)
Definition: logging.hpp:133
struct burm_state STATE_TYPE
Definition: Matcher.hpp:49
Nl nl
Definition: OStream.cpp:56