Added llvmgcc version to allow tests to be xfailed by frontend version.
[llvm-complete.git] / utils / Burg / burs.c
blob52df4266ac0fdad6f7f37902557cddb8919e76c8
1 char rcsid_burs[] = "$Id$";
3 #include "b.h"
5 Item_Set errorState;
7 static void doLeaf ARGS((Operator));
9 static void
10 doLeaf(leaf) Operator leaf;
12 int new;
13 List pl;
14 Item_Set ts;
15 Item_Set tmp;
17 assert(leaf->arity == 0);
19 ts = newItem_Set(leaf->table->relevant);
21 for (pl = rules; pl; pl = pl->next) {
22 Rule p = (Rule) pl->x;
23 if (p->pat->op == leaf) {
24 if (!ts->virgin[p->lhs->num].rule || p->delta < ts->virgin[p->lhs->num].delta) {
25 ts->virgin[p->lhs->num].rule = p;
26 ASSIGNCOST(ts->virgin[p->lhs->num].delta, p->delta);
27 ts->op = leaf;
31 trim(ts);
32 zero(ts);
33 tmp = encode(globalMap, ts, &new);
34 if (new) {
35 closure(ts);
36 leaf->table->transition[0] = ts;
37 addQ(globalQ, ts);
38 } else {
39 leaf->table->transition[0] = tmp;
40 freeItem_Set(ts);
44 void
45 build()
47 int new;
48 List ol;
49 Item_Set ts;
51 globalQ = newQ();
52 globalMap = newMapping(GLOBAL_MAP_SIZE);
54 ts = newItem_Set(0);
55 errorState = encode(globalMap, ts, &new);
56 ts->closed = ts->virgin;
57 addQ(globalQ, ts);
59 foreachList((ListFn) doLeaf, leaves);
61 debug(debugTables, printf("---initial set of states ---\n"));
62 debug(debugTables, dumpMapping(globalMap));
63 debug(debugTables, foreachList((ListFn) dumpItem_Set, globalQ->head));
65 for (ts = popQ(globalQ); ts; ts = popQ(globalQ)) {
66 for (ol = operators; ol; ol = ol->next) {
67 Operator op = (Operator) ol->x;
68 addToTable(op->table, ts);