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 */ CHECKNULLInstID, /* stm: CHECKNULLInstID */
63 /* 2 */ ARRAYLENGTHInstID, /* stm: ARRAYLENGTHInstID(stm) */
64 /* 3 */ ARRAYBOUNDSCHECKInstID, /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
65 /* 4 */ NEGInstID, /* stm: NEGInstID(stm) */
66 /* 5 */ CASTInstID, /* stm: CASTInstID(stm) */
67 /* 6 */ ADDInstID, /* stm: ADDInstID(stm,stm) */
68 /* 7 */ SUBInstID, /* stm: SUBInstID(stm,stm) */
69 /* 8 */ MULInstID, /* stm: MULInstID(stm,stm) */
70 /* 9 */ DIVInstID, /* stm: DIVInstID(stm,stm) */
71 /* 10 */ REMInstID, /* stm: REMInstID(stm,stm) */
72 /* 11 */ SHLInstID, /* stm: SHLInstID */
73 /* 12 */ USHRInstID, /* stm: USHRInstID */
74 /* 13 */ ANDInstID, /* stm: ANDInstID(stm,stm) */
75 /* 14 */ ORInstID, /* stm: ORInstID(stm,stm) */
76 /* 15 */ XORInstID, /* stm: XORInstID(stm,stm) */
77 /* 16 */ CMPInstID, /* stm: CMPInstID(stm,stm) */
78 /* 17 */ CONSTInstID, /* stm: CONSTInstID */
79 /* 18 */ AREFInstID, /* stm: AREFInstID(stm,stm) */
80 /* 19 */ ASTOREInstID, /* stm: ASTOREInstID(stm,stm) */
81 /* 20 */ ALOADInstID, /* stm: ALOADInstID(stm) */
82 /* 21 */ LOADInstID, /* stm: LOADInstID */
83 /* 22 */ IFInstID, /* stm: IFInstID(stm,stm) */
84 /* 23 */ TABLESWITCHInstID, /* stm: TABLESWITCHInstID(stm) */
85 /* 24 */ LOOKUPSWITCHInstID, /* stm: LOOKUPSWITCHInstID(stm) */
86 /* 25 */ RETURNInstID, /* stm: RETURNInstID(stm) */
87 /* 26 */ NoInstID, /* stm: NoInstID */
88 /* 0 */DUMMYREMOVE
89 };
90 #endif
91 
92 #ifdef GENDEFS
93 #undef GENDEFS
94 
95 #define burm_stm_NT 1
96 
97 struct burm_state {
98  burm_state(NODEPTR_TYPE root) : root(root) {
99  for (int i=1; i <= 1; ++i) cost[i] = 0x7fff;
100  };
101 
102  short cost[2];
103  struct {
104  unsigned int burm_stm:5;
105  } rule;
106  bool isLeaf;
108 };
109 
110 
111 #endif
112 
113 #ifdef GENSTATIC
114 #undef GENSTATIC
115 
116 static short burm_nts_0[] = { 0 };
117 static short burm_nts_1[] = { burm_stm_NT, 0 };
118 static short burm_nts_2[] = { burm_stm_NT, burm_stm_NT, 0 };
119 
120 static short *burm_nts[] = {
121  0, /* 0 */
122  burm_nts_0, /* 1 */
123  burm_nts_1, /* 2 */
124  burm_nts_2, /* 3 */
125  burm_nts_1, /* 4 */
126  burm_nts_1, /* 5 */
127  burm_nts_2, /* 6 */
128  burm_nts_2, /* 7 */
129  burm_nts_2, /* 8 */
130  burm_nts_2, /* 9 */
131  burm_nts_2, /* 10 */
132  burm_nts_0, /* 11 */
133  burm_nts_0, /* 12 */
134  burm_nts_2, /* 13 */
135  burm_nts_2, /* 14 */
136  burm_nts_2, /* 15 */
137  burm_nts_2, /* 16 */
138  burm_nts_0, /* 17 */
139  burm_nts_2, /* 18 */
140  burm_nts_2, /* 19 */
141  burm_nts_1, /* 20 */
142  burm_nts_0, /* 21 */
143  burm_nts_2, /* 22 */
144  burm_nts_1, /* 23 */
145  burm_nts_1, /* 24 */
146  burm_nts_1, /* 25 */
147  burm_nts_0, /* 26 */
148 };
149 
150 static const char *burm_templates[] = {
151 /* 0 */ 0,
152 /* 1 */ "CHECKNULLInstID", /* stm: CHECKNULLInstID */
153 /* 2 */ "ARRAYLENGTHInstID", /* stm: ARRAYLENGTHInstID(stm) */
154 /* 3 */ "ARRAYBOUNDSCHECKInstID", /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
155 /* 4 */ "NEGInstID", /* stm: NEGInstID(stm) */
156 /* 5 */ "CASTInstID", /* stm: CASTInstID(stm) */
157 /* 6 */ "ADDInstID", /* stm: ADDInstID(stm,stm) */
158 /* 7 */ "SUBInstID", /* stm: SUBInstID(stm,stm) */
159 /* 8 */ "MULInstID", /* stm: MULInstID(stm,stm) */
160 /* 9 */ "DIVInstID", /* stm: DIVInstID(stm,stm) */
161 /* 10 */ "REMInstID", /* stm: REMInstID(stm,stm) */
162 /* 11 */ "SHLInstID", /* stm: SHLInstID */
163 /* 12 */ "USHRInstID", /* stm: USHRInstID */
164 /* 13 */ "ANDInstID", /* stm: ANDInstID(stm,stm) */
165 /* 14 */ "ORInstID", /* stm: ORInstID(stm,stm) */
166 /* 15 */ "XORInstID", /* stm: XORInstID(stm,stm) */
167 /* 16 */ "CMPInstID", /* stm: CMPInstID(stm,stm) */
168 /* 17 */ "CONSTInstID", /* stm: CONSTInstID */
169 /* 18 */ "AREFInstID", /* stm: AREFInstID(stm,stm) */
170 /* 19 */ "ASTOREInstID", /* stm: ASTOREInstID(stm,stm) */
171 /* 20 */ "ALOADInstID", /* stm: ALOADInstID(stm) */
172 /* 21 */ "LOADInstID", /* stm: LOADInstID */
173 /* 22 */ "IFInstID", /* stm: IFInstID(stm,stm) */
174 /* 23 */ "TABLESWITCHInstID", /* stm: TABLESWITCHInstID(stm) */
175 /* 24 */ "LOOKUPSWITCHInstID", /* stm: LOOKUPSWITCHInstID(stm) */
176 /* 25 */ "RETURNInstID", /* stm: RETURNInstID(stm) */
177 /* 26 */ "NoInstID", /* stm: NoInstID */
178 };
179 
180 static char burm_isinstruction[] = {
181 /* 0 */ 0,
182 /* 1 */ 1, /* CHECKNULLInstID */
183 /* 2 */ 1, /* ARRAYLENGTHInstID */
184 /* 3 */ 1, /* ARRAYBOUNDSCHECKInstID */
185 /* 4 */ 1, /* NEGInstID */
186 /* 5 */ 1, /* CASTInstID */
187 /* 6 */ 1, /* ADDInstID */
188 /* 7 */ 1, /* SUBInstID */
189 /* 8 */ 1, /* MULInstID */
190 /* 9 */ 1, /* DIVInstID */
191 /* 10 */ 1, /* REMInstID */
192 /* 11 */ 1, /* SHLInstID */
193 /* 12 */ 1, /* USHRInstID */
194 /* 13 */ 1, /* ANDInstID */
195 /* 14 */ 1, /* ORInstID */
196 /* 15 */ 1, /* XORInstID */
197 /* 16 */ 1, /* CMPInstID */
198 /* 17 */ 1, /* CONSTInstID */
199 /* 18 */ 1, /* AREFInstID */
200 /* 19 */ 1, /* ASTOREInstID */
201 /* 20 */ 1, /* ALOADInstID */
202 /* 21 */ 1, /* LOADInstID */
203 /* 22 */ 1, /* IFInstID */
204 /* 23 */ 1, /* TABLESWITCHInstID */
205 /* 24 */ 1, /* LOOKUPSWITCHInstID */
206 /* 25 */ 1, /* RETURNInstID */
207 /* 26 */ 1, /* NoInstID */
208 };
209 
210 static const char *burm_string[] = {
211 /* 0 */ 0,
212 /* 1 */ "stm: CHECKNULLInstID",
213 /* 2 */ "stm: ARRAYLENGTHInstID(stm)",
214 /* 3 */ "stm: ARRAYBOUNDSCHECKInstID(stm,stm)",
215 /* 4 */ "stm: NEGInstID(stm)",
216 /* 5 */ "stm: CASTInstID(stm)",
217 /* 6 */ "stm: ADDInstID(stm,stm)",
218 /* 7 */ "stm: SUBInstID(stm,stm)",
219 /* 8 */ "stm: MULInstID(stm,stm)",
220 /* 9 */ "stm: DIVInstID(stm,stm)",
221 /* 10 */ "stm: REMInstID(stm,stm)",
222 /* 11 */ "stm: SHLInstID",
223 /* 12 */ "stm: USHRInstID",
224 /* 13 */ "stm: ANDInstID(stm,stm)",
225 /* 14 */ "stm: ORInstID(stm,stm)",
226 /* 15 */ "stm: XORInstID(stm,stm)",
227 /* 16 */ "stm: CMPInstID(stm,stm)",
228 /* 17 */ "stm: CONSTInstID",
229 /* 18 */ "stm: AREFInstID(stm,stm)",
230 /* 19 */ "stm: ASTOREInstID(stm,stm)",
231 /* 20 */ "stm: ALOADInstID(stm)",
232 /* 21 */ "stm: LOADInstID",
233 /* 22 */ "stm: IFInstID(stm,stm)",
234 /* 23 */ "stm: TABLESWITCHInstID(stm)",
235 /* 24 */ "stm: LOOKUPSWITCHInstID(stm)",
236 /* 25 */ "stm: RETURNInstID(stm)",
237 /* 26 */ "stm: NoInstID",
238 };
239 
240 static short burm_decode_stm[] = {
241  0,
242  1,
243  2,
244  3,
245  4,
246  5,
247  6,
248  7,
249  8,
250  9,
251  10,
252  11,
253  12,
254  13,
255  14,
256  15,
257  16,
258  17,
259  18,
260  19,
261  20,
262  21,
263  22,
264  23,
265  24,
266  25,
267  26,
268 };
269 
270 
271 #endif
272 
273 #ifdef GENMETHODDEFS
274 #undef GENMETHODDEFS
275 
276 int burm_rule(std::shared_ptr<STATE_TYPE> state, int goalnt);
277 void burm_label(NODEPTR_TYPE a, NODEPTR_TYPE root);
278 void burm_kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]);
279 
280 #endif
281 
282 #ifdef GENMETHODS
283 #undef GENMETHODS
284 
285 
286 namespace {
287 
288 }
289 
290 int Matcher::burm_rule(std::shared_ptr<STATE_TYPE> state, int goalnt) {
291  if (goalnt < 1 || goalnt > 1)
292  ABORT_MSG("burm_rule", "Bad goal nonterminal " << goalnt << nl);
293  if (!state)
294  return 0;
295  switch (goalnt) {
296  case burm_stm_NT: return burm_decode_stm[state->rule.burm_stm];
297  default:
298  ABORT_MSG("burm_rule", "Bad goal nonterminal " << goalnt << nl);
299  return 0;
300  }
301 }
302 
303 
304 void Matcher::burm_label(NODEPTR_TYPE a, NODEPTR_TYPE root) {
305  int c;
306  std::shared_ptr<STATE_TYPE> p;
307 
308  if (!a)
309  ABORT_MSG("burm_label", "Null tree");
310  STATE_LABEL(a) = p = std::shared_ptr<STATE_TYPE>(new STATE_TYPE(root));
311  switch (OP_LABEL(a)) {
312  case 3: /* CHECKNULLInstID */
313  /* stm: CHECKNULLInstID */
314  if (1 + 0 < p->cost[burm_stm_NT]) {
315  p->cost[burm_stm_NT] = 1 + 0;
316  p->rule.burm_stm = 1;
317  }
318  break;
319  case 4: /* ARRAYLENGTHInstID */
320  burm_label(LEFT_CHILD(a), root);
321  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
322  /* stm: ARRAYLENGTHInstID(stm) */
323  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
324  if (c + 0 < p->cost[burm_stm_NT]) {
325  p->cost[burm_stm_NT] = c + 0;
326  p->rule.burm_stm = 2;
327  }
328  break;
329  case 5: /* ARRAYBOUNDSCHECKInstID */
330  burm_label(LEFT_CHILD(a), root);
331  burm_label(RIGHT_CHILD(a), root);
332  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
333  /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
334  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
335  if (c + 0 < p->cost[burm_stm_NT]) {
336  p->cost[burm_stm_NT] = c + 0;
337  p->rule.burm_stm = 3;
338  }
339  break;
340  case 6: /* NEGInstID */
341  burm_label(LEFT_CHILD(a), root);
342  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
343  /* stm: NEGInstID(stm) */
344  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
345  if (c + 0 < p->cost[burm_stm_NT]) {
346  p->cost[burm_stm_NT] = c + 0;
347  p->rule.burm_stm = 4;
348  }
349  break;
350  case 7: /* CASTInstID */
351  burm_label(LEFT_CHILD(a), root);
352  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
353  /* stm: CASTInstID(stm) */
354  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
355  if (c + 0 < p->cost[burm_stm_NT]) {
356  p->cost[burm_stm_NT] = c + 0;
357  p->rule.burm_stm = 5;
358  }
359  break;
360  case 8: /* ADDInstID */
361  burm_label(LEFT_CHILD(a), root);
362  burm_label(RIGHT_CHILD(a), root);
363  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
364  /* stm: ADDInstID(stm,stm) */
365  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
366  if (c + 0 < p->cost[burm_stm_NT]) {
367  p->cost[burm_stm_NT] = c + 0;
368  p->rule.burm_stm = 6;
369  }
370  break;
371  case 9: /* SUBInstID */
372  burm_label(LEFT_CHILD(a), root);
373  burm_label(RIGHT_CHILD(a), root);
374  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
375  /* stm: SUBInstID(stm,stm) */
376  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
377  if (c + 0 < p->cost[burm_stm_NT]) {
378  p->cost[burm_stm_NT] = c + 0;
379  p->rule.burm_stm = 7;
380  }
381  break;
382  case 10: /* MULInstID */
383  burm_label(LEFT_CHILD(a), root);
384  burm_label(RIGHT_CHILD(a), root);
385  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
386  /* stm: MULInstID(stm,stm) */
387  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
388  if (c + 0 < p->cost[burm_stm_NT]) {
389  p->cost[burm_stm_NT] = c + 0;
390  p->rule.burm_stm = 8;
391  }
392  break;
393  case 11: /* DIVInstID */
394  burm_label(LEFT_CHILD(a), root);
395  burm_label(RIGHT_CHILD(a), root);
396  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
397  /* stm: DIVInstID(stm,stm) */
398  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
399  if (c + 0 < p->cost[burm_stm_NT]) {
400  p->cost[burm_stm_NT] = c + 0;
401  p->rule.burm_stm = 9;
402  }
403  break;
404  case 12: /* REMInstID */
405  burm_label(LEFT_CHILD(a), root);
406  burm_label(RIGHT_CHILD(a), root);
407  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
408  /* stm: REMInstID(stm,stm) */
409  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
410  if (c + 0 < p->cost[burm_stm_NT]) {
411  p->cost[burm_stm_NT] = c + 0;
412  p->rule.burm_stm = 10;
413  }
414  break;
415  case 13: /* SHLInstID */
416  /* stm: SHLInstID */
417  if (1 + 0 < p->cost[burm_stm_NT]) {
418  p->cost[burm_stm_NT] = 1 + 0;
419  p->rule.burm_stm = 11;
420  }
421  break;
422  case 14: /* USHRInstID */
423  /* stm: USHRInstID */
424  if (1 + 0 < p->cost[burm_stm_NT]) {
425  p->cost[burm_stm_NT] = 1 + 0;
426  p->rule.burm_stm = 12;
427  }
428  break;
429  case 15: /* ANDInstID */
430  burm_label(LEFT_CHILD(a), root);
431  burm_label(RIGHT_CHILD(a), root);
432  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
433  /* stm: ANDInstID(stm,stm) */
434  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
435  if (c + 0 < p->cost[burm_stm_NT]) {
436  p->cost[burm_stm_NT] = c + 0;
437  p->rule.burm_stm = 13;
438  }
439  break;
440  case 16: /* ORInstID */
441  burm_label(LEFT_CHILD(a), root);
442  burm_label(RIGHT_CHILD(a), root);
443  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
444  /* stm: ORInstID(stm,stm) */
445  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
446  if (c + 0 < p->cost[burm_stm_NT]) {
447  p->cost[burm_stm_NT] = c + 0;
448  p->rule.burm_stm = 14;
449  }
450  break;
451  case 17: /* XORInstID */
452  burm_label(LEFT_CHILD(a), root);
453  burm_label(RIGHT_CHILD(a), root);
454  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
455  /* stm: XORInstID(stm,stm) */
456  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
457  if (c + 0 < p->cost[burm_stm_NT]) {
458  p->cost[burm_stm_NT] = c + 0;
459  p->rule.burm_stm = 15;
460  }
461  break;
462  case 18: /* CMPInstID */
463  burm_label(LEFT_CHILD(a), root);
464  burm_label(RIGHT_CHILD(a), root);
465  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
466  /* stm: CMPInstID(stm,stm) */
467  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
468  if (c + 0 < p->cost[burm_stm_NT]) {
469  p->cost[burm_stm_NT] = c + 0;
470  p->rule.burm_stm = 16;
471  }
472  break;
473  case 19: /* CONSTInstID */
474  /* stm: CONSTInstID */
475  if (1 + 0 < p->cost[burm_stm_NT]) {
476  p->cost[burm_stm_NT] = 1 + 0;
477  p->rule.burm_stm = 17;
478  }
479  break;
480  case 25: /* AREFInstID */
481  burm_label(LEFT_CHILD(a), root);
482  burm_label(RIGHT_CHILD(a), root);
483  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
484  /* stm: AREFInstID(stm,stm) */
485  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
486  if (c + 0 < p->cost[burm_stm_NT]) {
487  p->cost[burm_stm_NT] = c + 0;
488  p->rule.burm_stm = 18;
489  }
490  break;
491  case 26: /* ASTOREInstID */
492  burm_label(LEFT_CHILD(a), root);
493  burm_label(RIGHT_CHILD(a), root);
494  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
495  /* stm: ASTOREInstID(stm,stm) */
496  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
497  if (c + 0 < p->cost[burm_stm_NT]) {
498  p->cost[burm_stm_NT] = c + 0;
499  p->rule.burm_stm = 19;
500  }
501  break;
502  case 27: /* ALOADInstID */
503  burm_label(LEFT_CHILD(a), root);
504  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
505  /* stm: ALOADInstID(stm) */
506  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
507  if (c + 0 < p->cost[burm_stm_NT]) {
508  p->cost[burm_stm_NT] = c + 0;
509  p->rule.burm_stm = 20;
510  }
511  break;
512  case 28: /* LOADInstID */
513  /* stm: LOADInstID */
514  if (1 + 0 < p->cost[burm_stm_NT]) {
515  p->cost[burm_stm_NT] = 1 + 0;
516  p->rule.burm_stm = 21;
517  }
518  break;
519  case 42: /* IFInstID */
520  burm_label(LEFT_CHILD(a), root);
521  burm_label(RIGHT_CHILD(a), root);
522  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID || OP_LABEL(RIGHT_CHILD(a)) == Instruction::NoInstID);
523  /* stm: IFInstID(stm,stm) */
524  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + (STATE_LABEL(RIGHT_CHILD(a)))->cost[burm_stm_NT] + 1;
525  if (c + 0 < p->cost[burm_stm_NT]) {
526  p->cost[burm_stm_NT] = c + 0;
527  p->rule.burm_stm = 22;
528  }
529  break;
530  case 44: /* TABLESWITCHInstID */
531  burm_label(LEFT_CHILD(a), root);
532  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
533  /* stm: TABLESWITCHInstID(stm) */
534  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
535  if (c + 0 < p->cost[burm_stm_NT]) {
536  p->cost[burm_stm_NT] = c + 0;
537  p->rule.burm_stm = 23;
538  }
539  break;
540  case 45: /* LOOKUPSWITCHInstID */
541  burm_label(LEFT_CHILD(a), root);
542  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
543  /* stm: LOOKUPSWITCHInstID(stm) */
544  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
545  if (c + 0 < p->cost[burm_stm_NT]) {
546  p->cost[burm_stm_NT] = c + 0;
547  p->rule.burm_stm = 24;
548  }
549  break;
550  case 46: /* RETURNInstID */
551  burm_label(LEFT_CHILD(a), root);
552  p->isLeaf = (OP_LABEL(LEFT_CHILD(a)) == Instruction::NoInstID);
553  /* stm: RETURNInstID(stm) */
554  c = (STATE_LABEL(LEFT_CHILD(a)))->cost[burm_stm_NT] + 1;
555  if (c + 0 < p->cost[burm_stm_NT]) {
556  p->cost[burm_stm_NT] = c + 0;
557  p->rule.burm_stm = 25;
558  }
559  break;
560  case 55: /* NoInstID */
561  /* stm: NoInstID */
562  if (1 + 0 < p->cost[burm_stm_NT]) {
563  p->cost[burm_stm_NT] = 1 + 0;
564  p->rule.burm_stm = 26;
565  }
566  break;
567  default:
568  ABORT_MSG("burm_label", "Bad terminal " << OP_LABEL(a) << nl);
569  }
570 }
571 
572 void Matcher::burm_kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]) {
573  if (!p)
574  ABORT_MSG("burm_kids", "Null tree");
575  if (!kids)
576  ABORT_MSG("burm_kids", "Null kids");
577  switch (eruleno) {
578  case 26: /* stm: NoInstID */
579  case 21: /* stm: LOADInstID */
580  case 17: /* stm: CONSTInstID */
581  case 12: /* stm: USHRInstID */
582  case 11: /* stm: SHLInstID */
583  case 1: /* stm: CHECKNULLInstID */
584  break;
585  case 25: /* stm: RETURNInstID(stm) */
586  case 24: /* stm: LOOKUPSWITCHInstID(stm) */
587  case 23: /* stm: TABLESWITCHInstID(stm) */
588  case 20: /* stm: ALOADInstID(stm) */
589  case 5: /* stm: CASTInstID(stm) */
590  case 4: /* stm: NEGInstID(stm) */
591  case 2: /* stm: ARRAYLENGTHInstID(stm) */
592  kids[0] = LEFT_CHILD(p);
593  break;
594  case 22: /* stm: IFInstID(stm,stm) */
595  case 19: /* stm: ASTOREInstID(stm,stm) */
596  case 18: /* stm: AREFInstID(stm,stm) */
597  case 16: /* stm: CMPInstID(stm,stm) */
598  case 15: /* stm: XORInstID(stm,stm) */
599  case 14: /* stm: ORInstID(stm,stm) */
600  case 13: /* stm: ANDInstID(stm,stm) */
601  case 10: /* stm: REMInstID(stm,stm) */
602  case 9: /* stm: DIVInstID(stm,stm) */
603  case 8: /* stm: MULInstID(stm,stm) */
604  case 7: /* stm: SUBInstID(stm,stm) */
605  case 6: /* stm: ADDInstID(stm,stm) */
606  case 3: /* stm: ARRAYBOUNDSCHECKInstID(stm,stm) */
607  kids[0] = LEFT_CHILD(p);
608  kids[1] = RIGHT_CHILD(p);
609  break;
610  default:
611  ABORT_MSG("burm_kids", "Bad rule number " << eruleno << nl);
612  }
613 }
614 
615 
616 #endif
617 
618 /*
619 * These are local overrides for various environment variables in Emacs.
620 * Please do not remove this and leave it at the end of the file, where
621 * Emacs will automagically detect them.
622 * ---------------------------------------------------------------------
623 * Local variables:
624 * mode: c++
625 * indent-tabs-mode: t
626 * c-basic-offset: 4
627 * tab-width: 4
628 * End:
629 * vim:noexpandtab:sw=4:ts=4:
630 */
#define STATE_LABEL(p)
Definition: Matcher.cpp:35
#define RIGHT_CHILD(p)
Definition: Matcher.cpp:34
Instruction * NODEPTR_TYPE
Definition: Matcher.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
#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