aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/bugpoint/BugDriver.h4
-rw-r--r--tools/bugpoint/Miscompilation.cpp2
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp4
-rw-r--r--utils/Burg/b.h276
-rw-r--r--utils/Burg/be.c1570
-rw-r--r--utils/Burg/burs.c94
-rw-r--r--utils/Burg/closure.c128
-rw-r--r--utils/Burg/delta.c190
-rw-r--r--utils/Burg/fe.c532
-rw-r--r--utils/Burg/fe.h80
-rw-r--r--utils/Burg/item.c158
-rw-r--r--utils/Burg/lex.c354
-rw-r--r--utils/Burg/list.c72
-rw-r--r--utils/Burg/main.c312
-rw-r--r--utils/Burg/map.c176
-rw-r--r--utils/Burg/nonterminal.c56
-rw-r--r--utils/Burg/operator.c30
-rw-r--r--utils/Burg/pattern.c42
-rw-r--r--utils/Burg/plank.c1432
-rw-r--r--utils/Burg/queue.c64
-rw-r--r--utils/Burg/rule.c46
-rw-r--r--utils/Burg/string.c70
-rw-r--r--utils/Burg/symtab.c36
-rw-r--r--utils/Burg/table.c832
-rw-r--r--utils/Burg/trim.c726
-rw-r--r--utils/Burg/zalloc.c22
-rw-r--r--utils/TableGen/Record.cpp6
-rw-r--r--utils/TableGen/Record.h6
-rw-r--r--utils/TableGen/TableGen.cpp94
29 files changed, 3707 insertions, 3707 deletions
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index e610c67f70..51798d29a5 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -94,7 +94,7 @@ public:
/// are to match.
///
bool debugPassMiscompilation(const PassInfo *ThePass,
- const std::string &ReferenceOutput);
+ const std::string &ReferenceOutput);
/// compileSharedObject - This method creates a SharedObject from a given
/// BytecodeFile for debugging a code generator.
@@ -227,7 +227,7 @@ public:
///
bool runPasses(const std::vector<const PassInfo*> &PassesToRun,
std::string &OutputFilename, bool DeleteOutput = false,
- bool Quiet = false) const;
+ bool Quiet = false) const;
/// writeProgramToFile - This writes the current "Program" to the named
/// bytecode file. If an error occurs, true is returned.
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index c7f954df3c..4d28ff8a99 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -564,7 +564,7 @@ bool BugDriver::debugMiscompilation() {
// Make sure something was miscompiled...
if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
std::cerr << "*** Optimized program matches reference output! No problem "
- << "detected...\nbugpoint can't help you with your problem!\n";
+ << "detected...\nbugpoint can't help you with your problem!\n";
return false;
}
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index 7feccab6ba..5de70be291 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -43,7 +43,7 @@ using namespace llvm;
/// file. If an error occurs, true is returned.
///
bool BugDriver::writeProgramToFile(const std::string &Filename,
- Module *M) const {
+ Module *M) const {
std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
std::ios::binary;
std::ofstream Out(Filename.c_str(), io_mode);
@@ -127,7 +127,7 @@ static void RunChild(Module *Program,const std::vector<const PassInfo*> &Passes,
///
bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
std::string &OutputFilename, bool DeleteOutput,
- bool Quiet) const{
+ bool Quiet) const{
std::cout << std::flush;
sys::Path uniqueFilename("bugpoint-output.bc");
uniqueFilename.makeUnique();
diff --git a/utils/Burg/b.h b/utils/Burg/b.h
index 164325dc97..dfe509b161 100644
--- a/utils/Burg/b.h
+++ b/utils/Burg/b.h
@@ -1,6 +1,6 @@
/* $Id$ */
-#define MAX_ARITY 2
+#define MAX_ARITY 2
typedef int ItemSetNum;
typedef int OperatorNum;
@@ -9,11 +9,11 @@ typedef int RuleNum;
typedef int ArityNum;
typedef int ERuleNum;
-extern NonTerminalNum last_user_nonterminal;
-extern NonTerminalNum max_nonterminal;
-extern RuleNum max_rule;
-extern ERuleNum max_erule_num;
-extern int max_arity;
+extern NonTerminalNum last_user_nonterminal;
+extern NonTerminalNum max_nonterminal;
+extern RuleNum max_rule;
+extern ERuleNum max_erule_num;
+extern int max_arity;
#ifdef __STDC__
#define ARGS(x) x
@@ -22,7 +22,7 @@ extern int max_arity;
#endif
#ifndef NOLEX
-#define DELTAWIDTH 4
+#define DELTAWIDTH 4
typedef short DeltaCost[DELTAWIDTH];
typedef short *DeltaPtr;
extern void ASSIGNCOST ARGS((DeltaPtr, DeltaPtr));
@@ -31,179 +31,179 @@ extern void MINUSCOST ARGS((DeltaPtr, DeltaPtr));
extern void ZEROCOST ARGS((DeltaPtr));
extern int LESSCOST ARGS((DeltaPtr, DeltaPtr));
extern int EQUALCOST ARGS((DeltaPtr, DeltaPtr));
-#define PRINCIPLECOST(x) (x[0])
+#define PRINCIPLECOST(x) (x[0])
#else
-#define DELTAWIDTH 1
+#define DELTAWIDTH 1
typedef int DeltaCost;
typedef int DeltaPtr;
-#define ASSIGNCOST(l, r) ((l) = (r))
-#define ADDCOST(l, r) ((l) += (r))
-#define MINUSCOST(l, r) ((l) -= (r))
-#define ZEROCOST(x) ((x) = 0)
-#define LESSCOST(l, r) ((l) < (r))
-#define EQUALCOST(l, r) ((l) == (r))
-#define PRINCIPLECOST(x) (x)
+#define ASSIGNCOST(l, r) ((l) = (r))
+#define ADDCOST(l, r) ((l) += (r))
+#define MINUSCOST(l, r) ((l) -= (r))
+#define ZEROCOST(x) ((x) = 0)
+#define LESSCOST(l, r) ((l) < (r))
+#define EQUALCOST(l, r) ((l) == (r))
+#define PRINCIPLECOST(x) (x)
#endif /* NOLEX */
-#define NODIVERGE(c,state,nt,base) if (prevent_divergence > 0) CHECKDIVERGE(c,state,nt,base);
+#define NODIVERGE(c,state,nt,base) if (prevent_divergence > 0) CHECKDIVERGE(c,state,nt,base);
struct list {
- void *x;
- struct list *next;
+ void *x;
+ struct list *next;
};
-typedef struct list *List;
+typedef struct list *List;
struct intlist {
- int x;
- struct intlist *next;
+ int x;
+ struct intlist *next;
};
-typedef struct intlist *IntList;
+typedef struct intlist *IntList;
struct operator {
- char *name;
- unsigned int ref:1;
- OperatorNum num;
- ItemSetNum baseNum;
- ItemSetNum stateCount;
- ArityNum arity;
- struct table *table;
+ char *name;
+ unsigned int ref:1;
+ OperatorNum num;
+ ItemSetNum baseNum;
+ ItemSetNum stateCount;
+ ArityNum arity;
+ struct table *table;
};
-typedef struct operator *Operator;
+typedef struct operator *Operator;
struct nonterminal {
- char *name;
- NonTerminalNum num;
- ItemSetNum baseNum;
- ItemSetNum ruleCount;
- struct plankMap *pmap;
+ char *name;
+ NonTerminalNum num;
+ ItemSetNum baseNum;
+ ItemSetNum ruleCount;
+ struct plankMap *pmap;
- struct rule *sampleRule; /* diagnostic---gives "a" rule that with this lhs */
+ struct rule *sampleRule; /* diagnostic---gives "a" rule that with this lhs */
};
-typedef struct nonterminal *NonTerminal;
+typedef struct nonterminal *NonTerminal;
struct pattern {
- NonTerminal normalizer;
- Operator op; /* NULL if NonTerm -> NonTerm */
- NonTerminal children[MAX_ARITY];
+ NonTerminal normalizer;
+ Operator op; /* NULL if NonTerm -> NonTerm */
+ NonTerminal children[MAX_ARITY];
};
-typedef struct pattern *Pattern;
+typedef struct pattern *Pattern;
struct rule {
- DeltaCost delta;
- ERuleNum erulenum;
- RuleNum num;
- RuleNum newNum;
- NonTerminal lhs;
- Pattern pat;
- unsigned int used:1;
+ DeltaCost delta;
+ ERuleNum erulenum;
+ RuleNum num;
+ RuleNum newNum;
+ NonTerminal lhs;
+ Pattern pat;
+ unsigned int used:1;
};
-typedef struct rule *Rule;
+typedef struct rule *Rule;
struct item {
- DeltaCost delta;
- Rule rule;
+ DeltaCost delta;
+ Rule rule;
};
-typedef struct item Item;
+typedef struct item Item;
-typedef short *Relevant; /* relevant non-terminals */
+typedef short *Relevant; /* relevant non-terminals */
-typedef Item *ItemArray;
+typedef Item *ItemArray;
-struct item_set { /* indexed by NonTerminal */
- ItemSetNum num;
- ItemSetNum newNum;
- Operator op;
- struct item_set *kids[2];
- struct item_set *representative;
- Relevant relevant;
- ItemArray virgin;
- ItemArray closed;
+struct item_set { /* indexed by NonTerminal */
+ ItemSetNum num;
+ ItemSetNum newNum;
+ Operator op;
+ struct item_set *kids[2];
+ struct item_set *representative;
+ Relevant relevant;
+ ItemArray virgin;
+ ItemArray closed;
};
-typedef struct item_set *Item_Set;
+typedef struct item_set *Item_Set;
-#define DIM_MAP_SIZE (1 << 8)
-#define GLOBAL_MAP_SIZE (1 << 15)
+#define DIM_MAP_SIZE (1 << 8)
+#define GLOBAL_MAP_SIZE (1 << 15)
-struct mapping { /* should be a hash table for TS -> int */
- List *hash;
- int hash_size;
- int max_size;
- ItemSetNum count;
- Item_Set *set; /* map: int <-> Item_Set */
+struct mapping { /* should be a hash table for TS -> int */
+ List *hash;
+ int hash_size;
+ int max_size;
+ ItemSetNum count;
+ Item_Set *set; /* map: int <-> Item_Set */
};
-typedef struct mapping *Mapping;
+typedef struct mapping *Mapping;
struct index_map {
- ItemSetNum max_size;
- Item_Set *class;
+ ItemSetNum max_size;
+ Item_Set *class;
};
-typedef struct index_map Index_Map;
+typedef struct index_map Index_Map;
struct dimension {
- Relevant relevant;
- Index_Map index_map;
- Mapping map;
- ItemSetNum max_size;
- struct plankMap *pmap;
+ Relevant relevant;
+ Index_Map index_map;
+ Mapping map;
+ ItemSetNum max_size;
+ struct plankMap *pmap;
};
-typedef struct dimension *Dimension;
+typedef struct dimension *Dimension;
struct table {
- Operator op;
- List rules;
- Relevant relevant;
- Dimension dimen[MAX_ARITY]; /* 1 for each dimension */
- Item_Set *transition; /* maps local indices to global
- itemsets */
+ Operator op;
+ List rules;
+ Relevant relevant;
+ Dimension dimen[MAX_ARITY]; /* 1 for each dimension */
+ Item_Set *transition; /* maps local indices to global
+ itemsets */
};
-typedef struct table *Table;
+typedef struct table *Table;
struct relation {
- Rule rule;
- DeltaCost chain;
- NonTerminalNum nextchain;
- DeltaCost sibling;
- int sibFlag;
- int sibComputed;
+ Rule rule;
+ DeltaCost chain;
+ NonTerminalNum nextchain;
+ DeltaCost sibling;
+ int sibFlag;
+ int sibComputed;
};
-typedef struct relation *Relation;
+typedef struct relation *Relation;
struct queue {
- List head;
- List tail;
+ List head;
+ List tail;
};
-typedef struct queue *Queue;
+typedef struct queue *Queue;
struct plank {
- char *name;
- List fields;
- int width;
+ char *name;
+ List fields;
+ int width;
};
-typedef struct plank *Plank;
+typedef struct plank *Plank;
struct except {
- short index;
- short value;
+ short index;
+ short value;
};
-typedef struct except *Exception;
+typedef struct except *Exception;
struct plankMap {
- List exceptions;
- int offset;
- struct stateMap *values;
+ List exceptions;
+ int offset;
+ struct stateMap *values;
};
-typedef struct plankMap *PlankMap;
+typedef struct plankMap *PlankMap;
struct stateMap {
- char *fieldname;
- Plank plank;
- int width;
- short *value;
+ char *fieldname;
+ Plank plank;
+ int width;
+ short *value;
};
-typedef struct stateMap *StateMap;
+typedef struct stateMap *StateMap;
struct stateMapTable {
- List maps;
+ List maps;
};
extern void CHECKDIVERGE ARGS((DeltaPtr, Item_Set, int, int));
@@ -232,7 +232,7 @@ extern Item_Set encode ARGS((Mapping, Item_Set, int *));
extern void build ARGS((void));
extern Item_Set *transLval ARGS((Table, int, int));
-typedef void * (*ListFn) ARGS((void *));
+typedef void * (*ListFn) ARGS((void *));
extern void foreachList ARGS((ListFn, List));
extern void reveachList ARGS((ListFn, List));
@@ -247,23 +247,23 @@ extern void addRelevant ARGS((Relevant, NonTerminalNum));
extern void *zalloc ARGS((unsigned int));
extern void zfree ARGS((void *));
-extern NonTerminal start;
-extern List rules;
-extern List chainrules;
-extern List operators;
-extern List leaves;
-extern List nonterminals;
-extern List grammarNts;
-extern Queue globalQ;
-extern Mapping globalMap;
-extern int exceptionTolerance;
-extern int prevent_divergence;
-extern int principleCost;
-extern int lexical;
-extern struct rule stub_rule;
-extern Relation *allpairs;
-extern Item_Set *sortedStates;
-extern Item_Set errorState;
+extern NonTerminal start;
+extern List rules;
+extern List chainrules;
+extern List operators;
+extern List leaves;
+extern List nonterminals;
+extern List grammarNts;
+extern Queue globalQ;
+extern Mapping globalMap;
+extern int exceptionTolerance;
+extern int prevent_divergence;
+extern int principleCost;
+extern int lexical;
+extern struct rule stub_rule;
+extern Relation *allpairs;
+extern Item_Set *sortedStates;
+extern Item_Set errorState;
extern void dumpRelevant ARGS((Relevant));
extern void dumpOperator ARGS((Operator, int));
@@ -289,14 +289,14 @@ extern void dumpSortedRules ARGS((void));
extern int debugTrim;
#ifdef DEBUG
-#define debug(a,b) if (a) b
+#define debug(a,b) if (a) b
#else
#define debug(a,b)
#endif
extern int debugTables;
-#define TABLE_INCR 8
-#define STATES_INCR 64
+#define TABLE_INCR 8
+#define STATES_INCR 64
#ifdef NDEBUG
#define assert(c) ((void) 0)
diff --git a/utils/Burg/be.c b/utils/Burg/be.c
index 303f9406fa..f048cdba15 100644
--- a/utils/Burg/be.c
+++ b/utils/Burg/be.c
@@ -29,120 +29,120 @@ static void printRule ARGS((RuleAST, const char *));
static void
doLabel(op) Operator op;
{
- fprintf(outfile, "\tcase %d:\n", op->num);
-
- switch (op->arity) {
- default:
- assert(0);
- break;
- case 0:
- fprintf(outfile, "\t\treturn %d;\n", op->table->transition[0]->num);
- break;
- case 1:
- if (op->table->rules) {
- fprintf(outfile, "\t\treturn %s_%s_transition[l];\n", prefix, op->name);
- } else {
- fprintf(outfile, "\t\treturn %d;\n", ERROR_VAL);
- }
- break;
- case 2:
- if (op->table->rules) {
- fprintf(outfile, "\t\treturn %s_%s_transition[%s_%s_imap_1[l]][%s_%s_imap_2[r]];\n", prefix, op->name, prefix, op->name, prefix, op->name);
- } else {
- fprintf(outfile, "\t\treturn %d;\n", ERROR_VAL);
- }
- break;
- }
+ fprintf(outfile, "\tcase %d:\n", op->num);
+
+ switch (op->arity) {
+ default:
+ assert(0);
+ break;
+ case 0:
+ fprintf(outfile, "\t\treturn %d;\n", op->table->transition[0]->num);
+ break;
+ case 1:
+ if (op->table->rules) {
+ fprintf(outfile, "\t\treturn %s_%s_transition[l];\n", prefix, op->name);
+ } else {
+ fprintf(outfile, "\t\treturn %d;\n", ERROR_VAL);
+ }
+ break;
+ case 2:
+ if (op->table->rules) {
+ fprintf(outfile, "\t\treturn %s_%s_transition[%s_%s_imap_1[l]][%s_%s_imap_2[r]];\n", prefix, op->name, prefix, op->name, prefix, op->name);
+ } else {
+ fprintf(outfile, "\t\treturn %d;\n", ERROR_VAL);
+ }
+ break;
+ }
}
int
opsOfArity(arity) int arity;
{
- int c;
- List l;
-
- c = 0;
- for (l = operators; l; l = l->next) {
- Operator op = (Operator) l->x;
- if (op->arity == arity) {
- fprintf(outfile, "\tcase %d:\n", op->num);
- c++;
- }
- }
- return c;
+ int c;
+ List l;
+
+ c = 0;
+ for (l = operators; l; l = l->next) {
+ Operator op = (Operator) l->x;
+ if (op->arity == arity) {
+ fprintf(outfile, "\tcase %d:\n", op->num);
+ c++;
+ }
+ }
+ return c;
}
static void
trailing_zeroes(z) int z;
{
- int i;
+ int i;
- for (i = 0; i < z; i++) {
- fprintf(outfile, ", 0");
- }
+ for (i = 0; i < z; i++) {
+ fprintf(outfile, ", 0");
+ }
}
void
makeLabel()
{
- int flag;
-
- fprintf(outfile, "#ifdef __STDC__\n");
- fprintf(outfile, "int %s_label(%s_NODEPTR_TYPE n) {\n", prefix, prefix);
- fprintf(outfile, "#else\n");
- fprintf(outfile, "int %s_label(n) %s_NODEPTR_TYPE n; {\n", prefix, prefix);
- fprintf(outfile, "#endif\n");
-
- fprintf(outfile,
- "\t%s_assert(n, %s_PANIC(\"NULL pointer passed to %s_label\\n\"));\n",
- prefix, prefix, prefix);
- fprintf(outfile, "\tswitch (%s_OP_LABEL(n)) {\n", prefix);
- fprintf(outfile, "\tdefault: %s_PANIC(\"Bad op %%d in %s_label\\n\", %s_OP_LABEL(n)); abort(); return 0;\n",
- prefix, prefix, prefix);
-
- flag = opsOfArity(0);
- if (flag > 0) {
- fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n)",
- prefix, prefix, prefix);
- trailing_zeroes(max_arity);
- fprintf(outfile, ");\n");
- }
- flag = opsOfArity(1);
- if (flag > 0) {
- fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n), %s_label(%s_LEFT_CHILD(n))",
- prefix, prefix, prefix, prefix, prefix);
- trailing_zeroes(max_arity-1);
- fprintf(outfile, ");\n");
- }
- flag = opsOfArity(2);
- if (flag > 0) {
- fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n), %s_label(%s_LEFT_CHILD(n)), %s_label(%s_RIGHT_CHILD(n))",
- prefix, prefix, prefix, prefix, prefix, prefix, prefix);
- trailing_zeroes(max_arity-2);
- fprintf(outfile, ");\n");
-
- }
- fprintf(outfile, "\t}\n");
- fprintf(outfile, "}\n");
+ int flag;
+
+ fprintf(outfile, "#ifdef __STDC__\n");
+ fprintf(outfile, "int %s_label(%s_NODEPTR_TYPE n) {\n", prefix, prefix);
+ fprintf(outfile, "#else\n");
+ fprintf(outfile, "int %s_label(n) %s_NODEPTR_TYPE n; {\n", prefix, prefix);
+ fprintf(outfile, "#endif\n");
+
+ fprintf(outfile,
+ "\t%s_assert(n, %s_PANIC(\"NULL pointer passed to %s_label\\n\"));\n",
+ prefix, prefix, prefix);
+ fprintf(outfile, "\tswitch (%s_OP_LABEL(n)) {\n", prefix);
+ fprintf(outfile, "\tdefault: %s_PANIC(\"Bad op %%d in %s_label\\n\", %s_OP_LABEL(n)); abort(); return 0;\n",
+ prefix, prefix, prefix);
+
+ flag = opsOfArity(0);
+ if (flag > 0) {
+ fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n)",
+ prefix, prefix, prefix);
+ trailing_zeroes(max_arity);
+ fprintf(outfile, ");\n");
+ }
+ flag = opsOfArity(1);
+ if (flag > 0) {
+ fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n), %s_label(%s_LEFT_CHILD(n))",
+ prefix, prefix, prefix, prefix, prefix);
+ trailing_zeroes(max_arity-1);
+ fprintf(outfile, ");\n");
+ }
+ flag = opsOfArity(2);
+ if (flag > 0) {
+ fprintf(outfile, "\t\treturn %s_STATE_LABEL(n) = %s_state(%s_OP_LABEL(n), %s_label(%s_LEFT_CHILD(n)), %s_label(%s_RIGHT_CHILD(n))",
+ prefix, prefix, prefix, prefix, prefix, prefix, prefix);
+ trailing_zeroes(max_arity-2);
+ fprintf(outfile, ");\n");
+
+ }
+ fprintf(outfile, "\t}\n");
+ fprintf(outfile, "}\n");
}
static void
makeState()
{
- fprintf(outfile, "int %s_state(int op, int l, int r) {\n", prefix);
- fprintf(outfile,
- "\t%s_assert(l >= 0 && l < %d, PANIC(\"Bad state %%d passed to %s_state\\n\", l));\n",
- prefix, globalMap->count, prefix);
- fprintf(outfile,
- "\t%s_assert(r >= 0 && r < %d, PANIC(\"Bad state %%d passed to %s_state\\n\", r));\n",
- prefix, globalMap->count, prefix);
- fprintf(outfile, "\tswitch (op) {\n");
- fprintf(outfile, "\tdefault: %s_PANIC(\"Bad op %%d in %s_state\\n\", op); abort(); return 0;\n", prefix, prefix);
-
- foreachList((ListFn) doLabel, operators);
-
- fprintf(outfile, "\t}\n");
- fprintf(outfile, "}\n");
+ fprintf(outfile, "int %s_state(int op, int l, int r) {\n", prefix);
+ fprintf(outfile,
+ "\t%s_assert(l >= 0 && l < %d, PANIC(\"Bad state %%d passed to %s_state\\n\", l));\n",
+ prefix, globalMap->count, prefix);
+ fprintf(outfile,
+ "\t%s_assert(r >= 0 && r < %d, PANIC(\"Bad state %%d passed to %s_state\\n\", r));\n",
+ prefix, globalMap->count, prefix);
+ fprintf(outfile, "\tswitch (op) {\n");
+ fprintf(outfile, "\tdefault: %s_PANIC(\"Bad op %%d in %s_state\\n\", op); abort(); return 0;\n", prefix, prefix);
+
+ foreachList((ListFn) doLabel, operators);
+
+ fprintf(outfile, "\t}\n");
+ fprintf(outfile, "}\n");
}
static char cumBuf[4000];
@@ -152,162 +152,162 @@ char vecBuf[4000];
static void
setVectors(ast) PatternAST ast;
{
- char old[4000];
-
- switch (ast->sym->tag) {
- default:
- assert(0);
- break;
- case NONTERMINAL:
- sprintf(old, "\t\tkids[%d] = %s;\n", vecIndex, vecBuf);
- strcat(cumBuf, old);
- vecIndex++;
- return;
- case OPERATOR:
- switch (ast->sym->u.op->arity) {
- default:
- assert(0);
- break;
- case 0:
- return;
- case 1:
- strcpy(old, vecBuf);
- sprintf(vecBuf, "%s_LEFT_CHILD(%s)", prefix, old);
- setVectors((PatternAST) ast->children->x);
- strcpy(vecBuf, old);
- return;
- case 2:
- strcpy(old, vecBuf);
- sprintf(vecBuf, "%s_LEFT_CHILD(%s)", prefix, old);
- setVectors((PatternAST) ast->children->x);
-
- sprintf(vecBuf, "%s_RIGHT_CHILD(%s)", prefix, old);
- setVectors((PatternAST) ast->children->next->x);
- strcpy(vecBuf, old);
- return;
- }
- break;
- }
+ char old[4000];
+
+ switch (ast->sym->tag) {
+ default:
+ assert(0);
+ break;
+ case NONTERMINAL:
+ sprintf(old, "\t\tkids[%d] = %s;\n", vecIndex, vecBuf);
+ strcat(cumBuf, old);
+ vecIndex++;
+ return;
+ case OPERATOR:
+ switch (ast->sym->u.op->arity) {
+ default:
+ assert(0);
+ break;
+ case 0:
+ return;
+ case 1:
+ strcpy(old, vecBuf);
+ sprintf(vecBuf, "%s_LEFT_CHILD(%s)", prefix, old);
+ setVectors((PatternAST) ast->children->x);
+ strcpy(vecBuf, old);
+ return;
+ case 2:
+ strcpy(old, vecBuf);
+ sprintf(vecBuf, "%s_LEFT_CHILD(%s)", prefix, old);
+ setVectors((PatternAST) ast->children->x);
+
+ sprintf(vecBuf, "%s_RIGHT_CHILD(%s)", prefix, old);
+ setVectors((PatternAST) ast->children->next->x);
+ strcpy(vecBuf, old);
+ return;
+ }
+ break;
+ }
}
-#define MAX_VECTOR 10
+#define MAX_VECTOR 10
void
makeRuleTable()
{
- int s,nt;
-
- fprintf(outfile, "static short %s_RuleNo[%d][%d] = {\n", prefix, globalMap->count, last_user_nonterminal-1);
- for (s = 0; s < globalMap->count; s++) {
- Item_Set ts = globalMap->set[s];
- if (s > 0) {
- fprintf(outfile, ",\n");
- }
- fprintf(outfile, "/* state %d */\n", s);
- fprintf(outfile, "{");
- for (nt = 1; nt < last_user_nonterminal; nt++) {
- if (nt > 1) {
- fprintf(outfile, ",");
- if (nt % 10 == 1) {
- fprintf(outfile, "\t/* state %d; Nonterminals %d-%d */\n", s, nt-10, nt-1);
- }
- }
- if (ts->closed[nt].rule) {
- ts->closed[nt].rule->used = 1;
- fprintf(outfile, "%5d", ts->closed[nt].rule->erulenum);
- } else {
- fprintf(outfile, "%5d", ERROR_VAL);
- }
- }
- fprintf(outfile, "}");
- }
- fprintf(outfile, "};\n");
+ int s,nt;
+
+ fprintf(outfile, "static short %s_RuleNo[%d][%d] = {\n", prefix, globalMap->count, last_user_nonterminal-1);
+ for (s = 0; s < globalMap->count; s++) {
+ Item_Set ts = globalMap->set[s];
+ if (s > 0) {
+ fprintf(outfile, ",\n");
+ }
+ fprintf(outfile, "/* state %d */\n", s);
+ fprintf(outfile, "{");
+ for (nt = 1; nt < last_user_nonterminal; nt++) {
+ if (nt > 1) {
+ fprintf(outfile, ",");
+ if (nt % 10 == 1) {
+ fprintf(outfile, "\t/* state %d; Nonterminals %d-%d */\n", s, nt-10, nt-1);
+ }
+ }
+ if (ts->closed[nt].rule) {
+ ts->closed[nt].rule->used = 1;
+ fprintf(outfile, "%5d", ts->closed[nt].rule->erulenum);
+ } else {
+ fprintf(outfile, "%5d", ERROR_VAL);
+ }
+ }
+ fprintf(outfile, "}");
+ }
+ fprintf(outfile, "};\n");
}
static void
makeIndex_Map(d) Dimension d;
{
- int s;
-
- for (s = 0; s < globalMap->count; s++) {
- if (s > 0) {
- fprintf(outfile, ",");
- if (s % 10 == 0) {
- fprintf(outfile, "\t/* %d-%d */\n", s-10, s-1);
- }
- }
- fprintf(outfile, "%5d", d->map->set[d->index_map.class[s]->num]->num);
- }
- fprintf(outfile, "};\n");
+ int s;
+
+ for (s = 0; s < globalMap->count; s++) {
+ if (s > 0) {
+ fprintf(outfile, ",");
+ if (s % 10 == 0) {
+ fprintf(outfile, "\t/* %d-%d */\n", s-10, s-1);
+ }
+ }
+ fprintf(outfile, "%5d", d->map->set[d->index_map.class[s]->num]->num);
+ }
+ fprintf(outfile, "};\n");
}
static void
doMakeTable(op) Operator op;
{
- int s;
- int i,j;
- Dimension d;
-
- switch (op->arity) {
- default:
- assert(0);
- break;
- case 0:
- return;
- case 1:
- if (!op->table->rules) {
- return;
- }
- d = op->table->dimen[0];
- fprintf(outfile, "static short %s_%s_transition[%d] = {\n", prefix, op->name, globalMap->count);
- for (s = 0; s < globalMap->count; s++) {
- if (s > 0) {
- fprintf(outfile, ", ");
- if (s % 10 == 0) {
- fprintf(outfile, "\t/* %d-%d */\n", s-10, s-1);
- }
- }
- fprintf(outfile, "%5d", op->table->transition[d->map->set[d->index_map.class[s]->num]->num]->num);
- }
- fprintf(outfile, "};\n");
- break;
- case 2:
- if (!op->table->rules) {
- return;
- }
- fprintf(outfile, "static short %s_%s_imap_1[%d] = {\n", prefix, op->name, globalMap->count);
- makeIndex_Map(op->table->dimen[0]);
- fprintf(outfile, "static short %s_%s_imap_2[%d] = {\n", prefix, op->name, globalMap->count);
- makeIndex_Map(op->table->dimen[1]);
-
- fprintf(outfile, "static short %s_%s_transition[%d][%d] = {", prefix, op->name,
- op->table->dimen[0]->map->count,
- op->table->dimen[1]->map->count);
- for (i = 0; i < op->table->dimen[0]->map->count; i++) {
- if (i > 0) {
- fprintf(outfile, ",");
- }
- fprintf(outfile, "\n");
- fprintf(outfile, "{");
- for (j = 0; j < op->table->dimen[1]->map->count; j++) {
- Item_Set *ts = transLval(op->table, i, j);
- if (j > 0) {
- fprintf(outfile, ",");
- }
- fprintf(outfile, "%5d", (*ts)->num);
- }
- fprintf(outfile, "}\t/* row %d */", i);
- }
- fprintf(outfile, "\n};\n");
-
- break;
- }
+ int s;
+ int i,j;
+ Dimension d;
+
+ switch (op->arity) {
+ default:
+ assert(0);
+ break;
+ case 0:
+ return;
+ case 1:
+ if (!op->table->rules) {
+ return;
+ }
+ d = op->table->dimen[0];
+ fprintf(outfile, "static short %s_%s_transition[%d] = {\n", prefix, op->name, globalMap->count);
+ for (s = 0; s < globalMap->count; s++) {
+ if (s > 0) {
+ fprintf(outfile, ", ");
+ if (s % 10 == 0) {
+ fprintf(outfile, "\t/* %d-%d */\n", s-10, s-1);
+ }
+ }
+ fprintf(outfile, "%5d", op->table->transition[d->map->set[d->index_map.class[s]->num]->num]->num);
+ }
+ fprintf(outfile, "};\n");
+ break;
+ case 2:
+ if (!op->table->rules) {
+ return;
+ }
+ fprintf(outfile, "static