aboutsummaryrefslogtreecommitdiff
path: root/sim/igen
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-11-22 04:20:49 +0000
committerAndrew Cagney <cagney@redhat.com>2002-11-22 04:20:49 +0000
commit4e0bf4c4d00096ac436378edaf7718dafec9ff82 (patch)
tree9a80850d7051a761dee6c6dd1aed8df337a1f92c /sim/igen
parentfeaee4bdbb06466822e886f5d1d30b9f1e04d985 (diff)
downloadgdb-4e0bf4c4d00096ac436378edaf7718dafec9ff82.zip
gdb-4e0bf4c4d00096ac436378edaf7718dafec9ff82.tar.gz
gdb-4e0bf4c4d00096ac436378edaf7718dafec9ff82.tar.bz2
2002-11-21 Andrew Cagney <ac131313@redhat.com>
* filter.c: Re-indent. * filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto. * gen-icache.c, gen-icache.h, gen-idecode.c: Ditto. * gen-idecode.h, gen-itable.c, gen-itable.h: Ditto. * gen-model.c, gen-model.h, gen-semantics.c: Ditto. * gen-semantics.h, gen-support.c, gen-support.h: Ditto. * gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto. * ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto. * lf.h, misc.c, misc.h, table.c, table.h: Ditto.
Diffstat (limited to 'sim/igen')
-rw-r--r--sim/igen/ChangeLog12
-rw-r--r--sim/igen/filter.c153
-rw-r--r--sim/igen/filter.h34
-rw-r--r--sim/igen/filter_host.h3
-rw-r--r--sim/igen/gen-engine.c244
-rw-r--r--sim/igen/gen-engine.h15
-rw-r--r--sim/igen/gen-icache.c482
-rw-r--r--sim/igen/gen-icache.h50
-rw-r--r--sim/igen/gen-idecode.c475
-rw-r--r--sim/igen/gen-idecode.h23
-rw-r--r--sim/igen/gen-itable.c89
-rw-r--r--sim/igen/gen-itable.h8
-rw-r--r--sim/igen/gen-model.c625
-rw-r--r--sim/igen/gen-model.h8
-rw-r--r--sim/igen/gen-semantics.c130
-rw-r--r--sim/igen/gen-semantics.h36
-rw-r--r--sim/igen/gen-support.c136
-rw-r--r--sim/igen/gen-support.h9
-rw-r--r--sim/igen/gen.c731
-rw-r--r--sim/igen/gen.h118
-rw-r--r--sim/igen/igen.c485
-rw-r--r--sim/igen/igen.h49
-rw-r--r--sim/igen/ld-cache.c16
-rw-r--r--sim/igen/ld-cache.h3
-rw-r--r--sim/igen/ld-decode.c131
-rw-r--r--sim/igen/ld-decode.h47
-rw-r--r--sim/igen/ld-insn.c875
-rw-r--r--sim/igen/ld-insn.h172
-rw-r--r--sim/igen/lf.c307
-rw-r--r--sim/igen/lf.h100
-rw-r--r--sim/igen/misc.c70
-rw-r--r--sim/igen/misc.h41
-rw-r--r--sim/igen/table.c131
-rw-r--r--sim/igen/table.h55
34 files changed, 2750 insertions, 3113 deletions
diff --git a/sim/igen/ChangeLog b/sim/igen/ChangeLog
index 11cc70f..97ad4ef 100644
--- a/sim/igen/ChangeLog
+++ b/sim/igen/ChangeLog
@@ -1,5 +1,17 @@
2002-11-21 Andrew Cagney <ac131313@redhat.com>
+ * filter.c: Re-indent.
+ * filter.h, filter_host.h, gen-engine.c, gen-engine.h: Ditto.
+ * gen-icache.c, gen-icache.h, gen-idecode.c: Ditto.
+ * gen-idecode.h, gen-itable.c, gen-itable.h: Ditto.
+ * gen-model.c, gen-model.h, gen-semantics.c: Ditto.
+ * gen-semantics.h, gen-support.c, gen-support.h: Ditto.
+ * gen.c, gen.h, igen.c, igen.h, ld-cache.c, ld-cache.h: Ditto.
+ * ld-decode.c, ld-decode.h, ld-insn.c, ld-insn.h, lf.c: Ditto.
+ * lf.h, misc.c, misc.h, table.c, table.h: Ditto.
+
+2002-11-21 Andrew Cagney <ac131313@redhat.com>
+
* Makefile.in: Update copyright. IGEN contributed to the FSF.
* filter.c, filter.h, filter_host.c, filter_host.h: Ditto.
* gen-engine.c, gen-engine.h, gen-icache.c, gen-icache.h: Ditto.
diff --git a/sim/igen/filter.c b/sim/igen/filter.c
index a5bfef3..ef74fc0 100644
--- a/sim/igen/filter.c
+++ b/sim/igen/filter.c
@@ -38,15 +38,15 @@
#include "lf.h"
#include "filter.h"
-struct _filter {
+struct _filter
+{
char *member;
filter *next;
};
void
-filter_parse (filter **filters,
- const char *filt)
+filter_parse (filter **filters, const char *filt)
{
while (strlen (filt) > 0)
{
@@ -54,7 +54,7 @@ filter_parse (filter **filters,
filter **last;
/* break out a member of the filter list */
const char *flag = filt;
- unsigned /*size_t*/ len;
+ unsigned /*size_t */ len;
filt = strchr (filt, ',');
if (filt == NULL)
{
@@ -68,13 +68,12 @@ filter_parse (filter **filters,
}
/* find an insertion point - sorted order */
last = filters;
- while (*last != NULL
- && strncmp (flag, (*last)->member, len) > 0)
+ while (*last != NULL && strncmp (flag, (*last)->member, len) > 0)
last = &(*last)->next;
if (*last != NULL
&& strncmp (flag, (*last)->member, len) == 0
&& strlen ((*last)->member) == len)
- continue; /* duplicate */
+ continue; /* duplicate */
/* create an entry for that member */
new_filter = ZALLOC (filter);
new_filter->member = NZALLOC (char, len + 1);
@@ -87,14 +86,13 @@ filter_parse (filter **filters,
void
-filter_add (filter **set,
- filter *add)
+filter_add (filter **set, filter *add)
{
while (add != NULL)
{
int cmp;
if (*set == NULL)
- cmp = 1; /* set->member > add->member */
+ cmp = 1; /* set->member > add->member */
else
cmp = strcmp ((*set)->member, add->member);
if (cmp > 0)
@@ -112,7 +110,7 @@ filter_add (filter **set,
/* already in set */
add = add->next;
}
- else /* cmp < 0 */
+ else /* cmp < 0 */
{
/* not reached insertion point */
set = &(*set)->next;
@@ -122,8 +120,7 @@ filter_add (filter **set,
int
-filter_is_subset (filter *superset,
- filter *subset)
+filter_is_subset (filter *superset, filter *subset)
{
while (1)
{
@@ -131,21 +128,20 @@ filter_is_subset (filter *superset,
if (subset == NULL)
return 1;
if (superset == NULL)
- return 0; /* subset isn't finished */
+ return 0; /* subset isn't finished */
cmp = strcmp (subset->member, superset->member);
if (cmp < 0)
- return 0; /* not found */
+ return 0; /* not found */
else if (cmp == 0)
- subset = subset->next; /* found */
+ subset = subset->next; /* found */
else if (cmp > 0)
- superset = superset->next; /* later in list? */
+ superset = superset->next; /* later in list? */
}
}
int
-filter_is_common (filter *l,
- filter *r)
+filter_is_common (filter *l, filter *r)
{
while (1)
{
@@ -158,7 +154,7 @@ filter_is_common (filter *l,
if (cmp < 0)
l = l->next;
else if (cmp == 0)
- return 1; /* common member */
+ return 1; /* common member */
else if (cmp > 0)
r = r->next;
}
@@ -166,8 +162,7 @@ filter_is_common (filter *l,
int
-filter_is_member (filter *filt,
- const char *flag)
+filter_is_member (filter *filt, const char *flag)
{
int index = 1;
while (filt != NULL)
@@ -182,68 +177,72 @@ filter_is_member (filter *filt,
int
-is_filtered_out (filter *filters,
- const char *flags)
+is_filtered_out (filter *filters, const char *flags)
{
- while (strlen(flags) > 0) {
- int present;
- filter *filt = filters;
- /* break the string up */
- char *end = strchr(flags, ',');
- char *next;
- unsigned /*size_t*/ len;
- if (end == NULL) {
- end = strchr(flags, '\0');
- next = end;
- }
- else {
- next = end + 1;
- }
- len = end - flags;
- /* check that it is present */
- present = 0;
- filt = filters;
- while (filt != NULL) {
- if (strncmp(flags, filt->member, len) == 0
- && strlen(filt->member) == len) {
- present = 1;
- break;
- }
- filt = filt->next;
+ while (strlen (flags) > 0)
+ {
+ int present;
+ filter *filt = filters;
+ /* break the string up */
+ char *end = strchr (flags, ',');
+ char *next;
+ unsigned /*size_t */ len;
+ if (end == NULL)
+ {
+ end = strchr (flags, '\0');
+ next = end;
+ }
+ else
+ {
+ next = end + 1;
+ }
+ len = end - flags;
+ /* check that it is present */
+ present = 0;
+ filt = filters;
+ while (filt != NULL)
+ {
+ if (strncmp (flags, filt->member, len) == 0
+ && strlen (filt->member) == len)
+ {
+ present = 1;
+ break;
+ }
+ filt = filt->next;
+ }
+ if (!present)
+ return 1;
+ flags = next;
}
- if (!present)
- return 1;
- flags = next;
- }
return 0;
}
#if 0
int
-it_is (const char *flag,
- const char *flags)
+it_is (const char *flag, const char *flags)
{
- int flag_len = strlen(flag);
- while (*flags != '\0') {
- if (!strncmp(flags, flag, flag_len)
- && (flags[flag_len] == ',' || flags[flag_len] == '\0'))
- return 1;
- while (*flags != ',') {
- if (*flags == '\0')
- return 0;
+ int flag_len = strlen (flag);
+ while (*flags != '\0')
+ {
+ if (!strncmp (flags, flag, flag_len)
+ && (flags[flag_len] == ',' || flags[flag_len] == '\0'))
+ return 1;
+ while (*flags != ',')
+ {
+ if (*flags == '\0')
+ return 0;
+ flags++;
+ }
flags++;
}
- flags++;
- }
return 0;
}
#endif
char *
-filter_next (filter *set,
- char *member)
+filter_next (filter *set, char *member)
{
while (set != NULL)
{
@@ -256,10 +255,7 @@ filter_next (filter *set,
void
-dump_filter (lf *file,
- char *prefix,
- filter *set,
- char *suffix)
+dump_filter (lf *file, char *prefix, filter *set, char *suffix)
{
char *member;
lf_printf (file, "%s", prefix);
@@ -281,20 +277,21 @@ dump_filter (lf *file,
#ifdef MAIN
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
filter *subset = NULL;
filter *superset = NULL;
lf *l;
int i;
- if (argc < 2) {
- printf("Usage: filter <subset> <filter> ...\n");
- exit (1);
- }
+ if (argc < 2)
+ {
+ printf ("Usage: filter <subset> <filter> ...\n");
+ exit (1);
+ }
/* load the filter up */
filter_parse (&subset, argv[1]);
- for (i = 2; i < argc; i++)
+ for (i = 2; i < argc; i++)
filter_parse (&superset, argv[i]);
/* dump various info */
@@ -352,7 +349,7 @@ main(int argc, char **argv)
dump_filter (l, "{", superset, " }");
lf_printf (l, "\n");
}
-
+
return 0;
}
#endif
diff --git a/sim/igen/filter.h b/sim/igen/filter.h
index 7951311..6cef909 100644
--- a/sim/igen/filter.h
+++ b/sim/igen/filter.h
@@ -28,62 +28,44 @@ typedef struct _filter filter;
/* parse the list merging any flags into the filter */
-extern void filter_parse
-(filter **filters,
- const char *filt);
+extern void filter_parse (filter **filters, const char *filt);
/* add the second filter to the first */
-extern void filter_add
-(filter **filters,
- filter *add);
+extern void filter_add (filter **filters, filter *add);
/* returns true if SUB is a strict subset of SUPER. For an empty set
is a member of any set */
-extern int filter_is_subset
-(filter *superset,
- filter *subset);
+extern int filter_is_subset (filter *superset, filter *subset);
/* return true if there is at least one member common to the two
filters */
-extern int filter_is_common
-(filter *l,
- filter *r);
+extern int filter_is_common (filter *l, filter *r);
/* returns the index (pos + 1) if the name is in the filter. */
-extern int filter_is_member
-(filter *set,
- const char *flag);
+extern int filter_is_member (filter *set, const char *flag);
/* returns true if one of the flags is not present in the filter.
=== !filter_is_subset (filter_parse (NULL, flags), filters) */
-int is_filtered_out
-(filter *filters,
- const char *flags);
+int is_filtered_out (filter *filters, const char *flags);
/* returns the next member of the filter set that follows MEMBER.
Member does not need to be an elememt of the filter set. Next of
"" is the first non-empty member */
-char *filter_next
-(filter *set,
- char *member);
+char *filter_next (filter *set, char *member);
/* for debugging */
-extern void dump_filter
-(lf *file,
- char *prefix,
- filter *filt,
- char *suffix);
+extern void dump_filter (lf *file, char *prefix, filter *filt, char *suffix);
diff --git a/sim/igen/filter_host.h b/sim/igen/filter_host.h
index 79839fe..7c6739d 100644
--- a/sim/igen/filter_host.h
+++ b/sim/igen/filter_host.h
@@ -25,6 +25,5 @@
#define _FILTER_HOST_H
/* Remove directory part from filename */
-extern const char *
-filter_filename(const char *filename);
+extern const char *filter_filename (const char *filename);
#endif
diff --git a/sim/igen/gen-engine.c b/sim/igen/gen-engine.c
index 70ede3d..d0f5c30 100644
--- a/sim/igen/gen-engine.c
+++ b/sim/igen/gen-engine.c
@@ -65,25 +65,25 @@ print_engine_issue_postfix_hook (lf *file)
static void
-print_run_body (lf *file,
- gen_entry *table)
+print_run_body (lf *file, gen_entry *table)
{
/* Output the function to execute real code:
-
+
Unfortunatly, there are multiple cases to consider vis:
-
+
<icache> X <smp>
-
+
Consequently this function is written in multiple different ways */
-
+
lf_printf (file, "{\n");
lf_indent (file, +2);
if (!options.gen.smp)
{
- lf_printf (file, "%sinstruction_address cia;\n", options.module.global.prefix.l);
+ lf_printf (file, "%sinstruction_address cia;\n",
+ options.module.global.prefix.l);
}
lf_printf (file, "int current_cpu = next_cpu_nr;\n");
-
+
if (options.gen.icache)
{
lf_printf (file, "/* flush the icache of a possible break insn */\n");
@@ -93,10 +93,10 @@ print_run_body (lf *file,
lf_printf (file, " cpu_flush_icache (STATE_CPU (sd, cpu_nr));\n");
lf_printf (file, "}\n");
}
-
+
if (!options.gen.smp)
{
-
+
lf_putstr (file, "\
/* CASE 1: NO SMP (with or with out instruction cache).\n\
\n\
@@ -124,16 +124,16 @@ cache. */\n\
lf_putstr (file, "while (1)\n");
lf_putstr (file, " {\n");
lf_indent (file, +4);
-
+
lf_printf (file, "%sinstruction_address nia;\n",
options.module.global.prefix.l);
lf_printf (file, "\n");
if (!options.gen.icache)
{
- lf_printf (file, "%sinstruction_word instruction_0 = IMEM%d (cia);\n",
- options.module.global.prefix.l,
- options.insn_bit_size);
+ lf_printf (file,
+ "%sinstruction_word instruction_0 = IMEM%d (cia);\n",
+ options.module.global.prefix.l, options.insn_bit_size);
print_engine_issue_prefix_hook (file);
print_idecode_body (file, table, "nia = ");
print_engine_issue_postfix_hook (file);
@@ -146,7 +146,8 @@ cache. */\n\
lf_putstr (file, " {\n");
lf_indent (file, -4);
lf_putstr (file, "/* cache hit */\n");
- lf_putstr (file, "idecode_semantic *const semantic = cache_entry->semantic;\n");
+ lf_putstr (file,
+ "idecode_semantic *const semantic = cache_entry->semantic;\n");
lf_putstr (file, "cia = semantic (cpu, cache_entry, cia);\n");
/* tail */
lf_indent (file, -4);
@@ -162,7 +163,8 @@ cache. */\n\
lf_printf (file, "instruction_word instruction = IMEM%d (cia);\n",
options.insn_bit_size);
lf_putstr (file, "if (WITH_MON != 0)\n");
- lf_putstr (file, " mon_event (mon_event_icache_miss, cpu, cia);\n");
+ lf_putstr (file,
+ " mon_event (mon_event_icache_miss, cpu, cia);\n");
if (options.gen.semantic_icache)
{
lf_putstr (file, "{\n");
@@ -183,7 +185,7 @@ cache. */\n\
lf_indent (file, -4);
lf_putstr (file, " }\n");
}
-
+
/* update the cpu if necessary */
switch (options.gen.nia)
{
@@ -210,10 +212,10 @@ cache. */\n\
lf_indent (file, -4);
lf_printf (file, " }\n");
}
-
+
if (options.gen.smp)
{
-
+
lf_putstr (file, "\
/* CASE 2: SMP (With or without ICACHE)\n\
\n\
@@ -223,9 +225,10 @@ cpu1 will normally be the next cpu that is run. Cpu0 being restarted\n\
after all the other CPU's and the event queue have been processed */\n\
\n\
");
-
+
lf_putstr (file, "\n");
- lf_printf (file, "/* have ensured that the event queue is NOT next */\n");
+ lf_printf (file,
+ "/* have ensured that the event queue is NOT next */\n");
lf_printf (file, "SIM_ASSERT (current_cpu >= 0);\n");
lf_printf (file, "SIM_ASSERT (current_cpu <= nr_cpus - 1);\n");
lf_printf (file, "SIM_ASSERT (nr_cpus <= MAX_NR_PROCESSORS);\n");
@@ -247,7 +250,7 @@ after all the other CPU's and the event queue have been processed */\n\
lf_putstr (file, "CIA_SET (cpu, cia);\n");
print_engine_issue_postfix_hook (file);
}
-
+
if (options.gen.icache)
{
lf_putstr (file, "engine_cache *cache_entry =\n");
@@ -258,8 +261,10 @@ after all the other CPU's and the event queue have been processed */\n\
lf_indent (file, +2);
lf_putstr (file, "\n");
lf_putstr (file, "/* cache hit */\n");
- lf_putstr (file, "engine_semantic *semantic = cache_entry->semantic;\n");
- lf_putstr (file, "cia = semantic(processor, cache_entry, cia);\n");
+ lf_putstr (file,
+ "engine_semantic *semantic = cache_entry->semantic;\n");
+ lf_putstr (file,
+ "cia = semantic(processor, cache_entry, cia);\n");
/* tail */
lf_putstr (file, "cpu_set_program_counter(processor, cia);\n");
lf_putstr (file, "\n");
@@ -278,13 +283,14 @@ after all the other CPU's and the event queue have been processed */\n\
lf_printf (file, "instruction_word instruction = IMEM%d (cia);\n",
options.insn_bit_size);
lf_putstr (file, "if (WITH_MON != 0)\n");
- lf_putstr (file, " mon_event(mon_event_icache_miss, processors[current_cpu], cia);\n");
+ lf_putstr (file,
+ " mon_event(mon_event_icache_miss, processors[current_cpu], cia);\n");
if (options.gen.semantic_icache)
{
lf_putstr (file, "{\n");
lf_indent (file, +2);
print_engine_issue_prefix_hook (file);
- print_idecode_body(file, table, "cia =");
+ print_idecode_body (file, table, "cia =");
print_engine_issue_postfix_hook (file);
lf_indent (file, -2);
lf_putstr (file, "}\n");
@@ -292,8 +298,9 @@ after all the other CPU's and the event queue have been processed */\n\
else
{
print_engine_issue_prefix_hook (file);
- print_idecode_body(file, table, "semantic = ");
- lf_putstr (file, "cia = semantic(processor, cache_entry, cia);\n");
+ print_idecode_body (file, table, "semantic = ");
+ lf_putstr (file,
+ "cia = semantic(processor, cache_entry, cia);\n");
print_engine_issue_postfix_hook (file);
}
/* tail */
@@ -303,7 +310,7 @@ after all the other CPU's and the event queue have been processed */\n\
}
lf_putstr (file, "}\n");
}
-
+
lf_putstr (file, "\n");
lf_putstr (file, "current_cpu += 1;\n");
lf_putstr (file, "if (current_cpu == nr_cpus)\n");
@@ -314,13 +321,13 @@ after all the other CPU's and the event queue have been processed */\n\
lf_putstr (file, " }\n");
lf_putstr (file, " current_cpu = 0;\n");
lf_putstr (file, " }\n");
-
+
/* tail */
lf_indent (file, -4);
lf_putstr (file, " }\n");
}
-
-
+
+
lf_indent (file, -2);
lf_putstr (file, "}\n");
}
@@ -330,8 +337,7 @@ after all the other CPU's and the event queue have been processed */\n\
#if 0
static void
-print_jump (lf *file,
- int is_tail)
+print_jump (lf *file, int is_tail)
{
if (!options.gen.smp)
{
@@ -342,7 +348,7 @@ print_jump (lf *file,
lf_putstr (file, " }\n");
lf_putstr (file, "}\n");
}
-
+
if (options.gen.smp)
{
if (is_tail)
@@ -359,7 +365,7 @@ print_jump (lf *file,
lf_putstr (file, "processor = processors[current_cpu];\n");
lf_putstr (file, "nia = cpu_get_program_counter(processor);\n");
}
-
+
if (options.gen.icache)
{
lf_putstr (file, "cache_entry = cpu_icache_entry(processor, nia);\n");
@@ -367,16 +373,17 @@ print_jump (lf *file,
lf_putstr (file, " /* cache hit */\n");
lf_putstr (file, " goto *cache_entry->semantic;\n");
lf_putstr (file, "}\n");
- if (is_tail) {
- lf_putstr (file, "goto cache_miss;\n");
- }
+ if (is_tail)
+ {
+ lf_putstr (file, "goto cache_miss;\n");
+ }
}
-
+
if (!options.gen.icache && is_tail)
{
lf_printf (file, "goto engine;\n");
}
-
+
}
#endif
@@ -384,10 +391,9 @@ print_jump (lf *file,
#if 0
static void
print_jump_insn (lf *file,
- insn_entry *instruction,
+ insn_entry * instruction,
opcode_bits *expanded_bits,
- opcode_field *opcodes,
- cache_entry *cache_rules)
+ opcode_field *opcodes, cache_entry *cache_rules)
{
insn_opcodes opcode_path;
@@ -398,9 +404,8 @@ print_jump_insn (lf *file,
lf_printf (file, "\n");
print_my_defines (file,
instruction->name,
- instruction->format_name,
- expanded_bits);
-
+ instruction->format_name, expanded_bits);
+
/* output the icache entry */
if (options.gen.icache)
{
@@ -409,24 +414,18 @@ print_jump_insn (lf *file,
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- expanded_bits,
- function_name_prefix_icache);
+ NULL, expanded_bits, function_name_prefix_icache);
lf_printf (file, ":\n");
lf_indent (file, +1);
lf_printf (file, "{\n");
lf_indent (file, +2);
lf_putstr (file, "const unsigned_word cia = nia;\n");
- print_itrace (file, instruction, 1/*putting-value-in-cache*/);
+ print_itrace (file, instruction, 1 /*putting-value-in-cache */ );
print_idecode_validate (file, instruction, &opcode_path);
lf_printf (file, "\n");
lf_printf (file, "{\n");
lf_indent (file, +2);
- print_icache_body (file,
- instruction,
- expanded_bits,
- cache_rules,
- 0, /*use_defines*/
+ print_icache_body (file, instruction, expanded_bits, cache_rules, 0, /*use_defines */
put_values_in_icache);
lf_printf (file, "cache_entry->address = nia;\n");
lf_printf (file, "cache_entry->semantic = &&");
@@ -434,16 +433,13 @@ print_jump_insn (lf *file,
instruction->name,
instruction->format_name,
NULL,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, ";\n");
if (options.gen.semantic_icache)
{
print_semantic_body (file,
- instruction,
- expanded_bits,
- &opcode_path);
- print_jump(file, 1/*is-tail*/);
+ instruction, expanded_bits, &opcode_path);
+ print_jump (file, 1 /*is-tail */ );
}
else
{
@@ -452,8 +448,7 @@ print_jump_insn (lf *file,
instruction->name,
instruction->format_name,
NULL,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, "; */\n");
}
lf_indent (file, -2);
@@ -461,16 +456,14 @@ print_jump_insn (lf *file,
lf_indent (file, -2);
lf_printf (file, "}\n");
}
-
+
/* print the semantics */
lf_printf (file, "\n");
lf_indent (file, -1);
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- expanded_bits,
- function_name_prefix_semantics);
+ NULL, expanded_bits, function_name_prefix_semantics);
lf_printf (file, ":\n");
lf_indent (file, +1);
lf_printf (file, "{\n");
@@ -484,12 +477,8 @@ print_jump_insn (lf *file,
? define_variables
: declare_variables),
(options.gen.icache
- ? get_values_from_icache
- : do_not_use_icache));
- print_semantic_body (file,
- instruction,
- expanded_bits,
- &opcode_path);
+ ? get_values_from_icache : do_not_use_icache));
+ print_semantic_body (file, instruction, expanded_bits, &opcode_path);
if (options.gen.direct_access)
print_icache_body (file,
instruction,
@@ -497,9 +486,8 @@ print_jump_insn (lf *file,
cache_rules,
undef_variables,
(options.gen.icache
- ? get_values_from_icache
- : do_not_use_icache));
- print_jump(file, 1/*is tail*/);
+ ? get_values_from_icache : do_not_use_icache));
+ print_jump (file, 1 /*is tail */ );
lf_indent (file, -2);
lf_printf (file, "}\n");
}
@@ -508,18 +496,14 @@ print_jump_insn (lf *file,
#if 0
static void
-print_jump_definition (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+print_jump_definition (lf *file, gen_entry *entry, int depth, void *data)
{
- cache_entry *cache_rules = (cache_entry*)data;
+ cache_entry *cache_rules = (cache_entry *) data;
if (entry->opcode_rule->with_duplicates)
{
ASSERT (entry->nr_insns == 1
&& entry->opcode == NULL
- && entry->parent != NULL
- && entry->parent->opcode != NULL);
+ && entry->parent != NULL && entry->parent->opcode != NULL);
ASSERT (entry->nr_insns == 1
&& entry->opcode == NULL
&& entry->parent != NULL
@@ -527,17 +511,11 @@ print_jump_definition (lf *file,
&& entry->parent->opcode_rule != NULL);
print_jump_insn (file,
entry->insns->insn,
- entry->expanded_bits,
- entry->opcode,
- cache_rules);
+ entry->expanded_bits, entry->opcode, cache_rules);
}
- else
+ else
{
- print_jump_insn (file,
- entry->insns->insn,
- NULL,
- NULL,
- cache_rules);
+ print_jump_insn (file, entry->insns->insn, NULL, NULL, cache_rules);
}
}
#endif
@@ -545,9 +523,7 @@ print_jump_definition (lf *file,
#if 0
static void
-print_jump_internal_function (lf *file,
- function_entry *function,
- void *data)
+print_jump_internal_function (lf *file, function_entry * function, void *data)
{
if (function->is_internal)
{
@@ -580,9 +556,7 @@ print_jump_internal_function (lf *file,
#if 0
static void
print_jump_body (lf *file,
- gen_entry *entry,
- insn_table *isa,
- cache_entry *cache_rules)
+ gen_entry *entry, insn_table *isa, cache_entry *cache_rules)
{
lf_printf (file, "{\n");
lf_indent (file, +2);
@@ -599,10 +573,10 @@ print_jump_body (lf *file,
{
lf_putstr (file, "int current_cpu = -1;\n");
}
-
+
/* all the switches and tables - they know about jumping */
print_idecode_lookups (file, entry, cache_rules);
-
+
/* start the simulation up */
if (options.gen.icache)
{
@@ -613,17 +587,17 @@ print_jump_body (lf *file,
lf_putstr (file, " cpu_flush_icache(processors[cpu_nr]);\n");
lf_putstr (file, "}\n");
}
-
+
lf_putstr (file, "\n");
lf_putstr (file, "psim_set_halt_and_restart(system, &halt, &restart);\n");
-
+
lf_putstr (file, "\n");
lf_putstr (file, "if (setjmp(halt))\n");
lf_putstr (file, " return;\n");
-
+
lf_putstr (file, "\n");
lf_putstr (file, "setjmp(restart);\n");
-
+
lf_putstr (file, "\n");
if (!options.gen.smp)
{
@@ -634,7 +608,7 @@ print_jump_body (lf *file,
{
lf_putstr (file, "current_cpu = psim_last_cpu(system);\n");
}
-
+
if (!options.gen.icache)
{
lf_printf (file, "\n");
@@ -642,36 +616,34 @@ print_jump_body (lf *file,
lf_printf (file, "engine:\n");
lf_indent (file, +1);
}
-
- print_jump(file, 0/*is_tail*/);
-
+
+ print_jump (file, 0 /*is_tail */ );
+
if (options.gen.icache)
{
lf_indent (file, -1);
lf_printf (file, "cache_miss:\n");
lf_indent (file, +1);
}
-
- print_engine_issue_prefix_hook (file);
+
+ print_engine_issue_prefix_hook (file);
lf_putstr (file, "instruction\n");
- lf_putstr (file, " = vm_instruction_map_read(cpu_instruction_map(processor),\n");
+ lf_putstr (file,
+ " = vm_instruction_map_read(cpu_instruction_map(processor),\n");
lf_putstr (file, " processor, nia);\n");
print_engine_issue_prefix_hook (file);
print_idecode_body (file, entry, "/*IGORE*/");
print_engine_issue_postfix_hook (file);
-
+
/* print out a table of all the internals functions */
function_entry_traverse (file, isa->functions,
- print_jump_internal_function,
- NULL);
-
+ print_jump_internal_function, NULL);
+
/* print out a table of all the instructions */
ERROR ("Use the list of semantic functions, not travere_tree");
- gen_entry_traverse_tree (file, entry,
- 1,
- NULL, /* start */
- print_jump_definition, /* leaf */
- NULL, /* end */
+ gen_entry_traverse_tree (file, entry, 1, NULL, /* start */
+ print_jump_definition, /* leaf */
+ NULL, /* end */
cache_rules);
lf_indent (file, -2);
lf_printf (file, "}\n");
@@ -701,11 +673,8 @@ print_engine_run_function_header (lf *file,
lf_printf (file, "void (*");
break;
}
- indent = print_function_name (file,
- "run",
- NULL, /* format name */
- processor,
- NULL, /* expanded bits */
+ indent = print_function_name (file, "run", NULL, /* format name */
+ processor, NULL, /* expanded bits */
function_name_prefix_engine);
switch (decl_type)
{
@@ -742,9 +711,7 @@ print_engine_run_function_header (lf *file,
void
gen_engine_h (lf *file,
- gen_table *gen,
- insn_table *isa,
- cache_entry *cache_rules)
+ gen_table *gen, insn_table *isa, cache_entry *cache_rules)
{
gen_list *entry;
for (entry = gen->tables; entry != NULL; entry = entry->next)
@@ -752,17 +719,14 @@ gen_engine_h (lf *file,
print_engine_run_function_header (file,
(options.gen.multi_sim
? entry->model->name
- : NULL),
- is_function_declaration);
+ : NULL), is_function_declaration);
}
}
void
-gen_engine_c(lf *file,
- gen_table *gen,
- insn_table *isa,
- cache_entry *cache_rules)
+gen_engine_c (lf *file,
+ gen_table *gen, insn_table *isa, cache_entry *cache_rules)
{
gen_list *entry;
/* the intro */
@@ -781,24 +745,22 @@ gen_engine_c(lf *file,
{
case generate_calls:
print_idecode_lookups (file, entry->table, cache_rules);
-
+
/* output the main engine routine */
print_engine_run_function_header (file,
(options.gen.multi_sim
? entry->model->name
- : NULL),
- is_function_definition);
+ : NULL), is_function_definition);
print_run_body (file, entry->table);
break;
-
+
case generate_jumps:
ERROR ("Jumps currently unimplemented");
#if 0
print_engine_run_function_header (file,
entry->processor,
is_function_definition);
- print_jump_body (file, entry->table,
- isa, cache_rules);
+ print_jump_body (file, entry->table, isa, cache_rules);
#endif
break;
}
diff --git a/sim/igen/gen-engine.h b/sim/igen/gen-engine.h
index 14c01a0..8f6c030 100644
--- a/sim/igen/gen-engine.h
+++ b/sim/igen/gen-engine.h
@@ -22,19 +22,10 @@
Boston, MA 02111-1307, USA. */
extern void gen_engine_h
-(lf *file,
- gen_table *gen,
- insn_table *isa,
- cache_entry *cache_rules);
+ (lf *file, gen_table *gen, insn_table *isa, cache_entry *cache_rules);
extern void gen_engine_c
-(lf *file,
- gen_table *gen,
- insn_table *isa,
- cache_entry *cache_rules);
+ (lf *file, gen_table *gen, insn_table *isa, cache_entry *cache_rules);
extern void print_engine_run_function_header
-(lf *file,
- char *processor,
- function_decl_type decl_type);
-
+ (lf *file, char *processor, function_decl_type decl_type);
diff --git a/sim/igen/gen-icache.c b/sim/igen/gen-icache.c
index 3e77af0..693a646 100644
--- a/sim/igen/gen-icache.c
+++ b/sim/igen/gen-icache.c
@@ -47,13 +47,12 @@ print_icache_function_header (lf *file,
int is_function_definition,
int nr_prefetched_words)
{
- lf_printf(file, "\n");
+ lf_printf (file, "\n");
lf_print__function_type_function (file, print_icache_function_type,
"EXTERN_ICACHE", " ");
print_function_name (file,
basename, format_name, NULL,
- expanded_bits,
- function_name_prefix_icache);
+ expanded_bits, function_name_prefix_icache);
lf_printf (file, "\n(");
print_icache_function_formal (file, nr_prefetched_words);
lf_printf (file, ")");
@@ -65,16 +64,15 @@ print_icache_function_header (lf *file,
void
print_icache_declaration (lf *file,
- insn_entry *insn,
+ insn_entry * insn,
opcode_bits *expanded_bits,
- insn_opcodes *opcodes,
- int nr_prefetched_words)
+ insn_opcodes *opcodes, int nr_prefetched_words)
{
print_icache_function_header (file,
insn->name,
insn->format_name,
expanded_bits,
- 0/* is not function definition */,
+ 0 /* is not function definition */ ,
nr_prefetched_words);
}
@@ -99,7 +97,7 @@ print_icache_extraction (lf *file,
char *reason;
ASSERT (format_name != NULL);
ASSERT (entry_name != NULL);
-
+
/* figure out exactly what should be going on here */
switch (cache_type)
{
@@ -129,30 +127,27 @@ print_icache_extraction (lf *file,
{
reason = "cache";
what_to_declare = ((what_to_do & put_values_in_icache)
- ? declare_variables
- : what_to_declare);
+ ? declare_variables : what_to_declare);
}
else
return;
break;
default:
- abort (); /* Bad switch. */
+ abort (); /* Bad switch. */
}
-
+
/* For the type, default to a simple unsigned */
if (entry_type == NULL || strlen (entry_type) == 0)
entry_type = "unsigned";
-
+
/* look through the set of expanded sub fields to see if this field
has been given a constant value */
- for (bits = expanded_bits;
- bits != NULL;
- bits = bits->next)
+ for (bits = expanded_bits; bits != NULL; bits = bits->next)
{
if (bits->field == cur_field)
break;
}
-
+
/* Define a storage area for the cache element */
switch (what_to_declare)
{
@@ -180,8 +175,8 @@ print_icache_extraction (lf *file,
lf_printf (file, "%s const %s UNUSED = ", entry_type, entry_name);
break;
}
-
-
+
+
/* define a value for that storage area as determined by what is in
the cache */
if (bits != NULL
@@ -193,11 +188,11 @@ print_icache_extraction (lf *file,
{
/* The cache rule is specifying what to do with a simple
instruction field.
-
- Because of instruction expansion, the field is either a
- constant value or equal to the specified constant (boolean
- comparison). (The latter indicated by bits->value == 0).
-
+
+ Because of instruction expansion, the field is either a
+ constant value or equal to the specified constant (boolean
+ comparison). (The latter indicated by bits->value == 0).
+
The case of a field not being equal to the specified boolean
value is handled later. */
expression = "constant field";
@@ -226,52 +221,55 @@ print_icache_extraction (lf *file,
"_is_",
strlen ("_is_")) == 0
&& ((bits->opcode->is_boolean
- && ((unsigned) atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
- == bits->opcode->boolean_constant))
+ && ((unsigned)
+ atol (entry_name + strlen (single_insn_field) +
+ strlen ("_is_")) == bits->opcode->boolean_constant))
|| (!bits->opcode->is_boolean)))
{
/* The cache rule defines an entry for the comparison between a
- single instruction field and a constant. The value of the
- comparison in someway matches that of the opcode field that
- was made constant through expansion. */
+ single instruction field and a constant. The value of the
+ comparison in someway matches that of the opcode field that
+ was made constant through expansion. */
expression = "constant compare";
if (bits->opcode->is_boolean)
{
lf_printf (file, "%d /* %s == %d */",
bits->value == 0,
- single_insn_field,
- bits->opcode->boolean_constant);
+ single_insn_field, bits->opcode->boolean_constant);
}
else if (bits->opcode->last < bits->field->last)
{
lf_printf (file, "%d /* %s == %d */",
- (atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
- == (bits->value << (bits->field->last - bits->opcode->last))),
+ (atol
+ (entry_name + strlen (single_insn_field) +
+ strlen ("_is_")) ==
+ (bits->
+ value << (bits->field->last - bits->opcode->last))),
single_insn_field,
- (bits->value << (bits->field->last - bits->opcode->last)));
+ (bits->
+ value << (bits->field->last - bits->opcode->last)));
}
else
{
lf_printf (file, "%d /* %s == %d */",
- (atol (entry_name + strlen (single_insn_field) + strlen ("_is_"))
- == bits->value),
- single_insn_field,
+ (atol
+ (entry_name + strlen (single_insn_field) +
+ strlen ("_is_")) == bits->value), single_insn_field,
bits->value);
}
}
else
{
/* put the field in the local variable, possibly also enter it
- into the cache */
+ into the cache */
expression = "extraction";
/* handle the cache */
if ((what_to_do & get_values_from_icache)
|| (what_to_do & put_values_in_icache))
{
lf_printf (file, "cache_entry->crack.%s.%s",
- format_name,
- entry_name);
- if (what_to_do & put_values_in_icache) /* also put it in the cache? */
+ format_name, entry_name);
+ if (what_to_do & put_values_in_icache) /* also put it in the cache? */
{
lf_printf (file, " = ");
}
@@ -282,10 +280,11 @@ print_icache_extraction (lf *file,
if (cur_field != NULL)
{
if (entry_expression != NULL && strlen (entry_expression) > 0)
- error (line, "Instruction field entry with nonempty expression\n");
- if (cur_field->first == 0 && cur_field->last == options.insn_bit_size - 1)
- lf_printf (file, "(instruction_%d)",
- cur_field->word_nr);
+ error (line,
+ "Instruction field entry with nonempty expression\n");
+ if (cur_field->first == 0
+ && cur_field->last == options.insn_bit_size - 1)
+ lf_printf (file, "(instruction_%d)", cur_field->word_nr);
else if (cur_field->last == options.insn_bit_size - 1)
lf_printf (file, "MASKED%d (instruction_%d, %d, %d)",
options.insn_bit_size,
@@ -305,7 +304,7 @@ print_icache_extraction (lf *file,
}
}
}
-
+
switch (what_to_declare)
{
case define_variables:
@@ -325,12 +324,11 @@ print_icache_extraction (lf *file,
void
print_icache_body (lf *file,
- insn_entry *instruction,
+ insn_entry * instruction,
opcode_bits *expanded_bits,
cache_entry *cache_rules,
icache_decl_type what_to_declare,
- icache_body_type what_to_do,
- int nr_prefetched_words)
+ icache_body_type what_to_do, int nr_prefetched_words)
{
/* extract instruction fields */
lf_printf (file, "/* Extraction: %s\n", instruction->name);
@@ -365,8 +363,8 @@ print_icache_body (lf *file,
}
lf_printf (file, "\n ");
print_insn_words (file, instruction);
- lf_printf(file, " */\n");
-
+ lf_printf (file, " */\n");
+
/* pass zero - fetch from memory any missing instructions.
Some of the instructions will have already been fetched (in the
@@ -387,13 +385,12 @@ print_icache_body (lf *file,
case define_variables:
case declare_variables:
for (word_nr = nr_prefetched_words;
- word_nr < instruction->nr_words;
- word_nr++)
+ word_nr < instruction->nr_words; word_nr++)
{
/* FIXME - should be using print_icache_extraction? */
- lf_printf (file, "%sinstruction_word instruction_%d UNUSED = ",
- options.module.global.prefix.l,
- word_nr);
+ lf_printf (file,
+ "%sinstruction_word instruction_%d UNUSED = ",
+ options.module.global.prefix.l, word_nr);
lf_printf (file, "IMEM%d_IMMED (cia, %d)",
options.insn_bit_size, word_nr);
lf_printf (file, ";\n");
@@ -404,21 +401,17 @@ print_icache_body (lf *file,
/* if putting the instruction words in the cache, define references
for them */
- if (options.gen.insn_in_icache) {
- /* FIXME: is the instruction_word type correct? */
- print_icache_extraction (file,
- instruction->format_name,
- cache_value,
- "insn", /* name */
- "instruction_word", /* type */
- "instruction", /* expression */
- NULL, /* origin */
- NULL, /* line */
- NULL, NULL,
- what_to_declare,
- what_to_do);
- }
- lf_printf(file, "\n");
+ if (options.gen.insn_in_icache)
+ {
+ /* FIXME: is the instruction_word type correct? */
+ print_icache_extraction (file, instruction->format_name, cache_value, "insn", /* name */
+ "instruction_word", /* type */
+ "instruction", /* expression */
+ NULL, /* origin */
+ NULL, /* line */
+ NULL, NULL, what_to_declare, what_to_do);
+ }
+ lf_printf (file, "\n");
/* pass one - process instruction fields.
@@ -426,9 +419,7 @@ print_icache_body (lf *file,
the cache */
{
insn_word_entry *word;
- for (word = instruction->words;
- word != NULL;
- word = word->next)
+ for (word = instruction->words; word != NULL; word = word->next)
{
insn_field_entry *cur_field;
for (cur_field = word->first;
@@ -444,12 +435,12 @@ print_icache_body (lf *file,
overriding the default cache action for an
instruction field */
for (cache_rule = cache_rules;
- cache_rule != NULL;
- cache_rule = cache_rule->next)
+ cache_rule != NULL; cache_rule = cache_rule->next)
{
if (filter_is_subset (instruction->field_names,
cache_rule->original_fields)
- && strcmp (cache_rule->name, cur_field->val_string) == 0)
+ && strcmp (cache_rule->name,
+ cur_field->val_string) == 0)
{
value_type = cache_rule->entry_type;
value_line = cache_rule->line;
@@ -463,19 +454,15 @@ print_icache_body (lf *file,
}
}
/* Define an entry for the field within the
- instruction */
- print_icache_extraction (file,
- instruction->format_name,
- value_type,
- cur_field->val_string, /* name */
- NULL, /* type */
- NULL, /* expression */
- cur_field->val_string, /* insn field */
+ instruction */
+ print_icache_extraction (file, instruction->format_name, value_type, cur_field->val_string, /* name */
+ NULL, /* type */
+ NULL, /* expression */
+ cur_field->val_string, /* insn field */
value_line,
cur_field,
expanded_bits,
- what_to_declare,
- what_to_do);
+ what_to_declare, what_to_do);
}
}
}
@@ -485,29 +472,20 @@ print_icache_body (lf *file,
{
cache_entry *cache_rule;
for (cache_rule = cache_rules;
- cache_rule != NULL;
- cache_rule = cache_rule->next)
+ cache_rule != NULL; cache_rule = cache_rule->next)
{
if (filter_is_subset (instruction->field_names,
cache_rule->original_fields)
- && !filter_is_member (instruction->field_names,
- cache_rule->name))
+ && !filter_is_member (instruction->field_names, cache_rule->name))
{
- char *single_field = filter_next (cache_rule->original_fields, "");
- if (filter_next (cache_rule->original_fields, single_field) != NULL)
+ char *single_field =
+ filter_next (cache_rule->original_fields, "");
+ if (filter_next (cache_rule->original_fields, single_field) !=
+ NULL)
single_field = NULL;
- print_icache_extraction (file,
- instruction->format_name,
- cache_rule->entry_type,
- cache_rule->name,
- cache_rule->type,
- cache_rule->expression,
- single_field,
- cache_rule->line,
- NULL, /* cur_field */
+ print_icache_extraction (file, instruction->format_name, cache_rule->entry_type, cache_rule->name, cache_rule->type, cache_rule->expression, single_field, cache_rule->line, NULL, /* cur_field */
expanded_bits,
- what_to_declare,
- what_to_do);
+ what_to_declare, what_to_do);
}
}
}
@@ -518,7 +496,8 @@ print_icache_body (lf *file,
typedef struct _form_fields form_fields;
-struct _form_fields {
+struct _form_fields
+{
char *name;
filter *fields;
form_fields *next;
@@ -529,134 +508,131 @@ insn_table_cache_fields (insn_table *isa)
{
form_fields *forms = NULL;
insn_entry *insn;
- for (insn = isa->insns;
- insn != NULL;
- insn = insn->next) {
- form_fields **form = &forms;
- while (1)
- {
- if (*form == NULL)
- {
- /* new format name, add it */
- form_fields *new_form = ZALLOC (form_fields);
- new_form->name = insn->format_name;
- filter_add (&new_form->fields, insn->field_names);
- *form = new_form;
- break;
- }
- else if (strcmp ((*form)->name, insn->format_name) == 0)
- {
- /* already present, add field names to the existing list */
- filter_add (&(*form)->fields, insn->field_names);
- break;
- }
- form = &(*form)->next;
- }
- }
+ for (insn = isa->insns; insn != NULL; insn = insn->next)
+ {
+ form_fields **form = &forms;
+ while (1)
+ {
+ if (*form == NULL)
+ {
+ /* new format name, add it */
+ form_fields *new_form = ZALLOC (form_fields);
+ new_form->name = insn->format_name;
+ filter_add (&new_form->fields, insn->field_names);
+ *form = new_form;
+ break;
+ }
+ else if (strcmp ((*form)->name, insn->format_name) == 0)
+ {
+ /* already present, add field names to the existing list */
+ filter_add (&(*form)->fields, insn->field_names);
+ break;
+ }
+ form = &(*form)->next;
+ }
+ }
return forms;
}
extern void
-print_icache_struct (lf *file,
- insn_table *isa,
- cache_entry *cache_rules)
+print_icache_struct (lf *file, insn_table *isa, cache_entry *cache_rules)
{
/* Create a list of all the different instruction formats with their
corresponding field names. */
form_fields *formats = insn_table_cache_fields (isa);
-
+
lf_printf (file, "\n");
lf_printf (file, "#define WITH_%sIDECODE_CACHE_SIZE %d\n",
options.module.global.prefix.u,
(options.gen.icache ? options.gen.icache_size : 0));
lf_printf (file, "\n");
-
+
/* create an instruction cache if being used */
- if (options.gen.icache) {
- lf_printf (file, "typedef struct _%sidecode_cache {\n",
- options.module.global.prefix.l);
- lf_indent (file, +2);
+ if (options.gen.icache)
{
- form_fields *format;
- lf_printf (file, "unsigned_word address;\n");
- lf_printf (file, "void *semantic;\n");
- lf_printf (file, "union {\n");
+ lf_printf (file, "typedef struct _%sidecode_cache {\n",
+ options.module.global.prefix.l);
lf_indent (file, +2);
- for (format = formats;
- format != NULL;
- format = format->next)
- {
- lf_printf (file, "struct {\n");
- lf_indent (file, +2);
+ {
+ form_fields *format;
+ lf_printf (file, "unsigned_word address;\n");
+ lf_printf (file, "void *semantic;\n");
+ lf_printf (file, "union {\n");
+ lf_indent (file, +2);
+ for (format = formats; format != NULL; format = format->next)
{
- cache_entry *cache_rule;
- char *field;
- /* space for any instruction words */
- if (options.gen.insn_in_icache)
- lf_printf (file, "instruction_word insn[%d];\n", isa->max_nr_words);
- /* define an entry for any applicable cache rules */
- for (cache_rule = cache_rules;
- cache_rule != NULL;
- cache_rule = cache_rule->next)
- {
- /* nb - sort of correct - should really check against
- individual instructions */
- if (filter_is_subset (format->fields, cache_rule->original_fields))
- {
- char *memb;
- lf_printf (file, "%s %s;",
- (cache_rule->type == NULL
- ? "unsigned"
- : cache_rule->type),
- cache_rule->name);
- lf_printf (file, " /*");
- for (memb = filter_next (cache_rule->original_fields, "");
- memb != NULL;
- memb = filter_next (cache_rule->original_fields, memb))
- {
- lf_printf (file, " %s", memb);
- }
- lf_printf (file, " */\n");
- }
- }
- /* define an entry for any fields not covered by a cache rule */
- for (field = filter_next (format->fields, "");
- field != NULL;
- field = filter_next (format->fields, field))
- {
- cache_entry *cache_rule;
- int found_rule = 0;
- for (cache_rule = cache_rules;
- cache_rule != NULL;
- cache_rule = cache_rule->next)
- {
- if (strcmp (cache_rule->name, field) == 0)
- {
- found_rule = 1;
- break;
- }
- }
- if (!found_rule)
- lf_printf (file, "unsigned %s; /* default */\n", field);
- }
+ lf_printf (file, "struct {\n");
+ lf_indent (file, +2);
+ {
+ cache_entry *cache_rule;
+ char *field;
+ /* space for any instruction words */
+ if (options.gen.insn_in_icache)
+ lf_printf (file, "instruction_word insn[%d];\n",
+ isa->max_nr_words);
+ /* define an entry for any applicable cache rules */
+ for (cache_rule = cache_rules;
+ cache_rule != NULL; cache_rule = cache_rule->next)
+ {
+ /* nb - sort of correct - should really check against
+ individual instructions */
+ if (filter_is_subset
+ (format->fields, cache_rule->original_fields))
+ {
+ char *memb;
+ lf_printf (file, "%s %s;",
+ (cache_rule->type == NULL
+ ? "unsigned"
+ : cache_rule->type), cache_rule->name);
+ lf_printf (file, " /*");
+ for (memb =
+ filter_next (cache_rule->original_fields, "");
+ memb != NULL;
+ memb =
+ filter_next (cache_rule->original_fields, memb))
+ {
+ lf_printf (file, " %s", memb);
+ }
+ lf_printf (file, " */\n");
+ }
+ }
+ /* define an entry for any fields not covered by a cache rule */
+ for (field = filter_next (format->fields, "");
+ field != NULL; field = filter_next (format->fields, field))
+ {
+ cache_entry *cache_rule;
+ int found_rule = 0;
+ for (cache_rule = cache_rules;
+ cache_rule != NULL; cache_rule = cache_rule->next)
+ {
+ if (strcmp (cache_rule->name, field) == 0)
+ {
+ found_rule = 1;
+ break;
+ }
+ }
+ if (!found_rule)
+ lf_printf (file, "unsigned %s; /* default */\n", field);
+ }
+ }
+ lf_indent (file, -2);
+ lf_printf (file, "} %s;\n", format->name);
}
- lf_indent (file, -2);
- lf_printf (file, "} %s;\n", format->name);
- }
+ lf_indent (file, -2);
+ lf_printf (file, "} crack;\n");
+ }
lf_indent (file, -2);
- lf_printf (file, "} crack;\n");
+ lf_printf (file, "} %sidecode_cache;\n",
+ options.module.global.prefix.l);
}
- lf_indent (file, -2);
- lf_printf (file, "} %sidecode_cache;\n", options.module.global.prefix.l);
- }
else
{
/* alernativly, since no cache, emit a dummy definition for
- idecode_cache so that code refering to the type can still compile */
- lf_printf(file, "typedef void %sidecode_cache;\n",
- options.module.global.prefix.l);
+ idecode_cache so that code refering to the type can still compile */
+ lf_printf (file, "typedef void %sidecode_cache;\n",
+ options.module.global.prefix.l);
}
lf_printf (file, "\n");
}
@@ -665,43 +641,40 @@ print_icache_struct (lf *file,
static void
print_icache_function (lf *file,
- insn_entry *instruction,
+ insn_entry * instruction,
opcode_bits *expanded_bits,
insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words)
+ cache_entry *cache_rules, int nr_prefetched_words)
{
int indent;
/* generate code to enter decoded instruction into the icache */
- lf_printf(file, "\n");
+ lf_printf (file, "\n");
lf_print__function_type_function (file, print_icache_function_type,
"EXTERN_ICACHE", "\n");
indent = print_function_name (file,
instruction->name,
instruction->format_name,
NULL,
- expanded_bits,
- function_name_prefix_icache);
+ expanded_bits, function_name_prefix_icache);
indent += lf_printf (file, " ");
lf_indent (file, +indent);
lf_printf (file, "(");
print_icache_function_formal (file, nr_prefetched_words);
lf_printf (file, ")\n");
lf_indent (file, -indent);
-
+
/* function header */
lf_printf (file, "{\n");
lf_indent (file, +2);
-
+
print_my_defines (file,
instruction->name,
- instruction->format_name,
- expanded_bits);
- print_itrace (file, instruction, 1/*putting-value-in-cache*/);
-
+ instruction->format_name, expanded_bits);
+ print_itrace (file, instruction, 1 /*putting-value-in-cache */ );
+
print_idecode_validate (file, instruction, opcodes);
-
+
lf_printf (file, "\n");
lf_printf (file, "{\n");
lf_indent (file, +2);
@@ -716,30 +689,25 @@ print_icache_function (lf *file,
: declare_variables),
(options.gen.semantic_icache
? both_values_and_icache
- : put_values_in_icache),
- nr_prefetched_words);
-
+ : put_values_in_icache), nr_prefetched_words);
+
lf_printf (file, "\n");
lf_printf (file, "cache_entry->address = cia;\n");
lf_printf (file, "cache_entry->semantic = ");
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- expanded_bits,
- function_name_prefix_semantics);
+ NULL, expanded_bits, function_name_prefix_semantics);
lf_printf (file, ";\n");
lf_printf (file, "\n");
- if (options.gen.semantic_icache) {
- lf_printf (file, "/* semantic routine */\n");
- print_semantic_body (file,
- instruction,
- expanded_bits,
- opcodes);
- lf_printf (file, "return nia;\n");
- }
-
+ if (options.gen.semantic_icache)
+ {
+ lf_printf (file, "/* semantic routine */\n");
+ print_semantic_body (file, instruction, expanded_bits, opcodes);
+ lf_printf (file, "return nia;\n");
+ }
+
if (!options.gen.semantic_icache)
{
lf_printf (file, "/* return the function proper */\n");
@@ -748,11 +716,10 @@ print_icache_function (lf *file,
instruction->name,
instruction->format_name,
NULL,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, ";\n");
}
-
+
if (options.gen.direct_access)
{
print_icache_body (file,
@@ -762,10 +729,9 @@ print_icache_function (lf *file,
undef_variables,
(options.gen.semantic_icache
? both_values_and_icache
- : put_values_in_icache),
- nr_prefetched_words);
+ : put_values_in_icache), nr_prefetched_words);
}
-
+
lf_indent (file, -2);
lf_printf (file, "}\n");
lf_indent (file, -2);
@@ -775,25 +741,22 @@ print_icache_function (lf *file,
void
print_icache_definition (lf *file,
- insn_entry *insn,
+ insn_entry * insn,
opcode_bits *expanded_bits,
insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words)
+ cache_entry *cache_rules, int nr_prefetched_words)
{
print_icache_function (file,
insn,
expanded_bits,
- opcodes,
- cache_rules,
- nr_prefetched_words);
+ opcodes, cache_rules, nr_prefetched_words);
}
void
print_icache_internal_function_declaration (lf *file,
- function_entry *function,
+ function_entry * function,
void *data)
{
ASSERT (options.gen.icache);
@@ -804,10 +767,7 @@ print_icache_internal_function_declaration (lf *file,
"INLINE_ICACHE", "\n");
print_function_name (file,
function->name,
- NULL,
- NULL,
- NULL,
- function_name_prefix_icache);
+ NULL, NULL, NULL, function_name_prefix_icache);
lf_printf (file, "\n(");
print_icache_function_formal (file, 0);
lf_printf (file, ");\n");
@@ -817,7 +777,7 @@ print_icache_internal_function_declaration (lf *file,
void
print_icache_internal_function_definition (lf *file,
- function_entry *function,
+ function_entry * function,
void *data)
{
ASSERT (options.gen.icache);
@@ -828,10 +788,7 @@ print_icache_internal_function_definition (lf *file,
"INLINE_ICACHE", "\n");
print_function_name (file,
function->name,
- NULL,
- NULL,
- NULL,
- function_name_prefix_icache);
+ NULL, NULL, NULL, function_name_prefix_icache);
lf_printf (file, "\n(");
print_icache_function_formal (file, 0);
lf_printf (file, ")\n");
@@ -842,7 +799,8 @@ print_icache_internal_function_definition (lf *file,
{
lf_print__line_ref (file, function->code->line);
table_print_code (file, function->code);
- lf_printf (file, "error (\"Internal function must longjump\\n\");\n");
+ lf_printf (file,
+ "error (\"Internal function must longjump\\n\");\n");
lf_printf (file, "return 0;\n");
}
else
@@ -851,12 +809,10 @@ print_icache_internal_function_definition (lf *file,
print_function_name (file,
function->name,
NULL,
- NULL,
- NULL,
- function_name_prefix_semantics);
+ NULL, NULL, function_name_prefix_semantics);
lf_printf (file, ";\n");
}
-
+
lf_print__internal_ref (file);
lf_indent (file, -2);
lf_printf (file, "}\n");
diff --git a/sim/igen/gen-icache.h b/sim/igen/gen-icache.h
index 7940e37..e2eec43 100644
--- a/sim/igen/gen-icache.h
+++ b/sim/igen/gen-icache.h
@@ -25,45 +25,45 @@
/* Output code to manipulate the instruction cache: either create it
or reference it */
-typedef enum {
+typedef enum
+{
declare_variables,
define_variables,
undef_variables,
-} icache_decl_type;
+}
+icache_decl_type;
-typedef enum {
+typedef enum
+{
do_not_use_icache = 0,
get_values_from_icache = 0x1,
put_values_in_icache = 0x2,
both_values_and_icache = 0x3,
-} icache_body_type;
+}
+icache_body_type;
extern void print_icache_body
-(lf *file,
- insn_entry *instruction,
- opcode_bits *expanded_bits,
- cache_entry *cache_rules,
- icache_decl_type what_to_declare,
- icache_body_type what_to_do,
- int nr_prefetched_words);
+ (lf *file,
+ insn_entry * instruction,
+ opcode_bits *expanded_bits,
+ cache_entry *cache_rules,
+ icache_decl_type what_to_declare,
+ icache_body_type what_to_do, int nr_prefetched_words);
/* Output an instruction cache decode function */
extern void print_icache_declaration
-(lf *file,
- insn_entry *insn,
- opcode_bits *expanded_bits,
- insn_opcodes *opcodes,
- int nr_prefetched_words);
-
+ (lf *file,
+ insn_entry * insn,
+ opcode_bits *expanded_bits,
+ insn_opcodes *opcodes, int nr_prefetched_words);
+
extern void print_icache_definition
-(lf *file,
- insn_entry *insn,
- opcode_bits *expanded_bits,
- insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words);
+ (lf *file,
+ insn_entry * insn,
+ opcode_bits *expanded_bits,
+ insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words);
/* Output an instruction cache support function */
@@ -75,9 +75,7 @@ extern function_entry_handler print_icache_internal_function_definition;
/* Output the instruction cache table data structure */
extern void print_icache_struct
-(lf *file,
- insn_table *instructions,
- cache_entry *cache_rules);
+ (lf *file, insn_table *instructions, cache_entry *cache_rules);
/* Output a single instructions decoder */
diff --git a/sim/igen/gen-idecode.c b/sim/igen/gen-idecode.c
index d15d701..639b563 100644
--- a/sim/igen/gen-idecode.c
+++ b/sim/igen/gen-idecode.c
@@ -40,18 +40,17 @@
static void
-lf_print_opcodes (lf *file,
- gen_entry *table)
+lf_print_opcodes (lf *file, gen_entry *table)
{
- if (table != NULL)
+ if (table !=NULL)
{
while (1)
{
ASSERT (table->opcode != NULL);
lf_printf (file, "_%d_%d",
- table->opcode->first,
- table->opcode->last);
- if (table->parent == NULL) break;
+ table->opcode->first, table->opcode->last);
+ if (table->parent == NULL)
+ break;
lf_printf (file, "__%d", table->opcode_nr);
table = table->parent;
}
@@ -68,12 +67,12 @@ print_idecode_ifetch (lf *file,
{
int word_nr;
for (word_nr = previous_nr_prefetched_words;
- word_nr < current_nr_prefetched_words;
- word_nr ++)
+ word_nr < current_nr_prefetched_words; word_nr++)
{
- lf_printf (file, "instruction_word instruction_%d = IMEM%d_IMMED (cia, %d);\n",
+ lf_printf (file,
+ "instruction_word instruction_%d = IMEM%d_IMMED (cia, %d);\n",
word_nr, options.insn_bit_size, word_nr);
-
+
}
}
@@ -83,8 +82,7 @@ print_idecode_ifetch (lf *file,
static void
-lf_print_table_name (lf *file,
- gen_entry *table)
+lf_print_table_name (lf *file, gen_entry *table)
{
lf_printf (file, "idecode_table");
lf_print_opcodes (file, table);
@@ -93,9 +91,7 @@ lf_print_table_name (lf *file,
static void
-print_idecode_table (lf *file,
- gen_entry *entry,
- const char *result)
+print_idecode_table (lf *file, gen_entry *entry, const char *result)
{
lf_printf (file, "/* prime the search */\n");
lf_printf (file, "idecode_table_entry *table = ");
@@ -106,7 +102,7 @@ print_idecode_table (lf *file,
i2target (options.hi_bit_nr, entry->opcode->first),
i2target (options.hi_bit_nr, entry->opcode->last));
lf_printf (file, "idecode_table_entry *table_entry = table + opcode;\n");
-
+
lf_printf (file, "\n");
lf_printf (file, "/* iterate until a leaf */\n");
lf_printf (file, "while (1) {\n");
@@ -129,7 +125,7 @@ print_idecode_table (lf *file,
lf_printf (file, " table_entry = table + opcode;\n");
lf_printf (file, " }\n");
lf_printf (file, "}\n");
-
+
lf_printf (file, "\n");
lf_printf (file, "/* call the leaf code */\n");
if (options.gen.code == generate_jumps)
@@ -141,14 +137,16 @@ print_idecode_table (lf *file,
lf_printf (file, "%s ", result);
if (options.gen.icache)
{
- lf_printf (file, "(((idecode_icache*)table_entry->function_or_table)\n");
+ lf_printf (file,
+ "(((idecode_icache*)table_entry->function_or_table)\n");
lf_printf (file, " (");
print_icache_function_actual (file, 1);
lf_printf (file, "));\n");
}
else
{
- lf_printf (file, "((idecode_semantic*)table_entry->function_or_table)\n");
+ lf_printf (file,
+ "((idecode_semantic*)table_entry->function_or_table)\n");
lf_printf (file, " (");
print_semantic_function_actual (file, 1);
lf_printf (file, ");\n");
@@ -158,10 +156,7 @@ print_idecode_table (lf *file,
static void
-print_idecode_table_start (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+print_idecode_table_start (lf *file, gen_entry *table, int depth, void *data)
{
ASSERT (depth == 0);
/* start of the table */
@@ -175,10 +170,7 @@ print_idecode_table_start (lf *file,
}
static void
-print_idecode_table_leaf (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+print_idecode_table_leaf (lf *file, gen_entry *entry, int depth, void *data)
{
gen_entry *master_entry;
ASSERT (entry->parent != NULL);
@@ -238,9 +230,9 @@ print_idecode_table_leaf (lf *file,
else
{
/* table `calling' another table */
- lf_printf (file, "%d, ", options.insn_bit_size - entry->opcode->last - 1);
- lf_printf (file, "MASK%d(%d,%d), ",
- options.insn_bit_size,
+ lf_printf (file, "%d, ",
+ options.insn_bit_size - entry->opcode->last - 1);
+ lf_printf (file, "MASK%d(%d,%d), ", options.insn_bit_size,
i2target (options.hi_bit_nr, entry->opcode->first),
i2target (options.hi_bit_nr, entry->opcode->last));
lf_printf (file, "0, ");
@@ -251,23 +243,20 @@ print_idecode_table_leaf (lf *file,
}
static void
-print_idecode_table_end (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+print_idecode_table_end (lf *file, gen_entry *table, int depth, void *data)
{
ASSERT (depth == 0);
- if (table->opcode_rule->gen == array_gen) {
- lf_printf (file, "};\n");
- }
+ if (table->opcode_rule->gen == array_gen)
+ {
+ lf_printf (file, "};\n");
+ }
}
/****************************************************************/
static void
-print_goto_switch_name (lf *file,
- gen_entry *entry)
+print_goto_switch_name (lf *file, gen_entry *entry)
{
lf_printf (file, "case_");
if (entry->opcode == NULL)
@@ -283,21 +272,19 @@ print_goto_switch_name (lf *file,
}
else
{
- lf_print_table_name(file, entry);
+ lf_print_table_name (file, entry);
}
}
static void
print_goto_switch_table_leaf (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+ gen_entry *entry, int depth, void *data)
{
ASSERT (entry->parent != NULL);
ASSERT (depth == 0);
ASSERT (entry->parent->opcode_rule->gen == goto_switch_gen);
ASSERT (entry->parent->opcode);
-
+
lf_printf (file, "/* %d */ &&", entry->opcode_nr);
if (entry->combined_parent != NULL)
print_goto_switch_name (file, entry->combined_parent);
@@ -307,8 +294,7 @@ print_goto_switch_table_leaf (lf *file,
}
static void
-print_goto_switch_break (lf *file,
- gen_entry *entry)
+print_goto_switch_break (lf *file, gen_entry *entry)
{
lf_printf (file, "goto break_");
lf_print_table_name (file, entry->parent);
@@ -317,41 +303,31 @@ print_goto_switch_break (lf *file,
static void
-print_goto_switch_table (lf *file,
- gen_entry *table)
+print_goto_switch_table (lf *file, gen_entry *table)
{
lf_printf (file, "const static void *");
lf_print_table_name (file, table);
lf_printf (file, "[] = {\n");
lf_indent (file, +2);
- gen_entry_traverse_tree (file, table,
- 0,
- NULL/*start*/,
- print_goto_switch_table_leaf,
- NULL/*end*/,
- NULL/*data*/);
+ gen_entry_traverse_tree (file, table, 0, NULL /*start */ ,
+ print_goto_switch_table_leaf, NULL /*end */ ,
+ NULL /*data */ );
lf_indent (file, -2);
lf_printf (file, "};\n");
}
-void print_idecode_switch
-(lf *file,
- gen_entry *table,
- const char *result);
+void print_idecode_switch (lf *file, gen_entry *table, const char *result);
static void
-print_idecode_switch_start (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+print_idecode_switch_start (lf *file, gen_entry *table, int depth, void *data)
{
/* const char *result = data; */
ASSERT (depth == 0);
ASSERT (table->opcode_rule->gen == switch_gen
|| table->opcode_rule->gen == goto_switch_gen
|| table->opcode_rule->gen == padded_switch_gen);
-
+
if (table->opcode->is_boolean
|| table->opcode_rule->gen == switch_gen
|| table->opcode_rule->gen == padded_switch_gen)
@@ -393,16 +369,13 @@ print_idecode_switch_start (lf *file,
}
else
{
- ASSERT("bad switch" == NULL);
+ ASSERT ("bad switch" == NULL);
}
}
static void
-print_idecode_switch_leaf (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+print_idecode_switch_leaf (lf *file, gen_entry *entry, int depth, void *data)
{
const char *result = data;
ASSERT (entry->parent != NULL);
@@ -411,19 +384,17 @@ print_idecode_switch_leaf (lf *file,
|| entry->parent->opcode_rule->gen == goto_switch_gen
|| entry->parent->opcode_rule->gen == padded_switch_gen);
ASSERT (entry->parent->opcode);
-
+
/* skip over any instructions combined into another entry */
if (entry->combined_parent != NULL)
return;
- if (entry->parent->opcode->is_boolean
- && entry->opcode_nr == 0)
+ if (entry->parent->opcode->is_boolean && entry->opcode_nr == 0)
{
/* case: boolean false target */
lf_printf (file, "case %d:\n", entry->parent->opcode->boolean_constant);
}
- else if (entry->parent->opcode->is_boolean
- && entry->opcode_nr != 0)
+ else if (entry->parent->opcode->is_boolean && entry->opcode_nr != 0)
{
/* case: boolean true case */
lf_printf (file, "default:\n");
@@ -475,7 +446,9 @@ print_idecode_switch_leaf (lf *file,
if (options.gen.code == generate_calls)
{
lf_printf (file, " (");
- print_semantic_function_actual (file, entry->insns->semantic->nr_prefetched_words);
+ print_semantic_function_actual (file,
+ entry->insns->semantic->
+ nr_prefetched_words);
lf_printf (file, ")");
}
lf_printf (file, ";\n");
@@ -512,7 +485,7 @@ print_idecode_switch_leaf (lf *file,
}
else if (entry->parent->opcode_rule->gen == goto_switch_gen)
{
- print_goto_switch_break(file, entry);
+ print_goto_switch_break (file, entry);
}
else
{
@@ -525,8 +498,7 @@ print_idecode_switch_leaf (lf *file,
static void
-print_idecode_switch_illegal (lf *file,
- const char *result)
+print_idecode_switch_illegal (lf *file, const char *result)
{
lf_indent (file, +2);
print_idecode_invalid (file, result, invalid_illegal);
@@ -535,10 +507,7 @@ print_idecode_switch_illegal (lf *file,
}
static void
-print_idecode_switch_end (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+print_idecode_switch_end (lf *file, gen_entry *table, int depth, void *data)
{
const char *result = data;
ASSERT (depth == 0);
@@ -546,7 +515,7 @@ print_idecode_switch_end (lf *file,
|| table->opcode_rule->gen == goto_switch_gen
|| table->opcode_rule->gen == padded_switch_gen);
ASSERT (table->opcode);
-
+
if (table->opcode->is_boolean)
{
lf_printf (file, "}\n");
@@ -559,7 +528,8 @@ print_idecode_switch_end (lf *file,
lf_indent (file, +2);
if (table->nr_entries == table->opcode->nr_opcodes)
{
- print_sim_engine_abort (file, "Internal error - bad switch generated");
+ print_sim_engine_abort (file,
+ "Internal error - bad switch generated");
lf_printf (file, "%sNULL_CIA;\n", result);
lf_printf (file, "break;\n");
}
@@ -578,7 +548,7 @@ print_idecode_switch_end (lf *file,
lf_printf (file, ":\n");
print_idecode_invalid (file, result, invalid_illegal);
lf_printf (file, "break_");
- lf_print_table_name(file, table);
+ lf_print_table_name (file, table);
lf_printf (file, ":;\n");
if (table->parent != NULL
&& (table->parent->opcode_rule->gen == switch_gen
@@ -597,16 +567,13 @@ print_idecode_switch_end (lf *file,
void
-print_idecode_switch (lf *file,
- gen_entry *table,
- const char *result)
+print_idecode_switch (lf *file, gen_entry *table, const char *result)
{
gen_entry_traverse_tree (file, table,
0,
print_idecode_switch_start,
print_idecode_switch_leaf,
- print_idecode_switch_end,
- (void*)result);
+ print_idecode_switch_end, (void *) result);
}
@@ -657,47 +624,35 @@ print_idecode_switch_function_header (lf *file,
static void
-idecode_declare_if_switch (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+idecode_declare_if_switch (lf *file, gen_entry *table, int depth, void *data)
{
- if ((table->opcode_rule->gen == switch_gen
- || table->opcode_rule->gen == goto_switch_gen
- || table->opcode_rule->gen == padded_switch_gen)
- && table->parent != NULL /* don't declare the top one yet */
+ if ((table->opcode_rule->gen == switch_gen || table->opcode_rule->gen == goto_switch_gen || table->opcode_rule->gen == padded_switch_gen) &&table->parent != NULL /* don't declare the top one yet */
&& table->parent->opcode_rule->gen == array_gen)
{
print_idecode_switch_function_header (file,
table,
- 0/*isnt function definition*/,
+ 0 /*isnt function definition */ ,
0);
}
}
static void
-idecode_expand_if_switch (lf *file,
- gen_entry *table,
- int depth,
- void *data)
+idecode_expand_if_switch (lf *file, gen_entry *table, int depth, void *data)
{
- if ((table->opcode_rule->gen == switch_gen
- || table->opcode_rule->gen == goto_switch_gen
- || table->opcode_rule->gen == padded_switch_gen)
- && table->parent != NULL /* don't expand the top one yet */
+ if ((table->opcode_rule->gen == switch_gen || table->opcode_rule->gen == goto_switch_gen || table->opcode_rule->gen == padded_switch_gen) &&table->parent != NULL /* don't expand the top one yet */
&& table->parent->opcode_rule->gen == array_gen)
{
- print_idecode_switch_function_header(file,
- table,
- 1/*is function definition*/,
- 0);
+ print_idecode_switch_function_header (file,
+ table,
+ 1 /*is function definition */ ,
+ 0);
if (options.gen.code == generate_calls)
{
lf_printf (file, "{\n");
lf_indent (file, +2);
}
- print_idecode_switch(file, table, "return");
+ print_idecode_switch (file, table, "return");
if (options.gen.code == generate_calls)
{
lf_indent (file, -2);
@@ -711,45 +666,32 @@ idecode_expand_if_switch (lf *file,
void
-print_idecode_lookups (lf *file,
- gen_entry *table,
- cache_entry *cache_rules)
+print_idecode_lookups (lf *file, gen_entry *table, cache_entry *cache_rules)
{
int depth;
-
+
/* output switch function declarations where needed by tables */
- gen_entry_traverse_tree (file, table,
- 1,
- idecode_declare_if_switch, /* START */
- NULL, NULL,
- NULL);
-
+ gen_entry_traverse_tree (file, table, 1, idecode_declare_if_switch, /* START */
+ NULL, NULL, NULL);
+
/* output tables where needed */
- for (depth = gen_entry_depth (table);
- depth > 0;
- depth--)
+ for (depth = gen_entry_depth (table); depth > 0; depth--)
{
gen_entry_traverse_tree (file, table,
- 1-depth,
+ 1 - depth,
print_idecode_table_start,
print_idecode_table_leaf,
- print_idecode_table_end,
- NULL);
+ print_idecode_table_end, NULL);
}
-
+
/* output switch functions where needed */
- gen_entry_traverse_tree (file, table,
- 1,
- idecode_expand_if_switch, /* START */
- NULL, NULL,
- NULL);
+ gen_entry_traverse_tree (file, table, 1, idecode_expand_if_switch, /* START */
+ NULL, NULL, NULL);
}
void
-print_idecode_body (lf *file,
- gen_entry *table,
- const char *result)
+print_idecode_body (lf *file, gen_entry *table, const char *result)
{
if (table->opcode_rule->gen == switch_gen
|| table->opcode_rule->gen == goto_switch_gen
@@ -768,15 +710,14 @@ print_idecode_body (lf *file,
#if 0
static void
-print_jump (lf *file,
- int is_tail)
+print_jump (lf *file, int is_tail)
{
if (is_tail)
{
lf_putstr (file, "if (keep_running != NULL && !*keep_running)\n");
lf_putstr (file, " cpu_halt(cpu, nia, was_continuing, 0/*na*/);\n");
}
-
+
if (!options.generate_smp)
{
lf_putstr (file, "if (WITH_EVENTS) {\n");
@@ -787,7 +728,7 @@ print_jump (lf *file,
lf_putstr (file, " }\n");
lf_putstr (file, "}\n");
}
-
+
if (options.generate_smp)
{
if (is_tail)
@@ -809,7 +750,7 @@ print_jump (lf *file,
lf_putstr (file, "cpu = cpus[current_cpu];\n");
lf_putstr (file, "nia = cpu_get_program_counter(cpu);\n");
}
-
+
if (options.gen.icache)
{
lf_putstr (file, "cache_entry = cpu_icache_entry(cpu, nia);\n");
@@ -827,7 +768,7 @@ print_jump (lf *file,
{
lf_printf (file, "goto idecode;\n");
}
-
+
}
#endif
@@ -836,16 +777,15 @@ print_jump (lf *file,
#if 0
static void
print_jump_insn (lf *file,
- insn_entry *instruction,
- insn_bits *expanded_bits,
- opcode_field *opcodes,
- cache_entry *cache_rules)
+ insn_entry * instruction,
+ insn_bits * expanded_bits,
+ opcode_field *opcodes, cache_entry *cache_rules)
{
-
+
/* what we are for the moment */
lf_printf (file, "\n");
print_my_defines (file, expanded_bits, instruction->name);
-
+
/* output the icache entry */
if (options.gen.icache)
{
@@ -853,46 +793,36 @@ print_jump_insn (lf *file,
lf_indent (file, -1);
print_function_name (file,
instruction->name,
- expanded_bits,
- function_name_prefix_icache);
+ expanded_bits, function_name_prefix_icache);
lf_printf (file, ":\n");
lf_indent (file, +1);
lf_printf (file, "{\n");
lf_indent (file, +2);
lf_putstr (file, "const unsigned_word cia = nia;\n");
- print_itrace (file, instruction, 1/*putting-value-in-cache*/);
+ print_itrace (file, instruction, 1 /*putting-value-in-cache */ );
print_idecode_validate (file, instruction, opcodes);
lf_printf (file, "\n");
lf_printf (file, "{\n");
lf_indent (file, +2);
- print_icache_body (file,
- instruction,
- expanded_bits,
- cache_rules,
- 0, /*use_defines*/
+ print_icache_body (file, instruction, expanded_bits, cache_rules, 0, /*use_defines */
put_values_in_icache);
lf_printf (file, "cache_entry->address = nia;\n");
lf_printf (file, "cache_entry->semantic = &&");
print_function_name (file,
instruction->name,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, ";\n");
if (options.gen.semantic_icache)
{
- print_semantic_body (file,
- instruction,
- expanded_bits,
- opcodes);
- print_jump (file, 1/*is-tail*/);
+ print_semantic_body (file, instruction, expanded_bits, opcodes);
+ print_jump (file, 1 /*is-tail */ );
}
else
{
lf_printf (file, "/* goto ");
print_function_name (file,
instruction->name,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, "; */\n");
}
lf_indent (file, -2);
@@ -900,14 +830,13 @@ print_jump_insn (lf *file,
lf_indent (file, -2);
lf_printf (file, "}\n");
}
-
+
/* print the semantics */
lf_printf (file, "\n");
lf_indent (file, -1);
print_function_name (file,
instruction->name,
- expanded_bits,
- function_name_prefix_semantics);
+ expanded_bits, function_name_prefix_semantics);
lf_printf (file, ":\n");
lf_indent (file, +1);
lf_printf (file, "{\n");
@@ -921,12 +850,8 @@ print_jump_insn (lf *file,
? define_variables
: declare_variables),
(options.gen.icache
- ? get_values_from_icache
- : do_not_use_icache));
- print_semantic_body (file,
- instruction,
- expanded_bits,
- opcodes);
+ ? get_values_from_icache : do_not_use_icache));
+ print_semantic_body (file, instruction, expanded_bits, opcodes);
if (options.gen.direct_access)
print_icache_body (file,
instruction,
@@ -934,9 +859,8 @@ print_jump_insn (lf *file,
cache_rules,
undef_variables,
(options.gen.icache
- ? get_values_from_icache
- : do_not_use_icache));
- print_jump (file, 1/*is tail*/);
+ ? get_values_from_icache : do_not_use_icache));
+ print_jump (file, 1 /*is tail */ );
lf_indent (file, -2);
lf_printf (file, "}\n");
}
@@ -947,17 +871,14 @@ print_jump_insn (lf *file,
static void
print_jump_definition (lf *file,
gen_entry *entry,
- insn_entry *insn,
- int depth,
- void *data)
+ insn_entry * insn, int depth, void *data)
{
- cache_entry *cache_rules = (cache_entry*)data;
+ cache_entry *cache_rules = (cache_entry *) data;
if (options.generate_expanded_instructions)
{
ASSERT (entry->nr_insns == 1
&& entry->opcode == NULL
- && entry->parent != NULL
- && entry->parent->opcode != NULL);
+ && entry->parent != NULL && entry->parent->opcode != NULL);
ASSERT (entry->nr_insns == 1
&& entry->opcode == NULL
&& entry->parent != NULL
@@ -965,17 +886,12 @@ print_jump_definition (lf *file,
&& entry->parent->opcode_rule != NULL);
print_jump_insn (file,
entry->insns->words[0]->insn,
- entry->expanded_bits,
- entry->opcode,
- cache_rules);
+ entry->expanded_bits, entry->opcode, cache_rules);
}
else
{
print_jump_insn (file,
- instruction->words[0]->insn,
- NULL,
- NULL,
- cache_rules);
+ instruction->words[0]->insn, NULL, NULL, cache_rules);
}
}
#endif
@@ -984,8 +900,7 @@ print_jump_definition (lf *file,
static void
print_jump_internal_function (lf *file,
gen_entry *table,
- function_entry *function,
- void *data)
+ function_entry * function, void *data)
{
if (function->is_internal)
{
@@ -1016,9 +931,8 @@ print_jump_internal_function (lf *file,
#if 0
static void
-print_jump_until_stop_body(lf *file,
- insn_table *table,
- cache_table *cache_rules)
+print_jump_until_stop_body (lf *file,
+ insn_table *table, cache_table * cache_rules)
{
lf_printf (file, "{\n");
lf_indent (file, +2);
@@ -1027,25 +941,28 @@ print_jump_until_stop_body(lf *file,
lf_putstr (file, "sim_cpu *cpu = NULL;\n");
lf_putstr (file, "unsigned_word nia = -1;\n");
lf_putstr (file, "instruction_word instruction = 0;\n");
- if ((code & generate_with_icache)) {
- lf_putstr (file, "idecode_cache *cache_entry = NULL;\n");
- }
- if (generate_smp) {
- lf_putstr (file, "int current_cpu = -1;\n");
- }
+ if ((code & generate_with_icache))
+ {
+ lf_putstr (file, "idecode_cache *cache_entry = NULL;\n");
+ }
+ if (generate_smp)
+ {
+ lf_putstr (file, "int current_cpu = -1;\n");
+ }
/* all the switches and tables - they know about jumping */
- print_idecode_lookups(file, table, cache_rules);
-
+ print_idecode_lookups (file, table, cache_rules);
+
/* start the simulation up */
- if ((code & generate_with_icache)) {
- lf_putstr (file, "\n");
- lf_putstr (file, "{\n");
- lf_putstr (file, " int cpu_nr;\n");
- lf_putstr (file, " for (cpu_nr = 0; cpu_nr < nr_cpus; cpu_nr++)\n");
- lf_putstr (file, " cpu_flush_icache(cpus[cpu_nr]);\n");
- lf_putstr (file, "}\n");
- }
+ if ((code & generate_with_icache))
+ {
+ lf_putstr (file, "\n");
+ lf_putstr (file, "{\n");
+ lf_putstr (file, " int cpu_nr;\n");
+ lf_putstr (file, " for (cpu_nr = 0; cpu_nr < nr_cpus; cpu_nr++)\n");
+ lf_putstr (file, " cpu_flush_icache(cpus[cpu_nr]);\n");
+ lf_putstr (file, "}\n");
+ }
lf_putstr (file, "\n");
lf_putstr (file, "psim_set_halt_and_restart(system, &halt, &restart);\n");
@@ -1058,52 +975,51 @@ print_jump_until_stop_body(lf *file,
lf_putstr (file, "setjmp(restart);\n");
lf_putstr (file, "\n");
- if (!generate_smp) {
- lf_putstr (file, "cpu = cpus[0];\n");
- lf_putstr (file, "nia = cpu_get_program_counter(cpu);\n");
- }
- else {
- lf_putstr (file, "current_cpu = psim_last_cpu(system);\n");
- }
+ if (!generate_smp)
+ {
+ lf_putstr (file, "cpu = cpus[0];\n");
+ lf_putstr (file, "nia = cpu_get_program_counter(cpu);\n");
+ }
+ else
+ {
+ lf_putstr (file, "current_cpu = psim_last_cpu(system);\n");
+ }
- if (!(code & generate_with_icache)) {
- lf_printf (file, "\n");
- lf_indent (file, -1);
- lf_printf (file, "idecode:\n");
- lf_indent (file, +1);
- }
+ if (!(code & generate_with_icache))
+ {
+ lf_printf (file, "\n");
+ lf_indent (file, -1);
+ lf_printf (file, "idecode:\n");
+ lf_indent (file, +1);
+ }
- print_jump(file, 0/*is_tail*/);
+ print_jump (file, 0 /*is_tail */ );
- if ((code & generate_with_icache)) {
- lf_indent (file, -1);
- lf_printf (file, "cache_miss:\n");
- lf_indent (file, +1);
- }
+ if ((code & generate_with_icache))
+ {
+ lf_indent (file, -1);
+ lf_printf (file, "cache_miss:\n");
+ lf_indent (file, +1);
+ }
lf_putstr (file, "instruction\n");
lf_putstr (file, " = vm_instruction_map_read(cpu_instruction_map(cpu),\n");
lf_putstr (file, " cpu, nia);\n");
- print_idecode_body(file, table, "/*IGORE*/");
+ print_idecode_body (file, table, "/*IGORE*/");
/* print out a table of all the internals functions */
- insn_table_traverse_function(table,
- file, NULL,
- print_jump_internal_function);
+ insn_table_traverse_function (table,
+ file, NULL, print_jump_internal_function);
- /* print out a table of all the instructions */
+ /* print out a table of all the instructions */
if (generate_expanded_instructions)
- insn_table_traverse_tree(table,
- file, cache_rules,
- 1,
- NULL, /* start */
- print_jump_definition, /* leaf */
- NULL, /* end */
- NULL); /* padding */
+ insn_table_traverse_tree (table, file, cache_rules, 1, NULL, /* start */
+ print_jump_definition, /* leaf */
+ NULL, /* end */
+ NULL); /* padding */
else
- insn_table_traverse_insn(table,
- file, cache_rules,
- print_jump_definition);
+ insn_table_traverse_insn (table,
+ file, cache_rules, print_jump_definition);
lf_indent (file, -2);
lf_printf (file, "}\n");
}
@@ -1120,8 +1036,7 @@ print_jump_until_stop_body(lf *file,
void
print_idecode_validate (lf *file,
- insn_entry *instruction,
- insn_opcodes *opcode_paths)
+ insn_entry * instruction, insn_opcodes *opcode_paths)
{
/* Validate: unchecked instruction fields
@@ -1154,27 +1069,24 @@ print_idecode_validate (lf *file,
/* Make space for the next bit */
check_mask <<= 1;
check_val <<= 1;
-
+
/* Only need to validate constant (and reserved)
- bits. Skip any others */
+ bits. Skip any others */
if (field->type != insn_field_int
&& field->type != insn_field_reserved)
continue;
/* Look through the list of opcode paths that lead to this
- instruction. See if any have failed to check the
- relevant bit */
+ instruction. See if any have failed to check the
+ relevant bit */
if (opcode_paths != NULL)
{
insn_opcodes *entry;
- for (entry = opcode_paths;
- entry != NULL;
- entry = entry->next)
+ for (entry = opcode_paths; entry != NULL; entry = entry->next)
{
opcode_field *opcode;
for (opcode = entry->opcode;
- opcode != NULL;
- opcode = opcode->parent)
+ opcode != NULL; opcode = opcode->parent)
{
if (opcode->word_nr == word_nr
&& opcode->first <= bit_nr
@@ -1188,14 +1100,14 @@ print_idecode_validate (lf *file,
}
if (entry == NULL)
/* all the opcode paths decoded on BIT_NR, no need
- to check it */
+ to check it */
continue;
}
-
+
check_mask |= 1;
check_val |= bit->value;
}
-
+
/* if any bits not checked by opcode tables, output code to check them */
if (check_mask)
{
@@ -1205,23 +1117,23 @@ print_idecode_validate (lf *file,
lf_printf (file, " {\n");
lf_indent (file, +4);
}
- nr_checks ++;
+ nr_checks++;
if (options.insn_bit_size > 32)
{
- lf_printf (file, "if ((instruction_%d\n", word_nr);
+ lf_printf (file, "if ((instruction_%d\n", word_nr);
lf_printf (file, " & UNSIGNED64 (0x%08lx%08lx))\n",
- (unsigned long)(check_mask >> 32),
- (unsigned long)(check_mask));
+ (unsigned long) (check_mask >> 32),
+ (unsigned long) (check_mask));
lf_printf (file, " != UNSIGNED64 (0x%08lx%08lx))\n",
- (unsigned long)(check_val >> 32),
- (unsigned long)(check_val));
+ (unsigned long) (check_val >> 32),
+ (unsigned long) (check_val));
}
else
{
- lf_printf (file, "if ((instruction_%d & 0x%08lx) != 0x%08lx)\n",
- word_nr,
- (unsigned long)(check_mask),
- (unsigned long)(check_val));
+ lf_printf (file,
+ "if ((instruction_%d & 0x%08lx) != 0x%08lx)\n",
+ word_nr, (unsigned long) (check_mask),
+ (unsigned long) (check_val));
}
lf_indent (file, +2);
print_idecode_invalid (file, "return", invalid_illegal);
@@ -1233,12 +1145,12 @@ print_idecode_validate (lf *file,
lf_indent (file, -4);
lf_printf (file, " }\n");
}
- lf_indent_suppress(file);
+ lf_indent_suppress (file);
lf_printf (file, "#endif\n");
}
/* Validate: Floating Point hardware
-
+
If the simulator is being built with out floating point hardware
(different to it being disabled in the MSR) then floating point
instructions are invalid */
@@ -1249,7 +1161,8 @@ print_idecode_validate (lf *file,
lf_indent_suppress (file);
lf_printf (file, "#if defined(CURRENT_FLOATING_POINT)\n");
lf_printf (file, "/* Validate: FP hardware exists */\n");
- lf_printf (file, "if (CURRENT_FLOATING_POINT != HARD_FLOATING_POINT) {\n");
+ lf_printf (file,
+ "if (CURRENT_FLOATING_POINT != HARD_FLOATING_POINT) {\n");
lf_indent (file, +2);
print_idecode_invalid (file, "return", invalid_illegal);
lf_indent (file, -2);
@@ -1277,14 +1190,14 @@ print_idecode_validate (lf *file,
lf_printf (file, "/* Validate: FP available according to cpu */\n");
lf_printf (file, "if (!IS_FP_AVAILABLE) {\n");
lf_indent (file, +2);
- print_idecode_invalid (file, "return", invalid_fp_unavailable);
+ print_idecode_invalid (file, "return", invalid_fp_unavailable);
lf_indent (file, -2);
lf_printf (file, "}\n");
lf_indent_suppress (file);
lf_printf (file, "#endif\n");
}
}
-
+
/* Validate: Validate Instruction in correct slot
Some architectures place restrictions on the slot that an
@@ -1297,7 +1210,8 @@ print_idecode_validate (lf *file,
lf_printf (file, "\n");
lf_indent_suppress (file);
lf_printf (file, "#if defined(IS_WRONG_SLOT)\n");
- lf_printf (file, "/* Validate: Instruction issued in correct slot */\n");
+ lf_printf (file,
+ "/* Validate: Instruction issued in correct slot */\n");
lf_printf (file, "if (IS_WRONG_SLOT) {\n");
lf_indent (file, +2);
print_idecode_invalid (file, "return", invalid_wrong_slot);
@@ -1307,7 +1221,7 @@ print_idecode_validate (lf *file,
lf_printf (file, "#endif\n");
}
}
-
+
}
@@ -1326,13 +1240,11 @@ print_idecode_issue_function_header (lf *file,
{
case is_function_declaration:
lf_print__function_type_function (file, print_semantic_function_type,
- "INLINE_IDECODE",
- " ");
+ "INLINE_IDECODE", " ");
break;
case is_function_definition:
lf_print__function_type_function (file, print_semantic_function_type,
- "INLINE_IDECODE",
- "\n");
+ "INLINE_IDECODE", "\n");
break;
case is_function_variable:
print_semantic_function_type (file);
@@ -1343,8 +1255,7 @@ print_idecode_issue_function_header (lf *file,
"issue",
NULL,
processor,
- NULL,
- function_name_prefix_idecode);
+ NULL, function_name_prefix_idecode);
switch (decl_type)
{
case is_function_definition:
diff --git a/sim/igen/gen-idecode.h b/sim/igen/gen-idecode.h
index 9578e6c..18682e4 100644
--- a/sim/igen/gen-idecode.h
+++ b/sim/igen/gen-idecode.h
@@ -23,23 +23,16 @@
void print_idecode_issue_function_header
-(lf *file,
- const char *processor,
- function_decl_type decl_type,
- int nr_prefetched_words);
+ (lf *file,
+ const char *processor,
+ function_decl_type decl_type, int nr_prefetched_words);
-void print_idecode_globals
-(lf *file);
+void print_idecode_globals (lf *file);
void print_idecode_lookups
-(lf *file,
- gen_entry *table,
- cache_entry *cache_rules);
+ (lf *file, gen_entry *table, cache_entry *cache_rules);
-void print_idecode_body
-(lf *file,
- gen_entry *table,
- const char *result);
+void print_idecode_body (lf *file, gen_entry *table, const char *result);
@@ -49,6 +42,4 @@ void print_idecode_body
hardware isn't disabled */
extern void print_idecode_validate
-(lf *file,
- insn_entry *instruction,
- insn_opcodes *opcode_paths);
+ (lf *file, insn_entry * instruction, insn_opcodes *opcode_paths);
diff --git a/sim/igen/gen-itable.c b/sim/igen/gen-itable.c
index dea71a2..7b94d37 100644
--- a/sim/igen/gen-itable.c
+++ b/sim/igen/gen-itable.c
@@ -42,18 +42,18 @@
-typedef struct _itable_info {
+typedef struct _itable_info
+{
int sizeof_form;
int sizeof_name;
int sizeof_file;
-} itable_info;
+}
+itable_info;
static void
itable_h_insn (lf *file,
- insn_table *entry,
- insn_entry *instruction,
- void *data)
+ insn_table *entry, insn_entry * instruction, void *data)
{
int len;
itable_info *info = data;
@@ -62,9 +62,7 @@ itable_h_insn (lf *file,
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- NULL,
- function_name_prefix_itable);
+ NULL, NULL, function_name_prefix_itable);
lf_printf (file, ",\n");
/* update summary info */
len = strlen (instruction->format_name);
@@ -82,16 +80,13 @@ itable_h_insn (lf *file,
/* print the list of all the different options */
static void
-itable_print_enum (lf *file,
- filter *set,
- char *name)
+itable_print_enum (lf *file, filter *set, char *name)
{
char *elem;
lf_printf (file, "typedef enum {\n");
lf_indent (file, +2);
for (elem = filter_next (set, "");
- elem != NULL;
- elem = filter_next (set, elem))
+ elem != NULL; elem = filter_next (set, elem))
{
lf_printf (file, "%sitable_%s_%s,\n",
options.module.itable.prefix.l, name, elem);
@@ -102,8 +97,9 @@ itable_print_enum (lf *file,
name, elem, options.module.itable.prefix.l, name, elem);
}
}
- lf_printf (file, "nr_%sitable_%ss,\n", options.module.itable.prefix.l, name);
-
+ lf_printf (file, "nr_%sitable_%ss,\n", options.module.itable.prefix.l,
+ name);
+
lf_indent (file, -2);
lf_printf (file, "} %sitable_%ss;\n", options.module.itable.prefix.l, name);
if (strlen (options.module.itable.prefix.l) > 0)
@@ -120,9 +116,7 @@ itable_print_enum (lf *file,
/* print an array of the option names as strings */
static void
-itable_print_names (lf *file,
- filter *set,
- char *name)
+itable_print_names (lf *file, filter *set, char *name)
{
char *elem;
lf_printf (file, "const char *%sitable_%s_names[nr_%sitable_%ss + 1] = {\n",
@@ -130,8 +124,7 @@ itable_print_names (lf *file,
options.module.itable.prefix.l, name);
lf_indent (file, +2);
for (elem = filter_next (set, "");
- elem != NULL;
- elem = filter_next (set, elem))
+ elem != NULL; elem = filter_next (set, elem))
{
lf_printf (file, "\"%s\",\n", elem);
}
@@ -140,16 +133,16 @@ itable_print_names (lf *file,
lf_printf (file, "};\n");
}
-extern void
-gen_itable_h (lf *file,
- insn_table *isa)
+extern void
+gen_itable_h (lf *file, insn_table *isa)
{
itable_info *info = ZALLOC (itable_info);
/* output an enumerated type for each instruction */
lf_printf (file, "typedef enum {\n");
insn_table_traverse_insn (file, isa, itable_h_insn, info);
- lf_printf (file, " nr_%sitable_entries,\n", options.module.itable.prefix.l);
+ lf_printf (file, " nr_%sitable_entries,\n",
+ options.module.itable.prefix.l);
lf_printf (file, "} %sitable_index;\n", options.module.itable.prefix.l);
lf_printf (file, "\n");
@@ -158,7 +151,7 @@ gen_itable_h (lf *file,
lf_printf (file, "extern const char *%sitable_flag_names[];\n",
options.module.itable.prefix.l);
lf_printf (file, "\n");
-
+
/* output an enumeration of all the possible options */
itable_print_enum (file, isa->options, "option");
lf_printf (file, "extern const char *%sitable_option_names[];\n",
@@ -220,9 +213,7 @@ gen_itable_h (lf *file,
/****************************************************************/
static void
-itable_print_set (lf *file,
- filter *set,
- filter *members)
+itable_print_set (lf *file, filter *set, filter *members)
{
char *elem;
lf_printf (file, "\"");
@@ -240,10 +231,9 @@ itable_print_set (lf *file,
}
lf_printf (file, "\",\n");
- lf_printf(file, "{");
+ lf_printf (file, "{");
for (elem = filter_next (set, "");
- elem != NULL;
- elem = filter_next (set, elem))
+ elem != NULL; elem = filter_next (set, elem))
{
if (filter_is_member (members, elem))
{
@@ -253,27 +243,23 @@ itable_print_set (lf *file,
{
lf_printf (file, " 0,");
}
-
+
}
/* always print a dummy element, to avoid empty initializers. */
- lf_printf(file, " 99 },\n");
+ lf_printf (file, " 99 },\n");
}
static void
itable_c_insn (lf *file,
- insn_table *isa,
- insn_entry *instruction,
- void *data)
+ insn_table *isa, insn_entry * instruction, void *data)
{
lf_printf (file, "{ ");
lf_indent (file, +2);
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- NULL,
- function_name_prefix_itable);
+ NULL, NULL, function_name_prefix_itable);
lf_printf (file, ",\n");
lf_printf (file, "\"");
print_insn_words (file, instruction);
@@ -284,22 +270,22 @@ itable_c_insn (lf *file,
itable_print_set (file, isa->options, instruction->options);
itable_print_set (file, isa->model->processors, instruction->processors);
- lf_printf(file, "\"%s\",\n", instruction->name);
- lf_printf(file, "\"%s\",\n",
- filter_filename (instruction->line->file_name));
- lf_printf(file, "%d,\n", instruction->line->line_nr);
- lf_printf(file, "},\n");
+ lf_printf (file, "\"%s\",\n", instruction->name);
+ lf_printf (file, "\"%s\",\n",
+ filter_filename (instruction->line->file_name));
+ lf_printf (file, "%d,\n", instruction->line->line_nr);
+ lf_printf (file, "},\n");
lf_indent (file, -2);
}
-extern void
-gen_itable_c (lf *file,
- insn_table *isa)
+extern void
+gen_itable_c (lf *file, insn_table *isa)
{
/* leader */
- lf_printf(file, "#include \"%sitable.h\"\n", options.module.itable.prefix.l);
- lf_printf(file, "\n");
+ lf_printf (file, "#include \"%sitable.h\"\n",
+ options.module.itable.prefix.l);
+ lf_printf (file, "\n");
/* FIXME - output model data??? */
/* FIXME - output assembler data??? */
@@ -312,9 +298,8 @@ gen_itable_c (lf *file,
/* output the table that contains the actual instruction info */
lf_printf (file, "%sitable_info %sitable[nr_%sitable_entries] = {\n",
options.module.itable.prefix.l,
- options.module.itable.prefix.l,
- options.module.itable.prefix.l);
+ options.module.itable.prefix.l, options.module.itable.prefix.l);
insn_table_traverse_insn (file, isa, itable_c_insn, NULL);
- lf_printf(file, "};\n");
+ lf_printf (file, "};\n");
}
diff --git a/sim/igen/gen-itable.h b/sim/igen/gen-itable.h
index 3134819..3cc69fb 100644
--- a/sim/igen/gen-itable.h
+++ b/sim/igen/gen-itable.h
@@ -25,10 +25,6 @@
/* Output a table of all the instructions */
-extern void gen_itable_h
-(lf *file,
- insn_table *table);
+extern void gen_itable_h (lf *file, insn_table *table);
-extern void gen_itable_c
-(lf *file,
- insn_table *table);
+extern void gen_itable_c (lf *file, insn_table *table);
diff --git a/sim/igen/gen-model.c b/sim/igen/gen-model.c
index 98302c0..8f35f0f 100644
--- a/sim/igen/gen-model.c
+++ b/sim/igen/gen-model.c
@@ -40,38 +40,37 @@
#if 0
static void
-model_c_or_h_data(insn_table *table,
- lf *file,
- table_entry *data)
+model_c_or_h_data (insn_table *table, lf *file, table_entry *data)
{
- if (data->annex) {
- table_entry_print_cpp_line_nr(file, data->annex_line);
- lf_print__c_code(file, data->annex);
- lf_print__internal_reference(file);
- lf_printf(file, "\n");
- }
+ if (data->annex)
+ {
+ table_entry_print_cpp_line_nr (file, data->annex_line);
+ lf_print__c_code (file, data->annex);
+ lf_print__internal_reference (file);
+ lf_printf (file, "\n");
+ }
}
static void
-model_c_or_h_function(insn_table *entry,
- lf *file,
- table_entry *function,
- char *prefix)
+model_c_or_h_function (insn_table *entry,
+ lf *file, table_entry *function, char *prefix)
{
if (function->fields[function_type] == NULL
- || function->fields[function_type][0] == '\0') {
- error("Model function type not specified for %s", function->fields[function_name]);
- }
- lf_printf(file, "\n");
- lf_print_function_type(file, function->fields[function_type], prefix, " ");
- lf_printf(file, "%s\n(%s);\n",
- function->fields[function_name],
- function->fields[function_param]);
- lf_printf(file, "\n");
+ || function->fields[function_type][0] == '\0')
+ {
+ error ("Model function type not specified for %s",
+ function->fields[function_name]);
+ }
+ lf_printf (file, "\n");
+ lf_print_function_type (file, function->fields[function_type], prefix, " ");
+ lf_printf (file, "%s\n(%s);\n",
+ function->fields[function_name],
+ function->fields[function_param]);
+ lf_printf (file, "\n");
}
-void
-gen_model_h(insn_table *table, lf *file)
+void
+gen_model_h (insn_table *table, lf *file)
{
insn *insn_ptr;
model *model_ptr;
@@ -83,161 +82,171 @@ gen_model_h(insn_table *table, lf *file)
int model_mon_info_p = 0;
int model_mon_info_free_p = 0;
- for(macro = model_macros; macro; macro = macro->next) {
- model_c_or_h_data(table, file, macro->file_entry);
- }
-
- lf_printf(file, "typedef enum _model_enum {\n");
- lf_printf(file, " MODEL_NONE,\n");
- for (model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- lf_printf(file, " MODEL_%s,\n", model_ptr->name);
- }
- lf_printf(file, " nr_models\n");
- lf_printf(file, "} model_enum;\n");
- lf_printf(file, "\n");
-
- lf_printf(file, "#define DEFAULT_MODEL MODEL_%s\n", (models) ? models->name : "NONE");
- lf_printf(file, "\n");
-
- lf_printf(file, "typedef struct _model_data model_data;\n");
- lf_printf(file, "typedef struct _model_time model_time;\n");
- lf_printf(file, "\n");
-
- lf_printf(file, "extern model_enum current_model;\n");
- lf_printf(file, "extern const char *model_name[ (int)nr_models ];\n");
- lf_printf(file, "extern const char *const *const model_func_unit_name[ (int)nr_models ];\n");
- lf_printf(file, "extern const model_time *const model_time_mapping[ (int)nr_models ];\n");
- lf_printf(file, "\n");
-
- for(insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_or_h_function(table, file, insn_ptr->file_entry, "INLINE_MODEL");
- name = insn_ptr->file_entry->fields[function_name];
- if (strcmp (name, "model_create") == 0)
- model_create_p = 1;
- else if (strcmp (name, "model_init") == 0)
- model_init_p = 1;
- else if (strcmp (name, "model_halt") == 0)
- model_halt_p = 1;
- else if (strcmp (name, "model_mon_info") == 0)
- model_mon_info_p = 1;
- else if (strcmp (name, "model_mon_info_free") == 0)
- model_mon_info_free_p = 1;
- }
-
- if (!model_create_p) {
- lf_print_function_type(file, "model_data *", "INLINE_MODEL", " ");
- lf_printf(file, "model_create\n");
- lf_printf(file, "(sim_cpu *cpu);\n");
- lf_printf(file, "\n");
- }
-
- if (!model_init_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
- lf_printf(file, "model_init\n");
- lf_printf(file, "(model_data *model_ptr);\n");
- lf_printf(file, "\n");
- }
-
- if (!model_halt_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
- lf_printf(file, "model_halt\n");
- lf_printf(file, "(model_data *model_ptr);\n");
- lf_printf(file, "\n");
- }
-
- if (!model_mon_info_p) {
- lf_print_function_type(file, "model_print *", "INLINE_MODEL", " ");
- lf_printf(file, "model_mon_info\n");
- lf_printf(file, "(model_data *model_ptr);\n");
- lf_printf(file, "\n");
- }
-
- if (!model_mon_info_free_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
- lf_printf(file, "model_mon_info_free\n");
- lf_printf(file, "(model_data *model_ptr,\n");
- lf_printf(file, " model_print *info_ptr);\n");
- lf_printf(file, "\n");
- }
-
- lf_print_function_type(file, "void", "INLINE_MODEL", " ");
- lf_printf(file, "model_set\n");
- lf_printf(file, "(const char *name);\n");
+ for (macro = model_macros; macro; macro = macro->next)
+ {
+ model_c_or_h_data (table, file, macro->file_entry);
+ }
+
+ lf_printf (file, "typedef enum _model_enum {\n");
+ lf_printf (file, " MODEL_NONE,\n");
+ for (model_ptr = models; model_ptr; model_ptr = model_ptr->next)
+ {
+ lf_printf (file, " MODEL_%s,\n", model_ptr->name);
+ }
+ lf_printf (file, " nr_models\n");
+ lf_printf (file, "} model_enum;\n");
+ lf_printf (file, "\n");
+
+ lf_printf (file, "#define DEFAULT_MODEL MODEL_%s\n",
+ (models) ? models->name : "NONE");
+ lf_printf (file, "\n");
+
+ lf_printf (file, "typedef struct _model_data model_data;\n");
+ lf_printf (file, "typedef struct _model_time model_time;\n");
+ lf_printf (file, "\n");
+
+ lf_printf (file, "extern model_enum current_model;\n");
+ lf_printf (file, "extern const char *model_name[ (int)nr_models ];\n");
+ lf_printf (file,
+ "extern const char *const *const model_func_unit_name[ (int)nr_models ];\n");
+ lf_printf (file,
+ "extern const model_time *const model_time_mapping[ (int)nr_models ];\n");
+ lf_printf (file, "\n");
+
+ for (insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_or_h_function (table, file, insn_ptr->file_entry,
+ "INLINE_MODEL");
+ name = insn_ptr->file_entry->fields[function_name];
+ if (strcmp (name, "model_create") == 0)
+ model_create_p = 1;
+ else if (strcmp (name, "model_init") == 0)
+ model_init_p = 1;
+ else if (strcmp (name, "model_halt") == 0)
+ model_halt_p = 1;
+ else if (strcmp (name, "model_mon_info") == 0)
+ model_mon_info_p = 1;
+ else if (strcmp (name, "model_mon_info_free") == 0)
+ model_mon_info_free_p = 1;
+ }
+
+ if (!model_create_p)
+ {
+ lf_print_function_type (file, "model_data *", "INLINE_MODEL", " ");
+ lf_printf (file, "model_create\n");
+ lf_printf (file, "(sim_cpu *cpu);\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_init_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", " ");
+ lf_printf (file, "model_init\n");
+ lf_printf (file, "(model_data *model_ptr);\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_halt_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", " ");
+ lf_printf (file, "model_halt\n");
+ lf_printf (file, "(model_data *model_ptr);\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_mon_info_p)
+ {
+ lf_print_function_type (file, "model_print *", "INLINE_MODEL", " ");
+ lf_printf (file, "model_mon_info\n");
+ lf_printf (file, "(model_data *model_ptr);\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_mon_info_free_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", " ");
+ lf_printf (file, "model_mon_info_free\n");
+ lf_printf (file, "(model_data *model_ptr,\n");
+ lf_printf (file, " model_print *info_ptr);\n");
+ lf_printf (file, "\n");
+ }
+
+ lf_print_function_type (file, "void", "INLINE_MODEL", " ");
+ lf_printf (file, "model_set\n");
+ lf_printf (file, "(const char *name);\n");
}
/****************************************************************/
typedef struct _model_c_passed_data model_c_passed_data;
-struct _model_c_passed_data {
+struct _model_c_passed_data
+{
lf *file;
model *model_ptr;
};
static void
-model_c_insn(insn_table *entry,
- lf *phony_file,
- void *data,
- insn *instruction,
- int depth)
+model_c_insn (insn_table *entry,
+ lf *phony_file, void *data, insn * instruction, int depth)
{
- model_c_passed_data *data_ptr = (model_c_passed_data *)data;
+ model_c_passed_data *data_ptr = (model_c_passed_data *) data;
lf *file = data_ptr->file;
char *current_name = data_ptr->model_ptr->printable_name;
table_model_entry *model_ptr = instruction->file_entry->model_first;
- while (model_ptr) {
- if (model_ptr->fields[insn_model_name] == current_name) {
- lf_printf(file, " { %-*s }, /* %s */\n",
- max_model_fields_len,
- model_ptr->fields[insn_model_fields],
- instruction->file_entry->fields[insn_name]);
- return;
+ while (model_ptr)
+ {
+ if (model_ptr->fields[insn_model_name] == current_name)
+ {
+ lf_printf (file, " { %-*s }, /* %s */\n",
+ max_model_fields_len,
+ model_ptr->fields[insn_model_fields],
+ instruction->file_entry->fields[insn_name]);
+ return;
+ }
+
+ model_ptr = model_ptr->next;
}
- model_ptr = model_ptr->next;
- }
-
- lf_printf(file, " { %-*s }, /* %s */\n",
- max_model_fields_len,
- data_ptr->model_ptr->insn_default,
- instruction->file_entry->fields[insn_name]);
+ lf_printf (file, " { %-*s }, /* %s */\n",
+ max_model_fields_len,
+ data_ptr->model_ptr->insn_default,
+ instruction->file_entry->fields[insn_name]);
}
static void
-model_c_function(insn_table *table,
- lf *file,
- table_entry *function,
- const char *prefix)
+model_c_function (insn_table *table,
+ lf *file, table_entry *function, const char *prefix)
{
if (function->fields[function_type] == NULL
|| function->fields[function_type][0] == '\0')
{
- error("Model function return type not specified for %s",
- function->fields[function_name]);
+ error ("Model function return type not specified for %s",
+ function->fields[function_name]);
}
else
{
- lf_printf(file, "\n");
- lf_print_function_type(file, function->fields[function_type], prefix, "\n");
- lf_printf(file, "%s(%s)\n",
- function->fields[function_name],
- function->fields[function_param]);
+ lf_printf (file, "\n");
+ lf_print_function_type (file, function->fields[function_type], prefix,
+ "\n");
+ lf_printf (file, "%s(%s)\n", function->fields[function_name],
+ function->fields[function_param]);
}
- lf_printf(file, "{\n");
+ lf_printf (file, "{\n");
if (function->annex)
{
- lf_indent(file, +2);
- table_entry_print_cpp_line_nr(file, function->annex_line);
- lf_print__c_code(file, function->annex);
- lf_indent(file, -2);
+ lf_indent (file, +2);
+ table_entry_print_cpp_line_nr (file, function->annex_line);
+ lf_print__c_code (file, function->annex);
+ lf_indent (file, -2);
}
- lf_printf(file, "}\n");
- lf_print__internal_reference(file);
- lf_printf(file, "\n");
+ lf_printf (file, "}\n");
+ lf_print__internal_reference (file);
+ lf_printf (file, "\n");
}
-void
-gen_model_c(insn_table *table, lf *file)
+void
+gen_model_c (insn_table *table, lf *file)
{
insn *insn_ptr;
model *model_ptr;
@@ -248,155 +257,179 @@ gen_model_c(insn_table *table, lf *file)
int model_mon_info_p = 0;
int model_mon_info_free_p = 0;
- lf_printf(file, "\n");
- lf_printf(file, "#include \"cpu.h\"\n");
- lf_printf(file, "#include \"mon.h\"\n");
- lf_printf(file, "\n");
- lf_printf(file, "#ifdef HAVE_STDLIB_H\n");
- lf_printf(file, "#include <stdlib.h>\n");
- lf_printf(file, "#endif\n");
- lf_printf(file, "\n");
-
- for(insn_ptr = model_data; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_or_h_data(table, file, insn_ptr->file_entry);
- }
-
- for(insn_ptr = model_static; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_or_h_function(table, file, insn_ptr->file_entry, "/*h*/STATIC");
- }
-
- for(insn_ptr = model_internal; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_or_h_function(table, file, insn_ptr->file_entry, "STATIC_INLINE_MODEL");
- }
-
- for(insn_ptr = model_static; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_function(table, file, insn_ptr->file_entry, "/*c*/STATIC");
- }
-
- for(insn_ptr = model_internal; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_function(table, file, insn_ptr->file_entry, "STATIC_INLINE_MODEL");
- }
-
- for(insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next) {
- model_c_function(table, file, insn_ptr->file_entry, "INLINE_MODEL");
- name = insn_ptr->file_entry->fields[function_name];
- if (strcmp (name, "model_create") == 0)
- model_create_p = 1;
- else if (strcmp (name, "model_init") == 0)
- model_init_p = 1;
- else if (strcmp (name, "model_halt") == 0)
- model_halt_p = 1;
- else if (strcmp (name, "model_mon_info") == 0)
- model_mon_info_p = 1;
- else if (strcmp (name, "model_mon_info_free") == 0)
- model_mon_info_free_p = 1;
- }
-
- if (!model_create_p) {
- lf_print_function_type(file, "model_data *", "INLINE_MODEL", "\n");
- lf_printf(file, "model_create(sim_cpu *cpu)\n");
- lf_printf(file, "{\n");
- lf_printf(file, " return (model_data *)0;\n");
- lf_printf(file, "}\n");
- lf_printf(file, "\n");
- }
-
- if (!model_init_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
- lf_printf(file, "model_init(model_data *model_ptr)\n");
- lf_printf(file, "{\n");
- lf_printf(file, "}\n");
- lf_printf(file, "\n");
- }
-
- if (!model_halt_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
- lf_printf(file, "model_halt(model_data *model_ptr)\n");
- lf_printf(file, "{\n");
- lf_printf(file, "}\n");
- lf_printf(file, "\n");
- }
-
- if (!model_mon_info_p) {
- lf_print_function_type(file, "model_print *", "INLINE_MODEL", "\n");
- lf_printf(file, "model_mon_info(model_data *model_ptr)\n");
- lf_printf(file, "{\n");
- lf_printf(file, " return (model_print *)0;\n");
- lf_printf(file, "}\n");
- lf_printf(file, "\n");
- }
-
- if (!model_mon_info_free_p) {
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
- lf_printf(file, "model_mon_info_free(model_data *model_ptr,\n");
- lf_printf(file, " model_print *info_ptr)\n");
- lf_printf(file, "{\n");
- lf_printf(file, "}\n");
- lf_printf(file, "\n");
- }
-
- lf_printf(file, "/* Insn functional unit info */\n");
- for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- model_c_passed_data data;
-
- lf_printf(file, "static const model_time model_time_%s[] = {\n", model_ptr->name);
- data.file = file;
- data.model_ptr = model_ptr;
- insn_table_traverse_insn(table,
- NULL, (void *)&data,
- model_c_insn);
-
- lf_printf(file, "};\n");
- lf_printf(file, "\n");
- lf_printf(file, "\f\n");
- }
-
- lf_printf(file, "#ifndef _INLINE_C_\n");
- lf_printf(file, "const model_time *const model_time_mapping[ (int)nr_models ] = {\n");
- lf_printf(file, " (const model_time *const)0,\n");
- for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- lf_printf(file, " model_time_%s,\n", model_ptr->name);
- }
- lf_printf(file, "};\n");
- lf_printf(file, "#endif\n");
- lf_printf(file, "\n");
-
- lf_printf(file, "\f\n");
- lf_printf(file, "/* map model enumeration into printable string */\n");
- lf_printf(file, "#ifndef _INLINE_C_\n");
- lf_printf(file, "const char *model_name[ (int)nr_models ] = {\n");
- lf_printf(file, " \"NONE\",\n");
- for (model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- lf_printf(file, " \"%s\",\n", model_ptr->printable_name);
- }
- lf_printf(file, "};\n");
- lf_printf(file, "#endif\n");
- lf_printf(file, "\n");
-
- lf_print_function_type(file, "void", "INLINE_MODEL", "\n");
- lf_printf(file, "model_set(const char *name)\n");
- lf_printf(file, "{\n");
- if (models) {
- lf_printf(file, " model_enum model;\n");
- lf_printf(file, " for(model = MODEL_%s; model < nr_models; model++) {\n", models->name);
- lf_printf(file, " if(strcmp(name, model_name[model]) == 0) {\n");
- lf_printf(file, " current_model = model;\n");
- lf_printf(file, " return;\n");
- lf_printf(file, " }\n");
- lf_printf(file, " }\n");
- lf_printf(file, "\n");
- lf_printf(file, " error(\"Unknown model '%%s', Models which are known are:%%s\n\",\n");
- lf_printf(file, " name,\n");
- lf_printf(file, " \"");
- for(model_ptr = models; model_ptr; model_ptr = model_ptr->next) {
- lf_printf(file, "\\n\\t%s", model_ptr->printable_name);
+ lf_printf (file, "\n");
+ lf_printf (file, "#include \"cpu.h\"\n");
+ lf_printf (file, "#include \"mon.h\"\n");
+ lf_printf (file, "\n");
+ lf_printf (file, "#ifdef HAVE_STDLIB_H\n");
+ lf_printf (file, "#include <stdlib.h>\n");
+ lf_printf (file, "#endif\n");
+ lf_printf (file, "\n");
+
+ for (insn_ptr = model_data; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_or_h_data (table, file, insn_ptr->file_entry);
+ }
+
+ for (insn_ptr = model_static; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_or_h_function (table, file, insn_ptr->file_entry,
+ "/*h*/STATIC");
+ }
+
+ for (insn_ptr = model_internal; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_or_h_function (table, file, insn_ptr->file_entry,
+ "STATIC_INLINE_MODEL");
+ }
+
+ for (insn_ptr = model_static; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_function (table, file, insn_ptr->file_entry, "/*c*/STATIC");
+ }
+
+ for (insn_ptr = model_internal; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_function (table, file, insn_ptr->file_entry,
+ "STATIC_INLINE_MODEL");
+ }
+
+ for (insn_ptr = model_functions; insn_ptr; insn_ptr = insn_ptr->next)
+ {
+ model_c_function (table, file, insn_ptr->file_entry, "INLINE_MODEL");
+ name = insn_ptr->file_entry->fields[function_name];
+ if (strcmp (name, "model_create") == 0)
+ model_create_p = 1;
+ else if (strcmp (name, "model_init") == 0)
+ model_init_p = 1;
+ else if (strcmp (name, "model_halt") == 0)
+ model_halt_p = 1;
+ else if (strcmp (name, "model_mon_info") == 0)
+ model_mon_info_p = 1;
+ else if (strcmp (name, "model_mon_info_free") == 0)
+ model_mon_info_free_p = 1;
+ }
+
+ if (!model_create_p)
+ {
+ lf_print_function_type (file, "model_data *", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_create(sim_cpu *cpu)\n");
+ lf_printf (file, "{\n");
+ lf_printf (file, " return (model_data *)0;\n");
+ lf_printf (file, "}\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_init_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_init(model_data *model_ptr)\n");
+ lf_printf (file, "{\n");
+ lf_printf (file, "}\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_halt_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_halt(model_data *model_ptr)\n");
+ lf_printf (file, "{\n");
+ lf_printf (file, "}\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_mon_info_p)
+ {
+ lf_print_function_type (file, "model_print *", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_mon_info(model_data *model_ptr)\n");
+ lf_printf (file, "{\n");
+ lf_printf (file, " return (model_print *)0;\n");
+ lf_printf (file, "}\n");
+ lf_printf (file, "\n");
+ }
+
+ if (!model_mon_info_free_p)
+ {
+ lf_print_function_type (file, "void", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_mon_info_free(model_data *model_ptr,\n");
+ lf_printf (file, " model_print *info_ptr)\n");
+ lf_printf (file, "{\n");
+ lf_printf (file, "}\n");
+ lf_printf (file, "\n");
+ }
+
+ lf_printf (file, "/* Insn functional unit info */\n");
+ for (model_ptr = models; model_ptr; model_ptr = model_ptr->next)
+ {
+ model_c_passed_data data;
+
+ lf_printf (file, "static const model_time model_time_%s[] = {\n",
+ model_ptr->name);
+ data.file = file;
+ data.model_ptr = model_ptr;
+ insn_table_traverse_insn (table, NULL, (void *) &data, model_c_insn);
+
+ lf_printf (file, "};\n");
+ lf_printf (file, "\n");
+ lf_printf (file, "\f\n");
+ }
+
+ lf_printf (file, "#ifndef _INLINE_C_\n");
+ lf_printf (file,
+ "const model_time *const model_time_mapping[ (int)nr_models ] = {\n");
+ lf_printf (file, " (const model_time *const)0,\n");
+ for (model_ptr = models; model_ptr; model_ptr = model_ptr->next)
+ {
+ lf_printf (file, " model_time_%s,\n", model_ptr->name);
+ }
+ lf_printf (file, "};\n");
+ lf_printf (file, "#endif\n");
+ lf_printf (file, "\n");
+
+ lf_printf (file, "\f\n");
+ lf_printf (file, "/* map model enumeration into printable string */\n");
+ lf_printf (file, "#ifndef _INLINE_C_\n");
+ lf_printf (file, "const char *model_name[ (int)nr_models ] = {\n");
+ lf_printf (file, " \"NONE\",\n");
+ for (model_ptr = models; model_ptr; model_ptr = model_ptr->next)
+ {
+ lf_printf (file, " \"%s\",\n", model_ptr->printable_name);
+ }
+ lf_printf (file, "};\n");
+ lf_printf (file, "#endif\n");
+ lf_printf (file, "\n");
+
+ lf_print_function_type (file, "void", "INLINE_MODEL", "\n");
+ lf_printf (file, "model_set(const char *name)\n");
+ lf_printf (file, "{\n");
+ if (models)
+ {
+ lf_printf (file, " model_enum model;\n");
+ lf_printf (file,
+ " for(model = MODEL_%s; model < nr_models; model++) {\n",
+ models->name);
+ lf_printf (file, " if(strcmp(name, model_name[model]) == 0) {\n");
+ lf_printf (file, " current_model = model;\n");
+ lf_printf (file, " return;\n");
+ lf_printf (file, " }\n");
+ lf_printf (file, " }\n");
+ lf_printf (file, "\n");
+ lf_printf (file,
+ " error(\"Unknown model '%%s', Models which are known are:%%s\n\",\n");
+ lf_printf (file, " name,\n");
+ lf_printf (file, " \"");
+ for (model_ptr = models; model_ptr; model_ptr = model_ptr->next)
+ {
+ lf_printf (file, "\\n\\t%s", model_ptr->printable_name);
+ }
+ lf_printf (file, "\");\n");
+ }
+ else
+ {
+ lf_printf (file, " error(\"No models are currently known about\");\n");
}
- lf_printf(file, "\");\n");
- } else {
- lf_printf(file, " error(\"No models are currently known about\");\n");
- }
- lf_printf(file, "}\n");
+ lf_printf (file, "}\n");
}
#endif
@@ -404,16 +437,14 @@ gen_model_c(insn_table *table, lf *file)
void
-gen_model_h (lf *file,
- insn_table *table)
+gen_model_h (lf *file, insn_table *table)
{
lf_print__this_file_is_empty (file, "suffering bit rot");
}
void
-gen_model_c (lf *file,
- insn_table *table)
+gen_model_c (lf *file, insn_table *table)
{
lf_print__this_file_is_empty (file, "suffering bit rot");
}
diff --git a/sim/igen/gen-model.h b/sim/igen/gen-model.h
index a0d7773..8dd9872 100644
--- a/sim/igen/gen-model.h
+++ b/sim/igen/gen-model.h
@@ -23,10 +23,6 @@
-extern void gen_model_h
-(lf *file,
- insn_table *isa);
+extern void gen_model_h (lf *file, insn_table *isa);
-extern void gen_model_c
-(lf *file,
- insn_table *isa);
+extern void gen_model_c (lf *file, insn_table *isa);
diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c
index ee6b610..44a3c52 100644
--- a/sim/igen/gen-semantics.c
+++ b/sim/igen/gen-semantics.c
@@ -48,7 +48,7 @@ print_semantic_function_header (lf *file,
int nr_prefetched_words)
{
int indent;
- lf_printf(file, "\n");
+ lf_printf (file, "\n");
lf_print__function_type_function (file, print_semantic_function_type,
"EXTERN_SEMANTICS",
(is_function_definition ? "\n" : " "));
@@ -85,52 +85,58 @@ print_semantic_function_header (lf *file,
void
print_semantic_declaration (lf *file,
- insn_entry *insn,
+ insn_entry * insn,
opcode_bits *expanded_bits,
- insn_opcodes *opcodes,
- int nr_prefetched_words)
+ insn_opcodes *opcodes, int nr_prefetched_words)
{
print_semantic_function_header (file,
insn->name,
insn->format_name,
expanded_bits,
- 0/* is not function definition*/,
+ 0 /* is not function definition */ ,
nr_prefetched_words);
}
+
-
/* generate the semantics.c file */
void
-print_idecode_invalid (lf *file,
- const char *result,
- invalid_type type)
+print_idecode_invalid (lf *file, const char *result, invalid_type type)
{
const char *name;
switch (type)
{
- default: name = "unknown"; break;
- case invalid_illegal: name = "illegal"; break;
- case invalid_fp_unavailable: name = "fp_unavailable"; break;
- case invalid_wrong_slot: name = "wrong_slot"; break;
+ default:
+ name = "unknown";
+ break;
+ case invalid_illegal:
+ name = "illegal";
+ break;
+ case invalid_fp_unavailable:
+ name = "fp_unavailable";
+ break;
+ case invalid_wrong_slot:
+ name = "wrong_slot";
+ break;
}
if (options.gen.code == generate_jumps)
{
lf_printf (file, "goto %s_%s;\n",
- (options.gen.icache ? "icache" : "semantic"),
- name);
+ (options.gen.icache ? "icache" : "semantic"), name);
}
else if (options.gen.icache)
{
- lf_printf (file, "%s %sicache_%s (", result, options.module.global.prefix.l, name);
+ lf_printf (file, "%s %sicache_%s (", result,
+ options.module.global.prefix.l, name);
print_icache_function_actual (file, 0);
lf_printf (file, ");\n");
}
else
{
- lf_printf (file, "%s %ssemantic_%s (", result, options.module.global.prefix.l, name);
+ lf_printf (file, "%s %ssemantic_%s (", result,
+ options.module.global.prefix.l, name);
print_semantic_function_actual (file, 0);
lf_printf (file, ");\n");
}
@@ -139,18 +145,17 @@ print_idecode_invalid (lf *file,
void
print_semantic_body (lf *file,
- insn_entry *instruction,
- opcode_bits *expanded_bits,
- insn_opcodes *opcodes)
+ insn_entry * instruction,
+ opcode_bits *expanded_bits, insn_opcodes *opcodes)
{
/* validate the instruction, if a cache this has already been done */
if (!options.gen.icache)
{
print_idecode_validate (file, instruction, opcodes);
}
-
- print_itrace (file, instruction, 0/*put_value_in_cache*/);
-
+
+ print_itrace (file, instruction, 0 /*put_value_in_cache */ );
+
/* generate the instruction profile call - this is delayed until
after the instruction has been verified. The count macro
generated is prefixed by ITABLE_PREFIX */
@@ -177,22 +182,20 @@ print_semantic_body (lf *file,
print_function_name (file,
instruction->name,
instruction->format_name,
- NULL,
- NULL,
- function_name_prefix_itable);
+ NULL, NULL, function_name_prefix_itable);
lf_printf (file, ", cpu, cia);\n");
lf_indent_suppress (file);
lf_printf (file, "#endif\n");
lf_printf (file, "\n");
}
-
+
/* determine the new instruction address */
{
- lf_printf(file, "/* keep the next instruction address handy */\n");
+ lf_printf (file, "/* keep the next instruction address handy */\n");
if (options.gen.nia == nia_is_invalid)
{
- lf_printf(file, "nia = %sINVALID_INSTRUCTION_ADDRESS;\n",
- options.module.global.prefix.u);
+ lf_printf (file, "nia = %sINVALID_INSTRUCTION_ADDRESS;\n",
+ options.module.global.prefix.u);
}
else
{
@@ -218,7 +221,7 @@ print_semantic_body (lf *file,
lf_printf (file, "nia = cia + %d * (%d + 1); %s\n",
options.insn_bit_size / 8, nr_immeds,
"/* skip immeds as well */");
-
+
}
else
{
@@ -228,7 +231,7 @@ print_semantic_body (lf *file,
}
}
}
-
+
/* if conditional, generate code to verify that the instruction
should be issued */
if (filter_is_member (instruction->options, "c")
@@ -241,7 +244,7 @@ print_semantic_body (lf *file,
lf_indent (file, +4);
/* FIXME - need to log a conditional failure */
}
-
+
/* Architecture expects a REG to be zero. Instead of having to
check every read to see if it is refering to that REG just zap it
at the start of every instruction */
@@ -251,7 +254,7 @@ print_semantic_body (lf *file,
lf_printf (file, "/* Architecture expects REG to be zero */\n");
lf_printf (file, "GPR_CLEAR(%d);\n", options.gen.zero_reg_nr);
}
-
+
/* generate the code (or at least something */
lf_printf (file, "\n");
lf_printf (file, "/* semantics: */\n");
@@ -287,32 +290,30 @@ print_semantic_body (lf *file,
lf_indent (file, -indent);
lf_print__internal_ref (file);
}
-
+
/* Close off the conditional execution */
if (filter_is_member (instruction->options, "c")
|| options.gen.conditional_issue)
{
lf_indent (file, -4);
lf_printf (file, " }\n");
- }
+ }
}
static void
print_c_semantic (lf *file,
- insn_entry *instruction,
+ insn_entry * instruction,
opcode_bits *expanded_bits,
insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words)
+ cache_entry *cache_rules, int nr_prefetched_words)
{
-
+
lf_printf (file, "{\n");
lf_indent (file, +2);
-
+
print_my_defines (file,
instruction->name,
- instruction->format_name,
- expanded_bits);
+ instruction->format_name, expanded_bits);
lf_printf (file, "\n");
print_icache_body (file,
instruction,
@@ -323,16 +324,13 @@ print_c_semantic (lf *file,
: declare_variables),
(options.gen.icache
? get_values_from_icache
- : do_not_use_icache),
- nr_prefetched_words);
-
- lf_printf (file, "%sinstruction_address nia;\n", options.module.global.prefix.l);
- print_semantic_body (file,
- instruction,
- expanded_bits,
- opcodes);
+ : do_not_use_icache), nr_prefetched_words);
+
+ lf_printf (file, "%sinstruction_address nia;\n",
+ options.module.global.prefix.l);
+ print_semantic_body (file, instruction, expanded_bits, opcodes);
lf_printf (file, "return nia;\n");
-
+
/* generate something to clean up any #defines created for the cache */
if (options.gen.direct_access)
{
@@ -343,51 +341,41 @@ print_c_semantic (lf *file,
undef_variables,
(options.gen.icache
? get_values_from_icache
- : do_not_use_icache),
- nr_prefetched_words);
+ : do_not_use_icache), nr_prefetched_words);
}
-
+
lf_indent (file, -2);
lf_printf (file, "}\n");
}
static void
print_c_semantic_function (lf *file,
- insn_entry *instruction,
+ insn_entry * instruction,
opcode_bits *expanded_bits,
insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words)
+ cache_entry *cache_rules, int nr_prefetched_words)
{
/* build the semantic routine to execute the instruction */
print_semantic_function_header (file,
instruction->name,
instruction->format_name,
expanded_bits,
- 1/*is-function-definition*/,
+ 1 /*is-function-definition */ ,
nr_prefetched_words);
print_c_semantic (file,
instruction,
- expanded_bits,
- opcodes,
- cache_rules,
- nr_prefetched_words);
+ expanded_bits, opcodes, cache_rules, nr_prefetched_words);
}
void
print_semantic_definition (lf *file,
- insn_entry *insn,
+ insn_entry * insn,
opcode_bits *expanded_bits,
insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words)
+ cache_entry *cache_rules, int nr_prefetched_words)
{
print_c_semantic_function (file,
insn,
expanded_bits,
- opcodes,
- cache_rules,
- nr_prefetched_words);
+ opcodes, cache_rules, nr_prefetched_words);
}
-
-
diff --git a/sim/igen/gen-semantics.h b/sim/igen/gen-semantics.h
index c8373b5..9afc5cf 100644
--- a/sim/igen/gen-semantics.h
+++ b/sim/igen/gen-semantics.h
@@ -73,35 +73,29 @@
extern void print_semantic_declaration
-(lf *file,
- insn_entry *insn,
- opcode_bits *bits,
- insn_opcodes *opcodes,
- int nr_prefetched_words);
+ (lf *file,
+ insn_entry * insn,
+ opcode_bits *bits, insn_opcodes *opcodes, int nr_prefetched_words);
extern void print_semantic_definition
-(lf *file,
- insn_entry *insn,
- opcode_bits *bits,
- insn_opcodes *opcodes,
- cache_entry *cache_rules,
- int nr_prefetched_words);
+ (lf *file,
+ insn_entry * insn,
+ opcode_bits *bits,
+ insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words);
-typedef enum {
+typedef enum
+{
invalid_illegal,
invalid_fp_unavailable,
invalid_wrong_slot,
-} invalid_type;
+}
+invalid_type;
extern void print_idecode_invalid
-(lf *file,
- const char *result,
- invalid_type type);
+ (lf *file, const char *result, invalid_type type);
extern void print_semantic_body
-(lf *file,
- insn_entry *instruction,
- opcode_bits *expanded_bits,
- insn_opcodes *opcodes);
-
+ (lf *file,
+ insn_entry * instruction,
+ opcode_bits *expanded_bits, insn_opcodes *opcodes);
diff --git a/sim/igen/gen-support.c b/sim/igen/gen-support.c
index 407d5f7..d246845 100644
--- a/sim/igen/gen-support.c
+++ b/sim/igen/gen-support.c
@@ -39,19 +39,16 @@
static void
print_support_function_name (lf *file,
- function_entry *function,
+ function_entry * function,
int is_function_definition)
{
if (function->is_internal)
{
lf_print__function_type_function (file, print_semantic_function_type,
"INLINE_SUPPORT",
- (is_function_definition ? "\n" : " "));
- print_function_name (file,
- function->name,
- NULL,
- NULL,
- NULL,
+ (is_function_definition ? "\n" :
+ " "));
+ print_function_name (file, function->name, NULL, NULL, NULL,
function_name_prefix_semantics);
lf_printf (file, "\n(");
lf_indent (file, +1);
@@ -71,16 +68,14 @@ print_support_function_name (lf *file,
lf_indent_suppress (file);
lf_printf (file, "#define %s %s%s\n",
function->name,
- options.module.support.prefix.l,
- function->name);
+ options.module.support.prefix.l, function->name);
}
lf_print__function_type (file,
function->type,
"INLINE_SUPPORT",
(is_function_definition ? "\n" : " "));
lf_printf (file, "%s%s\n(",
- options.module.support.prefix.l,
- function->name);
+ options.module.support.prefix.l, function->name);
if (options.gen.smp)
lf_printf (file,
"sim_cpu *cpu, %sinstruction_address cia, int MY_INDEX",
@@ -89,8 +84,7 @@ print_support_function_name (lf *file,
lf_printf (file,
"SIM_DESC sd, %sinstruction_address cia, int MY_INDEX",
options.module.support.prefix.l);
- if (function->param != NULL
- && strlen (function->param) > 0)
+ if (function->param != NULL && strlen (function->param) > 0)
lf_printf (file, ", %s", function->param);
lf_printf (file, ")%s", (is_function_definition ? "\n" : ";\n"));
}
@@ -98,58 +92,54 @@ print_support_function_name (lf *file,
static void
-support_h_function (lf *file,
- function_entry *function,
- void *data)
+support_h_function (lf *file, function_entry * function, void *data)
{
ASSERT (function->type != NULL);
- print_support_function_name (file,
- function,
- 0/*!is_definition*/);
- lf_printf(file, "\n");
+ print_support_function_name (file, function, 0 /*!is_definition */ );
+ lf_printf (file, "\n");
}
extern void
-gen_support_h (lf *file,
- insn_table *table)
+gen_support_h (lf *file, insn_table *table)
{
- /* output the definition of `SD_'*/
- if (options.gen.smp)
+ /* output the definition of `SD_' */
+ if (options.gen.smp)
{
- lf_printf(file, "#define SD CPU_STATE (cpu)\n");
- lf_printf(file, "#define CPU cpu\n");
- lf_printf(file, "#define CPU_ cpu\n");
+ lf_printf (file, "#define SD CPU_STATE (cpu)\n");
+ lf_printf (file, "#define CPU cpu\n");
+ lf_printf (file, "#define CPU_ cpu\n");
}
else
{
- lf_printf(file, "#define SD sd\n");
- lf_printf(file, "#define CPU (STATE_CPU (sd, 0))\n");
- lf_printf(file, "#define CPU_ sd\n");
+ lf_printf (file, "#define SD sd\n");
+ lf_printf (file, "#define CPU (STATE_CPU (sd, 0))\n");
+ lf_printf (file, "#define CPU_ sd\n");
}
- lf_printf(file, "#define CIA_ cia\n");
+ lf_printf (file, "#define CIA_ cia\n");
if (options.gen.delayed_branch)
{
- lf_printf(file, "#define CIA cia.ip\n");
- lf_printf(file, "/* #define NIA nia.dp -- do not define, ambigious */\n");
+ lf_printf (file, "#define CIA cia.ip\n");
+ lf_printf (file,
+ "/* #define NIA nia.dp -- do not define, ambigious */\n");
}
else
{
- lf_printf(file, "#define CIA cia\n");
- lf_printf(file, "#define NIA nia\n");
+ lf_printf (file, "#define CIA cia\n");
+ lf_printf (file, "#define NIA nia\n");
}
- lf_printf(file, "\n");
+ lf_printf (file, "\n");
- lf_printf(file, "#define SD_ CPU_, CIA_, MY_INDEX\n");
- lf_printf(file, "#define _SD SD_ /* deprecated */\n");
- lf_printf(file, "\n");
+ lf_printf (file, "#define SD_ CPU_, CIA_, MY_INDEX\n");
+ lf_printf (file, "#define _SD SD_ /* deprecated */\n");
+ lf_printf (file, "\n");
/* Map <PREFIX>_xxxx onto the shorter xxxx for the following names:
- instruction_word
- idecode_issue
- semantic_illegal
+ instruction_word
+ idecode_issue
+ semantic_illegal
Map defined here as name space problems are created when the name is
defined in idecode.h */
@@ -158,55 +148,47 @@ gen_support_h (lf *file,
lf_indent_suppress (file);
lf_printf (file, "#define %s %s%s\n",
"instruction_word",
- options.module.idecode.prefix.l,
- "instruction_word");
+ options.module.idecode.prefix.l, "instruction_word");
lf_printf (file, "\n");
lf_indent_suppress (file);
lf_printf (file, "#define %s %s%s\n",
"idecode_issue",
- options.module.idecode.prefix.l,
- "idecode_issue");
+ options.module.idecode.prefix.l, "idecode_issue");
lf_printf (file, "\n");
lf_indent_suppress (file);
lf_printf (file, "#define %s %s%s\n",
"semantic_illegal",
- options.module.idecode.prefix.l,
- "semantic_illegal");
+ options.module.idecode.prefix.l, "semantic_illegal");
lf_printf (file, "\n");
}
/* output a declaration for all functions */
- function_entry_traverse (file, table->functions,
- support_h_function,
- NULL);
- lf_printf(file, "\n");
- lf_printf(file, "#if defined(SUPPORT_INLINE)\n");
- lf_printf(file, "# if ((SUPPORT_INLINE & INCLUDE_MODULE)\\\n");
- lf_printf(file, " && (SUPPORT_INLINE & INCLUDED_BY_MODULE))\n");
- lf_printf(file, "# include \"%ssupport.c\"\n", options.module.support.prefix.l);
- lf_printf(file, "# endif\n");
- lf_printf(file, "#endif\n");
+ function_entry_traverse (file, table->functions, support_h_function, NULL);
+ lf_printf (file, "\n");
+ lf_printf (file, "#if defined(SUPPORT_INLINE)\n");
+ lf_printf (file, "# if ((SUPPORT_INLINE & INCLUDE_MODULE)\\\n");
+ lf_printf (file, " && (SUPPORT_INLINE & INCLUDED_BY_MODULE))\n");
+ lf_printf (file, "# include \"%ssupport.c\"\n",
+ options.module.support.prefix.l);
+ lf_printf (file, "# endif\n");
+ lf_printf (file, "#endif\n");
}
static void
-support_c_function (lf *file,
- function_entry *function,
- void *data)
+support_c_function (lf *file, function_entry * function, void *data)
{
ASSERT (function->type != NULL);
- print_support_function_name (file,
- function,
- 1/*!is_definition*/);
+ print_support_function_name (file, function, 1 /*!is_definition */ );
lf_printf (file, "{\n");
lf_indent (file, +2);
if (function->code == NULL)
- error (function->line,
- "Function without body (or null statement)");
+ error (function->line, "Function without body (or null statement)");
lf_print__line_ref (file, function->code->line);
table_print_code (file, function->code);
if (function->is_internal)
{
- lf_printf (file, "sim_engine_abort (SD, CPU, cia, \"Internal function must longjump\\n\");\n");
+ lf_printf (file,
+ "sim_engine_abort (SD, CPU, cia, \"Internal function must longjump\\n\");\n");
lf_printf (file, "return cia;\n");
}
lf_indent (file, -2);
@@ -217,17 +199,17 @@ support_c_function (lf *file,
void
-gen_support_c (lf *file,
- insn_table *table)
+gen_support_c (lf *file, insn_table *table)
{
- lf_printf(file, "#include \"sim-main.h\"\n");
- lf_printf(file, "#include \"%sidecode.h\"\n", options.module.idecode.prefix.l);
- lf_printf(file, "#include \"%sitable.h\"\n", options.module.itable.prefix.l);
- lf_printf(file, "#include \"%ssupport.h\"\n", options.module.support.prefix.l);
- lf_printf(file, "\n");
+ lf_printf (file, "#include \"sim-main.h\"\n");
+ lf_printf (file, "#include \"%sidecode.h\"\n",
+ options.module.idecode.prefix.l);
+ lf_printf (file, "#include \"%sitable.h\"\n",
+ options.module.itable.prefix.l);
+ lf_printf (file, "#include \"%ssupport.h\"\n",
+ options.module.support.prefix.l);
+ lf_printf (file, "\n");
/* output a definition (c-code) for all functions */
- function_entry_traverse (file, table->functions,
- support_c_function,
- NULL);
+ function_entry_traverse (file, table->functions, support_c_function, NULL);
}
diff --git a/sim/igen/gen-support.h b/sim/igen/gen-support.h
index e05bd9c..4d716c9 100644
--- a/sim/igen/gen-support.h
+++ b/sim/igen/gen-support.h
@@ -22,11 +22,6 @@
Boston, MA 02111-1307, USA. */
-extern void gen_support_h
-(lf *file,
- insn_table *table);
-
-extern void gen_support_c
-(lf *file,
- insn_table *table);
+extern void gen_support_h (lf *file, insn_table *table);
+extern void gen_support_c (lf *file, insn_table *table);
diff --git a/sim/igen/gen.c b/sim/igen/gen.c
index d12cb3b..0ff15d4 100644
--- a/sim/igen/gen.c
+++ b/sim/igen/gen.c
@@ -33,22 +33,16 @@
#include "gen.h"
static insn_uint
-sub_val (insn_uint val,
- int val_last_pos,
- int first_pos,
- int last_pos)
+sub_val (insn_uint val, int val_last_pos, int first_pos, int last_pos)
{
return ((val >> (val_last_pos - last_pos))
- & (((insn_uint)1 << (last_pos - first_pos + 1)) - 1));
+ & (((insn_uint) 1 << (last_pos - first_pos + 1)) - 1));
}
static void
-update_depth (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+update_depth (lf *file, gen_entry *entry, int depth, void *data)
{
- int *max_depth = (int*)data;
+ int *max_depth = (int *) data;
if (*max_depth < depth)
*max_depth = depth;
}
@@ -58,21 +52,15 @@ int
gen_entry_depth (gen_entry *table)
{
int depth = 0;
- gen_entry_traverse_tree (NULL,
- table,
- 1,
- NULL, /*start*/
- update_depth,
- NULL, /*end*/
- &depth); /* data */
+ gen_entry_traverse_tree (NULL, table, 1, NULL, /*start */
+ update_depth, NULL, /*end */
+ &depth); /* data */
return depth;
}
static void
-print_gen_entry_path (line_ref *line,
- gen_entry *table,
- error_func *print)
+print_gen_entry_path (line_ref *line, gen_entry *table, error_func *print)
{
if (table->parent == NULL)
{
@@ -91,8 +79,7 @@ print_gen_entry_path (line_ref *line,
static void
print_gen_entry_insns (gen_entry *table,
error_func *print,
- char *first_message,
- char *next_message)
+ char *first_message, char *next_message)
{
insn_list *i;
char *message;
@@ -101,10 +88,7 @@ print_gen_entry_insns (gen_entry *table,
{
insn_entry *insn = i->insn;
print_gen_entry_path (insn->line, table, print);
- print (NULL, ": %s.%s %s\n",
- insn->format_name,
- insn->name,
- message);
+ print (NULL, ": %s.%s %s\n", insn->format_name, insn->name, message);
if (next_message != NULL)
message = next_message;
}
@@ -118,14 +102,12 @@ insn_field_cmp (insn_word_entry *l, insn_word_entry *r)
{
int bit_nr;
if (l == NULL && r == NULL)
- return 0; /* all previous fields the same */
+ return 0; /* all previous fields the same */
if (l == NULL)
- return -1; /* left shorter than right */
+ return -1; /* left shorter than right */
if (r == NULL)
- return +1; /* left longer than right */
- for (bit_nr = 0;
- bit_nr < options.insn_bit_size;
- bit_nr++)
+ return +1; /* left longer than right */
+ for (bit_nr = 0; bit_nr < options.insn_bit_size; bit_nr++)
{
if (l->bit[bit_nr]->field->type != insn_field_string)
continue;
@@ -138,38 +120,46 @@ insn_field_cmp (insn_word_entry *l, insn_word_entry *r)
if (0)
printf ("%s%s%s VS %s%s%s\n",
l->bit[bit_nr]->field->val_string,
- l->bit[bit_nr]->field->conditions->test == insn_field_cond_eq ? "=" : "!",
- l->bit[bit_nr]->field->conditions->string,
+ l->bit[bit_nr]->field->conditions->test ==
+ insn_field_cond_eq ? "=" : "!",
+ l->bit[bit_nr]->field->conditions->string,
r->bit[bit_nr]->field->val_string,
- r->bit[bit_nr]->field->conditions->test == insn_field_cond_eq ? "=" : "!",
+ r->bit[bit_nr]->field->conditions->test ==
+ insn_field_cond_eq ? "=" : "!",
r->bit[bit_nr]->field->conditions->string);
if (l->bit[bit_nr]->field->conditions->test == insn_field_cond_eq
- && r->bit[bit_nr]->field->conditions->test == insn_field_cond_eq)
+ && r->bit[bit_nr]->field->conditions->test ==
+ insn_field_cond_eq)
{
- if (l->bit[bit_nr]->field->conditions->type == insn_field_cond_field
- && r->bit[bit_nr]->field->conditions->type == insn_field_cond_field)
+ if (l->bit[bit_nr]->field->conditions->type ==
+ insn_field_cond_field
+ && r->bit[bit_nr]->field->conditions->type ==
+ insn_field_cond_field)
/* somewhat arbitrary */
{
int cmp = strcmp (l->bit[bit_nr]->field->conditions->string,
- r->bit[bit_nr]->field->conditions->string);
+ r->bit[bit_nr]->field->conditions->
+ string);
if (cmp != 0)
return cmp;
else
continue;
}
- if (l->bit[bit_nr]->field->conditions->type == insn_field_cond_field)
+ if (l->bit[bit_nr]->field->conditions->type ==
+ insn_field_cond_field)
return +1;
- if (r->bit[bit_nr]->field->conditions->type == insn_field_cond_field)
+ if (r->bit[bit_nr]->field->conditions->type ==
+ insn_field_cond_field)
return -1;
/* The case of both fields having constant values should have
- already have been handled because such fields are converted
- into normal constant fields. */
+ already have been handled because such fields are converted
+ into normal constant fields. */
continue;
}
if (l->bit[bit_nr]->field->conditions->test == insn_field_cond_eq)
- return +1; /* left = only */
+ return +1; /* left = only */
if (r->bit[bit_nr]->field->conditions->test == insn_field_cond_eq)
- return -1; /* right = only */
+ return -1; /* right = only */
/* FIXME: Need to some what arbitrarily order conditional lists */
continue;
}
@@ -186,14 +176,12 @@ insn_word_cmp (insn_word_entry *l, insn_word_entry *r)
{
int bit_nr;
if (l == NULL && r == NULL)
- return 0; /* all previous fields the same */
+ return 0; /* all previous fields the same */
if (l == NULL)
- return -1; /* left shorter than right */
+ return -1; /* left shorter than right */
if (r == NULL)
- return +1; /* left longer than right */
- for (bit_nr = 0;
- bit_nr < options.insn_bit_size;
- bit_nr++)
+ return +1; /* left longer than right */
+ for (bit_nr = 0; bit_nr < options.insn_bit_size; bit_nr++)
{
if (l->bit[bit_nr]->mask < r->bit[bit_nr]->mask)
return -1;
@@ -211,30 +199,29 @@ insn_word_cmp (insn_word_entry *l, insn_word_entry *r)
/* same as strcmp */
static int
-opcode_bit_cmp (opcode_bits *l,
- opcode_bits *r)
+opcode_bit_cmp (opcode_bits *l, opcode_bits *r)
{
if (l == NULL && r == NULL)
- return 0; /* all previous bits the same */
+ return 0; /* all previous bits the same */
if (l == NULL)
- return -1; /* left shorter than right */
+ return -1; /* left shorter than right */
if (r == NULL)
- return +1; /* left longer than right */
+ return +1; /* left longer than right */
/* most significant word */
if (l->field->word_nr < r->field->word_nr)
- return +1; /* left has more significant word */
+ return +1; /* left has more significant word */
if (l->field->word_nr > r->field->word_nr)
- return -1; /* right has more significant word */
+ return -1; /* right has more significant word */
/* most significant bit? */
if (l->first < r->first)
- return +1; /* left as more significant bit */
+ return +1; /* left as more significant bit */
if (l->first > r->first)
- return -1; /* right as more significant bit */
+ return -1; /* right as more significant bit */
/* nr bits? */
if (l->last < r->last)
- return +1; /* left as less bits */
+ return +1; /* left as less bits */
if (l->last > r->last)
- return -1; /* right as less bits */
+ return -1; /* right as less bits */
/* value? */
if (l->value < r->value)
return -1;
@@ -246,14 +233,13 @@ opcode_bit_cmp (opcode_bits *l,
/* same as strcmp */
static int
-opcode_bits_cmp (opcode_bits *l,
- opcode_bits *r)
+opcode_bits_cmp (opcode_bits *l, opcode_bits *r)
{
while (1)
{
int cmp;
if (l == NULL && r == NULL)
- return 0; /* all previous bits the same */
+ return 0; /* all previous bits the same */
cmp = opcode_bit_cmp (l, r);
if (cmp != 0)
return cmp;
@@ -267,9 +253,7 @@ static opcode_bits *
new_opcode_bits (opcode_bits *old_bits,
int value,
int first,
- int last,
- insn_field_entry *field,
- opcode_field *opcode)
+ int last, insn_field_entry *field, opcode_field *opcode)
{
opcode_bits *new_bits = ZALLOC (opcode_bits);
new_bits->field = field;
@@ -277,7 +261,7 @@ new_opcode_bits (opcode_bits *old_bits,
new_bits->first = first;
new_bits->last = last;
new_bits->opcode = opcode;
-
+
if (old_bits != NULL)
{
opcode_bits *new_list;
@@ -286,12 +270,11 @@ new_opcode_bits (opcode_bits *old_bits,
old_bits->value,
old_bits->first,
old_bits->last,
- old_bits->field,
- old_bits->opcode);
+ old_bits->field, old_bits->opcode);
while (*last != NULL)
{
int cmp = opcode_bit_cmp (new_bits, *last);
- if (cmp < 0) /* new < new_list */
+ if (cmp < 0) /* new < new_list */
{
break;
}
@@ -325,15 +308,17 @@ format_name_cmp (const char *l, const char *r)
}
-typedef enum {
+typedef enum
+{
merge_duplicate_insns,
report_duplicate_insns,
-} duplicate_insn_actions;
+}
+duplicate_insn_actions;
static insn_list *
insn_list_insert (insn_list **cur_insn_ptr,
int *nr_insns,
- insn_entry *insn,
+ insn_entry * insn,
opcode_bits *expanded_bits,
opcode_field *opcodes,
int nr_prefetched_words,
@@ -366,12 +351,14 @@ insn_list_insert (insn_list **cur_insn_ptr,
continue;
/* key#4 sort according to the format-name. If two apparently
- identical instructions have unique format-names, then the
- instructions are different. This is because the
- format-name's use is overloaded, it not only indicates the
- format name but also provides a unique semantic name for the
- function. */
- cmp = format_name_cmp (insn->format_name, (*cur_insn_ptr)->insn->format_name);
+ identical instructions have unique format-names, then the
+ instructions are different. This is because the
+ format-name's use is overloaded, it not only indicates the
+ format name but also provides a unique semantic name for the
+ function. */
+ cmp =
+ format_name_cmp (insn->format_name,
+ (*cur_insn_ptr)->insn->format_name);
if (cmp < 0)
break;
else if (cmp > 0)
@@ -409,7 +396,7 @@ insn_list_insert (insn_list **cur_insn_ptr,
}
}
-
+
/* create a new list entry and insert it */
{
insn_list *new_insn = ZALLOC (insn_list);
@@ -424,7 +411,7 @@ insn_list_insert (insn_list **cur_insn_ptr,
}
(*cur_insn_ptr) = new_insn;
}
-
+
*nr_insns += 1;
return (*cur_insn_ptr);
@@ -435,27 +422,24 @@ extern void
gen_entry_traverse_tree (lf *file,
gen_entry *table,
int depth,
- gen_entry_handler *start,
- gen_entry_handler *leaf,
- gen_entry_handler *end,
- void *data)
+ gen_entry_handler * start,
+ gen_entry_handler * leaf,
+ gen_entry_handler * end, void *data)
{
gen_entry *entry;
-
- ASSERT (table != NULL);
+
+ ASSERT (table !=NULL);
ASSERT (table->opcode != NULL);
ASSERT (table->nr_entries > 0);
ASSERT (table->entries != 0);
-
+
/* prefix */
if (start != NULL && depth >= 0)
{
start (file, table, depth, data);
}
/* infix leaves */
- for (entry = table->entries;
- entry != NULL;
- entry = entry->sibling)
+ for (entry = table->entries; entry != NULL; entry = entry->sibling)
{
if (entry->entries != NULL && depth != 0)
{
@@ -482,9 +466,7 @@ gen_entry_traverse_tree (lf *file,
/* create a list element containing a single gen_table entry */
static gen_list *
-make_table (insn_table *isa,
- decode_table *rules,
- model_entry *model)
+make_table (insn_table *isa, decode_table *rules, model_entry *model)
{
insn_entry *insn;
gen_list *entry = ZALLOC (gen_list);
@@ -498,12 +480,9 @@ make_table (insn_table *isa,
|| insn->processors == NULL
|| filter_is_member (insn->processors, model->name))
{
- insn_list_insert (&entry->table->insns,
- &entry->table->nr_insns,
- insn,
- NULL, /* expanded_bits - none yet */
- NULL, /* opcodes - none yet */
- 0, /* nr_prefetched_words - none yet */
+ insn_list_insert (&entry->table->insns, &entry->table->nr_insns, insn, NULL, /* expanded_bits - none yet */
+ NULL, /* opcodes - none yet */
+ 0, /* nr_prefetched_words - none yet */
report_duplicate_insns);
}
}
@@ -513,8 +492,7 @@ make_table (insn_table *isa,
gen_table *
-make_gen_tables (insn_table *isa,
- decode_table *rules)
+make_gen_tables (insn_table *isa, decode_table *rules)
{
gen_table *gen = ZALLOC (gen_table);
gen->isa = isa;
@@ -528,9 +506,7 @@ make_gen_tables (insn_table *isa,
processors = options.model_filter;
else
processors = isa->model->processors;
- for (model = isa->model->models;
- model != NULL;
- model = model->next)
+ for (model = isa->model->models; model != NULL; model = model->next)
{
if (filter_is_member (processors, model->name))
{
@@ -545,21 +521,22 @@ make_gen_tables (insn_table *isa,
}
return gen;
}
-
-
+
+
/****************************************************************/
#if 0
-typedef enum {
+typedef enum
+{
field_is_not_constant = 0,
field_constant_int = 1,
field_constant_reserved = 2,
field_constant_string = 3
-} constant_field_types;
+}
+constant_field_types;
static constant_field_types
-insn_field_is_constant (insn_field *field,
- decode_table *rule)
+insn_field_is_constant (insn_field * field, decode_table *rule)
{
switch (field->type)
{
@@ -573,7 +550,7 @@ insn_field_is_constant (insn_field *field,
else
return field_is_not_constant;
case insn_field_wild:
- return field_is_not_constant; /* never constant */
+ return field_is_not_constant; /* never constant */
case insn_field_string:
/* field, though variable, is on the list of forced constants */
if (filter_is_member (rule->constant_field_names, field->val_string))
@@ -593,13 +570,11 @@ insn_field_is_constant (insn_field *field,
/* Is the bit, according to the decode rule, identical across all the
instructions? */
static int
-insns_bit_useless (insn_list *insns,
- decode_table *rule,
- int bit_nr)
+insns_bit_useless (insn_list *insns, decode_table *rule, int bit_nr)
{
insn_list *entry;
int value = -1;
- int is_useless = 1; /* cleared if something actually found */
+ int is_useless = 1; /* cleared if something actually found */
/* check the instructions for some constant value in at least one of
the bit fields */
@@ -625,9 +600,9 @@ insns_bit_useless (insn_list *insns,
case decode_find_constants:
case decode_find_mixed:
/* an integer is useful if its value isn't the same
- between all instructions. The first time through the
- value is saved, the second time through (if the
- values differ) it is marked as useful. */
+ between all instructions. The first time through the
+ value is saved, the second time through (if the
+ values differ) it is marked as useful. */
if (value < 0)
value = bit->value;
else if (value != bit->value)
@@ -684,14 +659,13 @@ insns_bit_useless (insn_list *insns,
break;
case decode_find_mixed:
/* string field with conditions. If this condition
- eliminates the value then the compare is useful */
+ eliminates the value then the compare is useful */
if (bit->field->conditions != NULL)
{
insn_field_cond *condition;
int shift = bit->field->last - bit_nr;
for (condition = bit->field->conditions;
- condition != NULL;
- condition = condition->next)
+ condition != NULL; condition = condition->next)
{
switch (condition->type)
{
@@ -702,14 +676,14 @@ insns_bit_useless (insn_list *insns,
if (((condition->value >> shift) & 1)
== (unsigned) value)
/* conditional field excludes the
- current value */
+ current value */
is_useless = 0;
break;
case insn_field_cond_eq:
if (((condition->value >> shift) & 1)
!= (unsigned) value)
/* conditional field requires the
- current value */
+ current value */
is_useless = 0;
break;
}
@@ -734,8 +708,7 @@ insns_bit_useless (insn_list *insns,
static opcode_field *
gen_entry_find_opcode_field (insn_list *insns,
- decode_table *rule,
- int string_only)
+ decode_table *rule, int string_only)
{
opcode_field curr_opcode;
ASSERT (rule != NULL);
@@ -751,14 +724,14 @@ gen_entry_find_opcode_field (insn_list *insns,
while (curr_opcode.first <= rule->last)
{
if (insns_bit_useless (insns, rule, curr_opcode.first))
- curr_opcode.first ++;
+ curr_opcode.first++;
else
break;
}
while (curr_opcode.last >= rule->first)
{
if (insns_bit_useless (insns, rule, curr_opcode.last))
- curr_opcode.last --;
+ curr_opcode.last--;
else
break;
}
@@ -769,62 +742,66 @@ gen_entry_find_opcode_field (insn_list *insns,
{
insn_word_entry *fields = entry->insn->word[rule->word_nr];
opcode_field new_opcode;
-
+
ASSERT (fields != NULL);
-
+
/* find a start point for the opcode field */
new_opcode.first = rule->first;
while (new_opcode.first <= rule->last
&& (!string_only
- || (insn_field_is_constant(fields->bit[new_opcode.first], rule)
- != field_constant_string))
- && (string_only
- || (insn_field_is_constant(fields->bit[new_opcode.first], rule)
- == field_is_not_constant)))
+ ||
+ (insn_field_is_constant (fields->bit[new_opcode.first], rule)
+ != field_constant_string)) && (string_only
+ ||
+ (insn_field_is_constant
+ (fields->
+ bit[new_opcode.first],
+ rule) ==
+ field_is_not_constant)))
{
int new_first = fields->bit[new_opcode.first]->last + 1;
ASSERT (new_first > new_opcode.first);
new_opcode.first = new_first;
}
- ASSERT(new_opcode.first > rule->last
- || (string_only
- && insn_field_is_constant(fields->bit[new_opcode.first],
- rule) == field_constant_string)
- || (!string_only
- && insn_field_is_constant(fields->bit[new_opcode.first],
- rule)));
-
+ ASSERT (new_opcode.first > rule->last
+ || (string_only
+ && insn_field_is_constant (fields->bit[new_opcode.first],
+ rule) == field_constant_string)
+ || (!string_only
+ && insn_field_is_constant (fields->bit[new_opcode.first],
+ rule)));
+
/* find the end point for the opcode field */
new_opcode.last = rule->last;
while (new_opcode.last >= rule->first
&& (!string_only
- || insn_field_is_constant(fields->bit[new_opcode.last],
- rule) != field_constant_string)
+ || insn_field_is_constant (fields->bit[new_opcode.last],
+ rule) != field_constant_string)
&& (string_only
- || !insn_field_is_constant(fields->bit[new_opcode.last],
- rule)))
+ || !insn_field_is_constant (fields->bit[new_opcode.last],
+ rule)))
{
int new_last = fields->bit[new_opcode.last]->first - 1;
ASSERT (new_last < new_opcode.last);
new_opcode.last = new_last;
}
- ASSERT(new_opcode.last < rule->first
- || (string_only
- && insn_field_is_constant(fields->bit[new_opcode.last],
- rule) == field_constant_string)
- || (!string_only
- && insn_field_is_constant(fields->bit[new_opcode.last],
- rule)));
-
+ ASSERT (new_opcode.last < rule->first
+ || (string_only
+ && insn_field_is_constant (fields->bit[new_opcode.last],
+ rule) == field_constant_string)
+ || (!string_only
+ && insn_field_is_constant (fields->bit[new_opcode.last],
+ rule)));
+
/* now see if our current opcode needs expanding to include the
- interesting fields within this instruction */
+ interesting fields within this instruction */
if (new_opcode.first <= rule->last
&& curr_opcode.first > new_opcode.first)
curr_opcode.first = new_opcode.first;
if (new_opcode.last >= rule->first
&& curr_opcode.last < new_opcode.last)
curr_opcode.last = new_opcode.last;
-
+
}
#endif
@@ -839,21 +816,18 @@ gen_entry_find_opcode_field (insn_list *insns,
/* Ensure that, for the non string only case, the opcode includes
the range forced_first .. forced_last */
- if (!string_only
- && curr_opcode.first > rule->force_first)
+ if (!string_only && curr_opcode.first > rule->force_first)
{
curr_opcode.first = rule->force_first;
}
- if (!string_only
- && curr_opcode.last < rule->force_last)
+ if (!string_only && curr_opcode.last < rule->force_last)
{
curr_opcode.last = rule->force_last;
}
/* For the string only case, force just the lower bound (so that the
shift can be eliminated) */
- if (string_only
- && rule->force_last == options.insn_bit_size - 1)
+ if (string_only && rule->force_last == options.insn_bit_size - 1)
{
curr_opcode.last = options.insn_bit_size - 1;
}
@@ -883,20 +857,19 @@ gen_entry_find_opcode_field (insn_list *insns,
static void
gen_entry_insert_insn (gen_entry *table,
- insn_entry *old_insn,
+ insn_entry * old_insn,
int new_word_nr,
int new_nr_prefetched_words,
- int new_opcode_nr,
- opcode_bits *new_bits)
+ int new_opcode_nr, opcode_bits *new_bits)
{
gen_entry **entry = &table->entries;
-
+
/* find the new table for this entry */
while ((*entry) != NULL && (*entry)->opcode_nr < new_opcode_nr)
{
entry = &(*entry)->sibling;
}
-
+
if ((*entry) == NULL || (*entry)->opcode_nr != new_opcode_nr)
{
/* insert the missing entry */
@@ -915,22 +888,17 @@ gen_entry_insert_insn (gen_entry *table,
}
/* ASSERT new_bits == cur_entry bits */
ASSERT ((*entry) != NULL && (*entry)->opcode_nr == new_opcode_nr);
- insn_list_insert (&(*entry)->insns,
- &(*entry)->nr_insns,
- old_insn,
- NULL, /* expanded_bits - only in final list */
- NULL, /* opcodes - only in final list */
- new_nr_prefetched_words, /* for this table */
+ insn_list_insert (&(*entry)->insns, &(*entry)->nr_insns, old_insn, NULL, /* expanded_bits - only in final list */
+ NULL, /* opcodes - only in final list */
+ new_nr_prefetched_words, /* for this table */
report_duplicate_insns);
}
static void
gen_entry_expand_opcode (gen_entry *table,
- insn_entry *instruction,
- int bit_nr,
- int opcode_nr,
- opcode_bits *bits)
+ insn_entry * instruction,
+ int bit_nr, int opcode_nr, opcode_bits *bits)
{
if (bit_nr > table->opcode->last)
{
@@ -943,21 +911,20 @@ gen_entry_expand_opcode (gen_entry *table,
opcode_nr,
instruction->format_name,
instruction->name,
- (table->opcode_rule->with_duplicates ? " (duplicated)" : ""));
+ (table->opcode_rule->
+ with_duplicates ? " (duplicated)" : ""));
}
if (table->opcode_rule->with_duplicates)
{
gen_entry_insert_insn (table, instruction,
table->opcode->word_nr,
- table->nr_prefetched_words,
- opcode_nr, bits);
+ table->nr_prefetched_words, opcode_nr, bits);
}
else
{
gen_entry_insert_insn (table, instruction,
table->opcode->word_nr,
- table->nr_prefetched_words,
- opcode_nr, NULL);
+ table->nr_prefetched_words, opcode_nr, NULL);
}
}
else
@@ -965,23 +932,19 @@ gen_entry_expand_opcode (gen_entry *table,
insn_word_entry *word = instruction->word[table->opcode->word_nr];
insn_field_entry *field = word->bit[bit_nr]->field;
int last_pos = ((field->last < table->opcode->last)
- ? field->last
- : table->opcode->last);
+ ? field->last : table->opcode->last);
int first_pos = ((field->first > table->opcode->first)
- ? field->first
- : table->opcode->first);
+ ? field->first : table->opcode->first);
int width = last_pos - first_pos + 1;
switch (field->type)
{
case insn_field_int:
{
int val;
- val = sub_val (field->val_int, field->last,
- first_pos, last_pos);
+ val = sub_val (field->val_int, field->last, first_pos, last_pos);
gen_entry_expand_opcode (table, instruction,
last_pos + 1,
- ((opcode_nr << width) | val),
- bits);
+ ((opcode_nr << width) | val), bits);
break;
}
default:
@@ -989,18 +952,15 @@ gen_entry_expand_opcode (gen_entry *table,
if (field->type == insn_field_reserved)
gen_entry_expand_opcode (table, instruction,
last_pos + 1,
- ((opcode_nr << width)),
- bits);
+ ((opcode_nr << width)), bits);
else
{
int val;
- int last_val = (table->opcode->is_boolean
- ? 2
- : (1 << width));
+ int last_val = (table->opcode->is_boolean ? 2 : (1 << width));
for (val = 0; val < last_val; val++)
{
/* check to see if the value has been precluded
- (by a conditional) in some way */
+ (by a conditional) in some way */
int is_precluded;
insn_field_cond *condition;
for (condition = field->conditions, is_precluded = 0;
@@ -1011,8 +971,9 @@ gen_entry_expand_opcode (gen_entry *table,
{
case insn_field_cond_value:
{
- int value = sub_val (condition->value, field->last,
- first_pos, last_pos);
+ int value =
+ sub_val (condition->value, field->last,
+ first_pos, last_pos);
switch (condition->test)
{
case insn_field_cond_ne:
@@ -1032,51 +993,62 @@ gen_entry_expand_opcode (gen_entry *table,
opcode_bits *bit;
gen_entry *t = NULL;
/* Try to find a value for the
- conditional by looking back through
- the previously defined bits for one
- that covers the designated
- conditional field */
- for (bit = bits;
- bit != NULL;
- bit = bit->next)
+ conditional by looking back through
+ the previously defined bits for one
+ that covers the designated
+ conditional field */
+ for (bit = bits; bit != NULL; bit = bit->next)
{
- if (bit->field->word_nr == condition->field->word_nr
+ if (bit->field->word_nr ==
+ condition->field->word_nr
&& bit->first <= condition->field->first
&& bit->last >= condition->field->last)
{
/* the bit field fully specified
- the conditional field's value */
+ the conditional field's value */
value = sub_val (bit->value, bit->last,
- condition->field->first,
- condition->field->last);
+ condition->field->
+ first,
+ condition->field->
+ last);
}
}
/* Try to find a value by looking
- through this and previous tables */
+ through this and previous tables */
if (bit == NULL)
{
for (t = table;
- t->parent != NULL;
- t = t->parent)
+ t->parent != NULL; t = t->parent)
{
- if (t->parent->opcode->word_nr == condition->field->word_nr
- && t->parent->opcode->first <= condition->field->first
- && t->parent->opcode->last >= condition->field->last)
+ if (t->parent->opcode->word_nr ==
+ condition->field->word_nr
+ && t->parent->opcode->first <=
+ condition->field->first
+ && t->parent->opcode->last >=
+ condition->field->last)
{
/* the table entry fully
- specified the condition
- field's value */
+ specified the condition
+ field's value */
/* extract the field's value
- from the opcode */
- value = sub_val (t->opcode_nr, t->parent->opcode->last,
- condition->field->first, condition->field->last);
+ from the opcode */
+ value =
+ sub_val (t->opcode_nr,
+ t->parent->opcode->last,
+ condition->field->first,
+ condition->field->last);
/* this is a requirement of
- a conditonal field
- refering to another field */
- ASSERT ((condition->field->first - condition->field->last)
- == (first_pos - last_pos));
-printf ("value=%d, opcode_nr=%d, last=%d, [%d..%d]\n",
- value, t->opcode_nr, t->parent->opcode->last, condition->field->first, condition->field->last);
+ a conditonal field
+ refering to another field */
+ ASSERT ((condition->field->first -
+ condition->field->last) ==
+ (first_pos - last_pos));
+ printf
+ ("value=%d, opcode_nr=%d, last=%d, [%d..%d]\n",
+ value, t->opcode_nr,
+ t->parent->opcode->last,
+ condition->field->first,
+ condition->field->last);
}
}
}
@@ -1102,25 +1074,26 @@ printf ("value=%d, opcode_nr=%d, last=%d, [%d..%d]\n",
if (!is_precluded)
{
/* Only add additional hardwired bit
- information if the entry is not going to
- later be combined */
+ information if the entry is not going to
+ later be combined */
if (table->opcode_rule->with_combine)
{
gen_entry_expand_opcode (table, instruction,
last_pos + 1,
- ((opcode_nr << width) | val),
- bits);
+ ((opcode_nr << width) |
+ val), bits);
}
else
{
- opcode_bits *new_bits = new_opcode_bits (bits, val,
- first_pos, last_pos,
- field,
- table->opcode);
+ opcode_bits *new_bits =
+ new_opcode_bits (bits, val,
+ first_pos, last_pos,
+ field,
+ table->opcode);
gen_entry_expand_opcode (table, instruction,
last_pos + 1,
- ((opcode_nr << width) | val),
- new_bits);
+ ((opcode_nr << width) |
+ val), new_bits);
}
}
}
@@ -1131,28 +1104,24 @@ printf ("value=%d, opcode_nr=%d, last=%d, [%d..%d]\n",
}
static void
-gen_entry_insert_expanding (gen_entry *table,
- insn_entry *instruction)
+gen_entry_insert_expanding (gen_entry *table, insn_entry * instruction)
{
gen_entry_expand_opcode (table,
instruction,
- table->opcode->first,
- 0,
- table->expanded_bits);
+ table->opcode->first, 0, table->expanded_bits);
}
static int
-insns_match_format_names (insn_list *insns,
- filter *format_names)
+insns_match_format_names (insn_list *insns, filter *format_names)
{
if (format_names != NULL)
{
insn_list *i;
for (i = insns; i != NULL; i = i->next)
{
- if ( i->insn->format_name != NULL
- && !filter_is_member (format_names, i->insn->format_name))
+ if (i->insn->format_name != NULL
+ && !filter_is_member (format_names, i->insn->format_name))
return 0;
}
}
@@ -1160,8 +1129,7 @@ insns_match_format_names (insn_list *insns,
}
static int
-table_matches_path (gen_entry *table,
- decode_path_list *paths)
+table_matches_path (gen_entry *table, decode_path_list *paths)
{
if (paths == NULL)
return 1;
@@ -1187,8 +1155,7 @@ table_matches_path (gen_entry *table,
static int
-insns_match_conditions (insn_list *insns,
- decode_cond *conditions)
+insns_match_conditions (insn_list *insns, decode_cond *conditions)
{
if (conditions != NULL)
{
@@ -1208,8 +1175,7 @@ insns_match_conditions (insn_list *insns,
if (!i->insn->word[cond->word_nr]->bit[bit_nr]->mask)
return 0;
if ((i->insn->word[cond->word_nr]->bit[bit_nr]->value
- == cond->value[bit_nr])
- == !cond->is_equal)
+ == cond->value[bit_nr]) == !cond->is_equal)
return 0;
}
}
@@ -1219,8 +1185,7 @@ insns_match_conditions (insn_list *insns,
}
static int
-insns_match_nr_words (insn_list *insns,
- int nr_words)
+insns_match_nr_words (insn_list *insns, int nr_words)
{
insn_list *i;
for (i = insns; i != NULL; i = i->next)
@@ -1232,8 +1197,7 @@ insns_match_nr_words (insn_list *insns,
}
static int
-insn_list_cmp (insn_list *l,
- insn_list *r)
+insn_list_cmp (insn_list *l, insn_list *r)
{
while (1)
{
@@ -1245,7 +1209,7 @@ insn_list_cmp (insn_list *l,
if (r == NULL)
return 1;
if (l->insn != r->insn)
- return -1; /* somewhat arbitrary at present */
+ return -1; /* somewhat arbitrary at present */
/* skip this insn */
insn = l->insn;
while (l != NULL && l->insn == insn)
@@ -1262,12 +1226,11 @@ gen_entry_expand_insns (gen_entry *table)
{
decode_table *opcode_rule;
- ASSERT(table->nr_insns >= 1);
-
+ ASSERT (table->nr_insns >= 1);
+
/* determine a valid opcode */
for (opcode_rule = table->opcode_rule;
- opcode_rule != NULL;
- opcode_rule = opcode_rule->next)
+ opcode_rule != NULL; opcode_rule = opcode_rule->next)
{
char *discard_reason;
if (table->top->model != NULL
@@ -1281,17 +1244,19 @@ gen_entry_expand_insns (gen_entry *table)
else if (table->nr_insns == 1 && opcode_rule->conditions == NULL)
{
/* for safety, require a pre-codition when attempting to
- apply a rule to a single instruction */
+ apply a rule to a single instruction */
discard_reason = "need pre-condition when nr-insn == 1";
}
else if (table->nr_insns == 1 && !opcode_rule->with_duplicates)
{
/* Little point in expanding a single instruction when we're
- not duplicating the semantic functions that this table
- calls */
+ not duplicating the semantic functions that this table
+ calls */
discard_reason = "need duplication with nr-insns == 1";
}
- else if (!insns_match_format_names (table->insns, opcode_rule->format_names))
+ else
+ if (!insns_match_format_names
+ (table->insns, opcode_rule->format_names))
{
discard_reason = "wrong format name";
}
@@ -1303,18 +1268,18 @@ gen_entry_expand_insns (gen_entry *table)
{
discard_reason = "path failed";
}
- else if (!insns_match_conditions (table->insns, opcode_rule->conditions))
+ else
+ if (!insns_match_conditions (table->insns, opcode_rule->conditions))
{
discard_reason = "condition failed";
}
else
{
discard_reason = "no opcode field";
- table->opcode =
- gen_entry_find_opcode_field (table->insns,
- opcode_rule,
- table->nr_insns == 1/*string-only*/
- );
+ table->opcode = gen_entry_find_opcode_field (table->insns,
+ opcode_rule,
+ table->nr_insns == 1 /*string-only */
+ );
if (table->opcode != NULL)
{
table->opcode_rule = opcode_rule;
@@ -1328,7 +1293,7 @@ gen_entry_expand_insns (gen_entry *table)
notify (NULL, ": rule discarded - %s\n", discard_reason);
}
}
-
+
/* did we find anything */
if (opcode_rule == NULL)
{
@@ -1348,7 +1313,8 @@ gen_entry_expand_insns (gen_entry *table)
this table to function */
if (table->parent == NULL)
table->nr_prefetched_words = table->opcode_rule->word_nr + 1;
- else if (table->opcode_rule->word_nr + 1 > table->parent->nr_prefetched_words)
+ else if (table->opcode_rule->word_nr + 1 >
+ table->parent->nr_prefetched_words)
table->nr_prefetched_words = table->opcode_rule->word_nr + 1;
else
table->nr_prefetched_words = table->parent->nr_prefetched_words;
@@ -1356,7 +1322,7 @@ gen_entry_expand_insns (gen_entry *table)
/* back link what we found to its parent */
if (table->parent != NULL)
{
- ASSERT(table->parent->opcode != NULL);
+ ASSERT (table->parent->opcode != NULL);
table->opcode->parent = table->parent->opcode;
}
@@ -1371,8 +1337,7 @@ gen_entry_expand_insns (gen_entry *table)
i2target (options.hi_bit_nr, table->opcode->last),
i2target (options.hi_bit_nr, table->opcode_rule->first),
i2target (options.hi_bit_nr, table->opcode_rule->last),
- table->opcode->nr_opcodes,
- table->nr_entries);
+ table->opcode->nr_opcodes, table->nr_entries);
}
/* expand the raw instructions according to the opcode */
@@ -1384,8 +1349,7 @@ gen_entry_expand_insns (gen_entry *table)
{
print_gen_entry_path (table->opcode_rule->line, table, notify);
notify (NULL, ": expand - %s.%s\n",
- entry->insn->format_name,
- entry->insn->name);
+ entry->insn->format_name, entry->insn->name);
}
gen_entry_insert_expanding (table, entry->insn);
}
@@ -1400,14 +1364,13 @@ gen_entry_expand_insns (gen_entry *table)
insn_list *l;
print_gen_entry_path (table->opcode_rule->line, entry, notify);
notify (NULL, ": %d - entries %d -",
- entry->opcode_nr,
- entry->nr_insns);
+ entry->opcode_nr, entry->nr_insns);
for (l = entry->insns; l != NULL; l = l->next)
notify (NULL, " %s.%s", l->insn->format_name, l->insn->name);
notify (NULL, "\n");
}
}
-
+
/* perform a combine pass if needed */
if (table->opcode_rule->with_combine)
{
@@ -1441,9 +1404,9 @@ gen_entry_expand_insns (gen_entry *table)
insn_list *l;
gen_entry *duplicate;
nr_unique++;
- print_gen_entry_path (table->opcode_rule->line, entry, notify);
- for (duplicate = entry->combined_next;
- duplicate != NULL;
+ print_gen_entry_path (table->opcode_rule->line, entry,
+ notify);
+ for (duplicate = entry->combined_next; duplicate != NULL;
duplicate = duplicate->combined_next)
{
notify (NULL, "+%d", duplicate->opcode_nr);
@@ -1452,42 +1415,42 @@ gen_entry_expand_insns (gen_entry *table)
for (l = entry->insns; l != NULL; l = l->next)
{
notify (NULL, " %s.%s",
- l->insn->format_name,
- l->insn->name);
+ l->insn->format_name, l->insn->name);
}
notify (NULL, "\n");
}
}
print_gen_entry_path (table->opcode_rule->line, table, notify);
- notify (NULL, ": combine - word %d, bits [%d..%d] in [%d..%d], opcodes %d, entries %d, unique %d\n",
- table->opcode->word_nr,
- i2target (options.hi_bit_nr, table->opcode->first),
+ notify (NULL,
+ ": combine - word %d, bits [%d..%d] in [%d..%d], opcodes %d, entries %d, unique %d\n",
+ table->opcode->word_nr, i2target (options.hi_bit_nr,
+ table->opcode->first),
i2target (options.hi_bit_nr, table->opcode->last),
i2target (options.hi_bit_nr, table->opcode_rule->first),
i2target (options.hi_bit_nr, table->opcode_rule->last),
- table->opcode->nr_opcodes,
- table->nr_entries,
- nr_unique);
+ table->opcode->nr_opcodes, table->nr_entries, nr_unique);
}
}
-
+
/* Check that the rule did more than re-arange the order of the
instructions */
{
- gen_entry *entry;
- for (entry = table->entries; entry != NULL; entry = entry->sibling)
- {
- if (entry->combined_parent == NULL)
- {
- if (insn_list_cmp (table->insns, entry->insns) == 0)
- {
- print_gen_entry_path (table->opcode_rule->line, table, warning);
- warning (NULL, ": Applying rule just copied all instructions\n");
- print_gen_entry_insns (entry, warning, "Copied", NULL);
- error (NULL, "");
- }
- }
- }
+ gen_entry *entry;
+ for (entry = table->entries; entry != NULL; entry = entry->sibling)
+ {
+ if (entry->combined_parent == NULL)
+ {
+ if (insn_list_cmp (table->insns, entry->insns) == 0)
+ {
+ print_gen_entry_path (table->opcode_rule->line, table,
+ warning);
+ warning (NULL,
+ ": Applying rule just copied all instructions\n");
+ print_gen_entry_insns (entry, warning, "Copied", NULL);
+ error (NULL, "");
+ }
+ }
+ }
}
/* if some form of expanded table, fill in the missing dots */
@@ -1507,10 +1470,7 @@ gen_entry_expand_insns (gen_entry *table)
if ((*entry) == NULL || (*entry)->opcode_nr != opcode_nr)
{
/* missing - insert it under our feet at *entry */
- gen_entry_insert_insn (table,
- table->top->isa->illegal_insn,
- table->opcode->word_nr,
- 0, /* nr_prefetched_words == 0 for invalid */
+ gen_entry_insert_insn (table, table->top->isa->illegal_insn, table->opcode->word_nr, 0, /* nr_prefetched_words == 0 for invalid */
opcode_nr, NULL);
ASSERT ((*entry) != NULL);
ASSERT ((*entry)->opcode_nr == opcode_nr);
@@ -1522,7 +1482,7 @@ gen_entry_expand_insns (gen_entry *table)
opcode_nr++;
}
/* oops, will have pointed the first illegal insn back to
- its self. Fix this */
+ its self. Fix this */
if (illegals != NULL)
illegals->combined_parent = NULL;
}
@@ -1537,7 +1497,7 @@ gen_entry_expand_insns (gen_entry *table)
expand entries that haven't been combined. */
{
gen_entry *entry;
- for (entry = table->entries; entry != NULL; entry = entry->sibling)
+ for (entry = table->entries; entry != NULL; entry = entry->sibling)
{
if (entry->combined_parent == NULL)
{
@@ -1563,12 +1523,9 @@ gen_tables_expand_insns (gen_table *gen)
worked. */
static void
-make_gen_semantics_list (lf *file,
- gen_entry *entry,
- int depth,
- void *data)
+make_gen_semantics_list (lf *file, gen_entry *entry, int depth, void *data)
{
- gen_table *gen = (gen_table*) data;
+ gen_table *gen = (gen_table *) data;
insn_list *insn;
/* Not interested in an entrie that have been combined into some
other entry at the same level */
@@ -1598,14 +1555,12 @@ gen_tables_expand_semantics (gen_table *gen)
gen_list *entry;
for (entry = gen->tables; entry != NULL; entry = entry->next)
{
- gen_entry_traverse_tree (NULL,
- entry->table,
- 1, /* depth */
- NULL, /* start-handler */
- make_gen_semantics_list, /* leaf-handler */
- NULL, /* end-handler */
- gen); /* data */
- }
+ gen_entry_traverse_tree (NULL, entry->table, 1, /* depth */
+ NULL, /* start-handler */
+ make_gen_semantics_list, /* leaf-handler */
+ NULL, /* end-handler */
+ gen); /* data */
+ }
}
@@ -1616,34 +1571,30 @@ gen_tables_expand_semantics (gen_table *gen)
static void
dump_opcode_field (lf *file,
char *prefix,
- opcode_field *field,
- char *suffix,
- int levels)
+ opcode_field *field, char *suffix, int levels)
{
lf_printf (file, "%s(opcode_field *) 0x%lx", prefix, (long) field);
- if (levels && field != NULL) {
- lf_indent (file, +1);
- lf_printf (file, "\n(first %d)", field->first);
- lf_printf (file, "\n(last %d)", field->last);
- lf_printf (file, "\n(nr_opcodes %d)", field->nr_opcodes);
- lf_printf (file, "\n(is_boolean %d)", field->is_boolean);
- lf_printf (file, "\n(boolean_constant %d)", field->boolean_constant);
- dump_opcode_field(file, "\n(parent ", field->parent, ")", levels - 1);
- lf_indent (file, -1);
- }
+ if (levels && field != NULL)
+ {
+ lf_indent (file, +1);
+ lf_printf (file, "\n(first %d)", field->first);
+ lf_printf (file, "\n(last %d)", field->last);
+ lf_printf (file, "\n(nr_opcodes %d)", field->nr_opcodes);
+ lf_printf (file, "\n(is_boolean %d)", field->is_boolean);
+ lf_printf (file, "\n(boolean_constant %d)", field->boolean_constant);
+ dump_opcode_field (file, "\n(parent ", field->parent, ")", levels - 1);
+ lf_indent (file, -1);
+ }
lf_printf (file, "%s", suffix);
}
static void
dump_opcode_bits (lf *file,
- char *prefix,
- opcode_bits *bits,
- char *suffix,
- int levels)
+ char *prefix, opcode_bits *bits, char *suffix, int levels)
{
lf_printf (file, "%s(opcode_bits *) 0x%lx", prefix, (long) bits);
-
+
if (levels && bits != NULL)
{
lf_indent (file, +1);
@@ -1659,28 +1610,25 @@ dump_opcode_bits (lf *file,
static void
-dump_insn_list (lf *file,
- char *prefix,
- insn_list *entry,
- char *suffix)
+dump_insn_list (lf *file, char *prefix, insn_list *entry, char *suffix)
{
lf_printf (file, "%s(insn_list *) 0x%lx", prefix, (long) entry);
- if (entry != NULL) {
- lf_indent (file, +1);
- dump_insn_entry (file, "\n(insn ", entry->insn, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
- lf_indent (file, -1);
- }
+ if (entry != NULL)
+ {
+ lf_indent (file, +1);
+ dump_insn_entry (file, "\n(insn ", entry->insn, ")");
+ lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_indent (file, -1);
+ }
lf_printf (file, "%s", suffix);
}
static void
dump_insn_word_entry_list_entries (lf *file,
- char *prefix,
- insn_list *entry,
- char *suffix)
+ char *prefix,
+ insn_list *entry, char *suffix)
{
lf_printf (file, "%s", prefix);
while (entry != NULL)
@@ -1694,39 +1642,37 @@ dump_insn_word_entry_list_entries (lf *file,
static void
dump_gen_entry (lf *file,
- char *prefix,
- gen_entry *table,
- char *suffix,
- int levels)
+ char *prefix, gen_entry *table, char *suffix, int levels)
{
lf_printf (file, "%s(gen_entry *) 0x%lx", prefix, (long) table);
- if (levels && table != NULL) {
-
- lf_indent (file, +1);
- lf_printf (file, "\n(opcode_nr %d)", table->opcode_nr);
- lf_printf (file, "\n(word_nr %d)", table->word_nr);
- dump_opcode_bits (file, "\n(expanded_bits ", table->expanded_bits, ")", -1);
- lf_printf (file, "\n(nr_insns %d)", table->nr_insns);
- dump_insn_word_entry_list_entries (file, "\n(insns ", table->insns, ")");
- dump_decode_rule (file, "\n(opcode_rule ", table->opcode_rule, ")");
- dump_opcode_field (file, "\n(opcode ", table->opcode, ")", 0);
- lf_printf (file, "\n(nr_entries %d)", table->nr_entries);
- dump_gen_entry (file, "\n(entries ", table->entries, ")", table->nr_entries);
- dump_gen_entry (file, "\n(sibling ", table->sibling, ")", levels - 1);
- dump_gen_entry (file, "\n(parent ", table->parent, ")", 0);
- lf_indent (file, -1);
- }
+ if (levels && table !=NULL)
+ {
+
+ lf_indent (file, +1);
+ lf_printf (file, "\n(opcode_nr %d)", table->opcode_nr);
+ lf_printf (file, "\n(word_nr %d)", table->word_nr);
+ dump_opcode_bits (file, "\n(expanded_bits ", table->expanded_bits, ")",
+ -1);
+ lf_printf (file, "\n(nr_insns %d)", table->nr_insns);
+ dump_insn_word_entry_list_entries (file, "\n(insns ", table->insns,
+ ")");
+ dump_decode_rule (file, "\n(opcode_rule ", table->opcode_rule, ")");
+ dump_opcode_field (file, "\n(opcode ", table->opcode, ")", 0);
+ lf_printf (file, "\n(nr_entries %d)", table->nr_entries);
+ dump_gen_entry (file, "\n(entries ", table->entries, ")",
+ table->nr_entries);
+ dump_gen_entry (file, "\n(sibling ", table->sibling, ")", levels - 1);
+ dump_gen_entry (file, "\n(parent ", table->parent, ")", 0);
+ lf_indent (file, -1);
+ }
lf_printf (file, "%s", suffix);
}
static void
dump_gen_list (lf *file,
- char *prefix,
- gen_list *entry,
- char *suffix,
- int levels)
+ char *prefix, gen_list *entry, char *suffix, int levels)
{
while (entry != NULL)
{
@@ -1740,10 +1686,7 @@ dump_gen_list (lf *file,
static void
dump_gen_table (lf *file,
- char *prefix,
- gen_table *gen,
- char *suffix,
- int levels)
+ char *prefix, gen_table *gen, char *suffix, int levels)
{
lf_printf (file, "%s(gen_table *) 0x%lx", prefix, (long) gen);
lf_printf (file, "\n(isa (insn_table *) 0x%lx)", (long) gen->isa);
@@ -1756,8 +1699,7 @@ dump_gen_table (lf *file,
igen_options options;
int
-main (int argc,
- char **argv)
+main (int argc, char **argv)
{
decode_table *decode_rules;
insn_table *instructions;
@@ -1765,16 +1707,17 @@ main (int argc,
lf *l;
if (argc != 7)
- error (NULL, "Usage: insn <filter-in> <hi-bit-nr> <insn-bit-size> <widths> <decode-table> <insn-table>\n");
+ error (NULL,
+ "Usage: insn <filter-in> <hi-bit-nr> <insn-bit-size> <widths> <decode-table> <insn-table>\n");
INIT_OPTIONS (options);
filter_parse (&options.flags_filter, argv[1]);
- options.hi_bit_nr = a2i(argv[2]);
- options.insn_bit_size = a2i(argv[3]);
- options.insn_specifying_widths = a2i(argv[4]);
- ASSERT(options.hi_bit_nr < options.insn_bit_size);
+ options.hi_bit_nr = a2i (argv[2]);
+ options.insn_bit_size = a2i (argv[3]);
+ options.insn_specifying_widths = a2i (argv[4]);
+ ASSERT (options.hi_bit_nr < options.insn_bit_size);
instructions = load_insn_table (argv[6], NULL);
decode_rules = load_decode_table (argv[5]);
diff --git a/sim/igen/gen.h b/sim/igen/gen.h
index c919fcc..073a831 100644
--- a/sim/igen/gen.h
+++ b/sim/igen/gen.h
@@ -23,7 +23,8 @@
typedef struct _opcode_field opcode_field;
-struct _opcode_field {
+struct _opcode_field
+{
int word_nr;
int first;
int last;
@@ -34,7 +35,8 @@ struct _opcode_field {
};
typedef struct _opcode_bits opcode_bits;
-struct _opcode_bits {
+struct _opcode_bits
+{
int value;
int first;
int last;
@@ -44,13 +46,15 @@ struct _opcode_bits {
};
typedef struct _insn_opcodes insn_opcodes;
-struct _insn_opcodes {
+struct _insn_opcodes
+{
opcode_field *opcode;
insn_opcodes *next;
};
typedef struct _insn_list insn_list;
-struct _insn_list {
+struct _insn_list
+{
/* the instruction */
insn_entry *insn;
/* list of non constant bits that have been made constant */
@@ -70,14 +74,15 @@ struct _insn_list {
typedef struct _gen_list gen_list;
typedef struct _gen_entry gen_entry;
-struct _gen_entry {
+struct _gen_entry
+{
/* as an entry in a table */
int word_nr;
int opcode_nr;
gen_entry *sibling;
opcode_bits *expanded_bits;
- gen_entry *parent; /* parent has the opcode* data */
+ gen_entry *parent; /* parent has the opcode* data */
/* as a table containing entries */
decode_table *opcode_rule;
@@ -99,7 +104,8 @@ struct _gen_entry {
};
-struct _gen_list {
+struct _gen_list
+{
model_entry *model;
insn_table *isa;
gen_entry *table;
@@ -108,7 +114,8 @@ struct _gen_list {
typedef struct _gen_table gen_table;
-struct _gen_table {
+struct _gen_table
+{
/* list of all the instructions */
insn_table *isa;
/* list of all the semantic functions */
@@ -121,38 +128,28 @@ struct _gen_table {
};
-extern gen_table *make_gen_tables
-(insn_table *isa,
- decode_table *rules);
+extern gen_table *make_gen_tables (insn_table *isa, decode_table *rules);
-extern void gen_tables_expand_insns
-(gen_table *gen);
+extern void gen_tables_expand_insns (gen_table *gen);
-extern void gen_tables_expand_semantics
-(gen_table *gen);
+extern void gen_tables_expand_semantics (gen_table *gen);
-extern int gen_entry_depth
-(gen_entry *table);
+extern int gen_entry_depth (gen_entry *table);
/* Traverse the created data structure */
typedef void gen_entry_handler
-(lf *file,
- gen_entry *entry,
- int depth,
- void *data);
+ (lf *file, gen_entry *entry, int depth, void *data);
extern void gen_entry_traverse_tree
-(lf *file,
- gen_entry *table,
- int depth,
- gen_entry_handler *start,
- gen_entry_handler *leaf,
- gen_entry_handler *end,
- void *data);
+ (lf *file,
+ gen_entry *table,
+ int depth,
+ gen_entry_handler * start,
+ gen_entry_handler * leaf, gen_entry_handler * end, void *data);
@@ -161,70 +158,57 @@ extern void gen_entry_traverse_tree
/* Cache functions: */
-extern int print_icache_function_formal
-(lf *file, int nr_prefetched_words);
+extern int print_icache_function_formal (lf *file, int nr_prefetched_words);
-extern int print_icache_function_actual
-(lf *file, int nr_prefetched_words);
+extern int print_icache_function_actual (lf *file, int nr_prefetched_words);
-extern int print_icache_function_type
-(lf *file);
+extern int print_icache_function_type (lf *file);
-extern int print_semantic_function_formal
-(lf *file, int nr_prefetched_words);
+extern int print_semantic_function_formal (lf *file, int nr_prefetched_words);
-extern int print_semantic_function_actual
-(lf *file, int nr_prefetched_words);
+extern int print_semantic_function_actual (lf *file, int nr_prefetched_words);
-extern int print_semantic_function_type
-(lf *file);
+extern int print_semantic_function_type (lf *file);
-extern int print_idecode_function_formal
-(lf *file, int nr_prefetched_words);
+extern int print_idecode_function_formal (lf *file, int nr_prefetched_words);
-extern int print_idecode_function_actual
-(lf *file, int nr_prefetched_words);
+extern int print_idecode_function_actual (lf *file, int nr_prefetched_words);
-typedef enum {
+typedef enum
+{
function_name_prefix_semantics,
function_name_prefix_idecode,
function_name_prefix_itable,
function_name_prefix_icache,
function_name_prefix_engine,
function_name_prefix_none
-} lf_function_name_prefixes;
+}
+lf_function_name_prefixes;
-typedef enum {
+typedef enum
+{
is_function_declaration = 0,
is_function_definition = 1,
is_function_variable,
-} function_decl_type;
+}
+function_decl_type;
extern int print_function_name
-(lf *file,
- const char *basename,
- const char *format_name,
- const char *model_name,
- opcode_bits *expanded_bits,
- lf_function_name_prefixes prefix);
+ (lf *file,
+ const char *basename,
+ const char *format_name,
+ const char *model_name,
+ opcode_bits *expanded_bits, lf_function_name_prefixes prefix);
extern void print_my_defines
-(lf *file,
- const char *basename,
- const char *format_name,
- opcode_bits *expanded_bits);
+ (lf *file,
+ const char *basename, const char *format_name, opcode_bits *expanded_bits);
-extern void print_itrace
-(lf *file,
- insn_entry *insn,
- int idecode);
+extern void print_itrace (lf *file, insn_entry * insn, int idecode);
-extern void print_sim_engine_abort
-(lf *file,
- const char *message);
+extern void print_sim_engine_abort (lf *file, const char *message);
extern void print_include (lf *file, igen_module module);
-extern void print_include_inline (lf *file, igen_module module);
+extern void print_include_inline (lf *file, igen_module module);
extern void print_includes (lf *file);
-
diff --git a/sim/igen/igen.c b/sim/igen/igen.c
index d51684b..d5896f2 100644
--- a/sim/igen/igen.c
+++ b/sim/igen/igen.c
@@ -55,8 +55,7 @@
/* Semantic functions */
int
-print_semantic_function_formal (lf *file,
- int nr_prefetched_words)
+print_semantic_function_formal (lf *file, int nr_prefetched_words)
{
int nr = 0;
int word_nr;
@@ -74,8 +73,7 @@ print_semantic_function_formal (lf *file,
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
{
nr += lf_printf (file, "%sinstruction_word instruction_%d,\n",
- options.module.global.prefix.l,
- word_nr);
+ options.module.global.prefix.l, word_nr);
}
nr += lf_printf (file, "%sinstruction_address cia",
options.module.global.prefix.l);
@@ -86,8 +84,7 @@ print_semantic_function_formal (lf *file,
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
{
nr += lf_printf (file, "%sinstruction_word instruction_%d,\n",
- options.module.global.prefix.l,
- word_nr);
+ options.module.global.prefix.l, word_nr);
}
nr += lf_printf (file, "%sinstruction_address cia",
options.module.global.prefix.l);
@@ -96,8 +93,7 @@ print_semantic_function_formal (lf *file,
}
int
-print_semantic_function_actual (lf *file,
- int nr_prefetched_words)
+print_semantic_function_actual (lf *file, int nr_prefetched_words)
{
int nr = 0;
int word_nr;
@@ -131,15 +127,14 @@ print_semantic_function_type (lf *file)
/* Idecode functions */
int
-print_icache_function_formal (lf *file,
- int nr_prefetched_words)
+print_icache_function_formal (lf *file, int nr_prefetched_words)
{
int nr = 0;
int word_nr;
if (options.gen.smp)
- nr += lf_printf (file, "sim_cpu *cpu,\n");
+ nr += lf_printf (file, "sim_cpu *cpu,\n");
else
- nr += lf_printf (file, "SIM_DESC sd,\n");
+ nr += lf_printf (file, "SIM_DESC sd,\n");
for (word_nr = 0; word_nr < nr_prefetched_words; word_nr++)
nr += lf_printf (file, " %sinstruction_word instruction_%d,\n",
options.module.global.prefix.l, word_nr);
@@ -151,8 +146,7 @@ print_icache_function_formal (lf *file,
}
int
-print_icache_function_actual (lf *file,
- int nr_prefetched_words)
+print_icache_function_actual (lf *file, int nr_prefetched_words)
{
int nr = 0;
int word_nr;
@@ -186,8 +180,7 @@ print_icache_function_type (lf *file)
/* Function names */
static int
-print_opcode_bits (lf *file,
- opcode_bits *bits)
+print_opcode_bits (lf *file, opcode_bits *bits)
{
int nr = 0;
if (bits == NULL)
@@ -196,19 +189,21 @@ print_opcode_bits (lf *file,
nr += lf_putstr (file, bits->field->val_string);
if (bits->opcode->is_boolean && bits->value == 0)
nr += lf_putint (file, bits->opcode->boolean_constant);
- else if (!bits->opcode->is_boolean) {
- if (bits->opcode->last < bits->field->last)
- nr += lf_putint (file, bits->value << (bits->field->last - bits->opcode->last));
- else
- nr += lf_putint (file, bits->value);
- }
+ else if (!bits->opcode->is_boolean)
+ {
+ if (bits->opcode->last < bits->field->last)
+ nr +=
+ lf_putint (file,
+ bits->value << (bits->field->last - bits->opcode->last));
+ else
+ nr += lf_putint (file, bits->value);
+ }
nr += print_opcode_bits (file, bits->next);
return nr;
}
static int
-print_c_name (lf *file,
- const char *name)
+print_c_name (lf *file, const char *name)
{
int nr = 0;
const char *pos;
@@ -264,7 +259,7 @@ print_function_name (lf *file,
default:
break;
}
-
+
if (model_name != NULL)
{
nr += print_c_name (file, model_name);
@@ -273,7 +268,7 @@ print_function_name (lf *file,
/* the function name */
nr += print_c_name (file, basename);
-
+
/* the format name if available */
if (format_name != NULL)
{
@@ -291,8 +286,7 @@ print_function_name (lf *file,
void
print_my_defines (lf *file,
const char *basename,
- const char *format_name,
- opcode_bits *expanded_bits)
+ const char *format_name, opcode_bits *expanded_bits)
{
/* #define MY_INDEX xxxxx */
lf_indent_suppress (file);
@@ -301,16 +295,14 @@ print_my_defines (lf *file,
lf_printf (file, "#define MY_INDEX ");
print_function_name (file,
basename, format_name, NULL,
- NULL,
- function_name_prefix_itable);
+ NULL, function_name_prefix_itable);
lf_printf (file, "\n");
/* #define MY_PREFIX xxxxxx */
lf_indent_suppress (file);
lf_printf (file, "#undef ");
print_function_name (file,
basename, format_name, NULL,
- expanded_bits,
- function_name_prefix_none);
+ expanded_bits, function_name_prefix_none);
lf_printf (file, "\n");
lf_indent_suppress (file);
lf_printf (file, "#undef MY_PREFIX\n");
@@ -318,8 +310,7 @@ print_my_defines (lf *file,
lf_printf (file, "#define MY_PREFIX ");
print_function_name (file,
basename, format_name, NULL,
- expanded_bits,
- function_name_prefix_none);
+ expanded_bits, function_name_prefix_none);
lf_printf (file, "\n");
/* #define MY_NAME xxxxxx */
lf_indent_suppress (file);
@@ -329,8 +320,7 @@ print_my_defines (lf *file,
lf_printf (file, "#define MY_NAME \"");
print_function_name (file,
basename, format_name, NULL,
- expanded_bits,
- function_name_prefix_none);
+ expanded_bits, function_name_prefix_none);
lf_printf (file, "\"\n");
}
@@ -340,18 +330,20 @@ print_itrace_prefix (lf *file)
{
const char *prefix = "trace_prefix (";
int indent = strlen (prefix);
- lf_printf (file, "%sSD, CPU, cia, CIA, TRACE_LINENUM_P (CPU), \\\n", prefix);
+ lf_printf (file, "%sSD, CPU, cia, CIA, TRACE_LINENUM_P (CPU), \\\n",
+ prefix);
lf_indent (file, +indent);
- lf_printf (file, "%sitable[MY_INDEX].file, \\\n", options.module.itable.prefix.l);
- lf_printf (file, "%sitable[MY_INDEX].line_nr, \\\n", options.module.itable.prefix.l);
+ lf_printf (file, "%sitable[MY_INDEX].file, \\\n",
+ options.module.itable.prefix.l);
+ lf_printf (file, "%sitable[MY_INDEX].line_nr, \\\n",
+ options.module.itable.prefix.l);
lf_printf (file, "\"");
return indent;
}
static void
-print_itrace_format (lf *file,
- insn_mnemonic_entry *assembler)
+print_itrace_format (lf *file, insn_mnemonic_entry *assembler)
{
/* pass=1 is fmt string; pass=2 is arguments */
int pass;
@@ -359,7 +351,7 @@ print_itrace_format (lf *file,
for (pass = 1; pass <= 2; pass++)
{
const char *chp = assembler->format;
- chp++; /* skip the leading quote */
+ chp++; /* skip the leading quote */
/* write out the format/args */
while (*chp != '\0')
{
@@ -399,7 +391,8 @@ print_itrace_format (lf *file,
}
strlen_param = chp - param;
if (chp[0] != '>')
- error (assembler->line, "Missing closing `>' in assembler string\n");
+ error (assembler->line,
+ "Missing closing `>' in assembler string\n");
chp++;
/* now process it */
if (pass == 2)
@@ -430,7 +423,8 @@ print_itrace_format (lf *file,
lf_printf (file, "%%s");
else
{
- lf_printf (file, "%sstr_", options.module.global.prefix.l);
+ lf_printf (file, "%sstr_",
+ options.module.global.prefix.l);
lf_write (file, func, strlen_func);
lf_printf (file, " (SD_, ");
lf_write (file, param, strlen_param);
@@ -449,7 +443,7 @@ print_itrace_format (lf *file,
}
}
else if (strncmp (fmt, "%#lx<", 5) == 0)
- /* simple hex with 0x prefix*/
+ /* simple hex with 0x prefix */
{
if (pass == 1)
lf_printf (file, "%%#lx");
@@ -486,9 +480,7 @@ print_itrace_format (lf *file,
void
-print_itrace (lf *file,
- insn_entry *insn,
- int idecode)
+print_itrace (lf *file, insn_entry * insn, int idecode)
{
/* NB: Here we escape each EOLN. This is so that the the compiler
treats a trace function call as a single line. Consequently any
@@ -513,8 +505,7 @@ print_itrace (lf *file,
{
int indent;
lf_printf (file, "%sif (%s)\n",
- is_first ? "" : "else ",
- assembler->condition);
+ is_first ? "" : "else ", assembler->condition);
lf_indent (file, +2);
lf_print__line_ref (file, assembler->line);
indent = print_itrace_prefix (file);
@@ -523,7 +514,8 @@ print_itrace (lf *file,
lf_indent (file, -indent);
lf_indent (file, -2);
if (assembler->next == NULL)
- error (assembler->line, "Missing final unconditional assembler\n");
+ error (assembler->line,
+ "Missing final unconditional assembler\n");
}
else
{
@@ -541,7 +533,8 @@ print_itrace (lf *file,
if (!is_first)
lf_indent (file, -2);
if (assembler->next != NULL)
- error (assembler->line, "Unconditional assembler is not last\n");
+ error (assembler->line,
+ "Unconditional assembler is not last\n");
}
is_first = 0;
assembler = assembler->next;
@@ -562,7 +555,9 @@ print_itrace (lf *file,
}
lf_printf (file, "/* trace the instruction execution if enabled */\n");
lf_printf (file, "if (TRACE_%s_P (CPU))\n", phase);
- lf_printf (file, " trace_generic (SD, CPU, TRACE_%s_IDX, \" %%s\", itable[MY_INDEX].name);\n", phase);
+ lf_printf (file,
+ " trace_generic (SD, CPU, TRACE_%s_IDX, \" %%s\", itable[MY_INDEX].name);\n",
+ phase);
}
lf_indent (file, -4);
lf_printf (file, " }\n");
@@ -572,8 +567,7 @@ print_itrace (lf *file,
void
-print_sim_engine_abort (lf *file,
- const char *message)
+print_sim_engine_abort (lf *file, const char *message)
{
lf_printf (file, "sim_engine_abort (SD, CPU, cia, ");
lf_printf (file, "\"%s\"", message);
@@ -582,15 +576,13 @@ print_sim_engine_abort (lf *file,
void
-print_include (lf *file,
- igen_module module)
+print_include (lf *file, igen_module module)
{
lf_printf (file, "#include \"%s%s.h\"\n", module.prefix.l, module.suffix.l);
}
void
-print_include_inline (lf *file,
- igen_module module)
+print_include_inline (lf *file, igen_module module)
{
lf_printf (file, "#if C_REVEALS_MODULE_P (%s_INLINE)\n", module.suffix.u);
lf_printf (file, "#include \"%s%s.c\"\n", module.prefix.l, module.suffix.l);
@@ -616,9 +608,7 @@ print_includes (lf *file)
static void
-gen_semantics_h (lf *file,
- insn_list *semantics,
- int max_nr_words)
+gen_semantics_h (lf *file, insn_list *semantics, int max_nr_words)
{
int word_nr;
insn_list *semantic;
@@ -626,8 +616,7 @@ gen_semantics_h (lf *file,
{
lf_printf (file, "typedef ");
print_semantic_function_type (file);
- lf_printf (file, " %sidecode_semantic",
- options.module.global.prefix.l);
+ lf_printf (file, " %sidecode_semantic", options.module.global.prefix.l);
if (word_nr >= 0)
lf_printf (file, "_%d", word_nr);
lf_printf (file, "\n(");
@@ -660,9 +649,7 @@ gen_semantics_h (lf *file,
static void
-gen_semantics_c (lf *file,
- insn_list *semantics,
- cache_entry *cache_rules)
+gen_semantics_c (lf *file, insn_list *semantics, cache_entry *cache_rules)
{
if (options.gen.code == generate_calls)
{
@@ -697,23 +684,20 @@ gen_semantics_c (lf *file,
static void
gen_icache_h (lf *file,
insn_list *semantic,
- function_entry *functions,
- int max_nr_words)
+ function_entry * functions, int max_nr_words)
{
int word_nr;
for (word_nr = 0; word_nr <= max_nr_words; word_nr++)
{
lf_printf (file, "typedef ");
- print_icache_function_type(file);
+ print_icache_function_type (file);
lf_printf (file, " %sidecode_icache_%d\n(",
- options.module.global.prefix.l,
- word_nr);
- print_icache_function_formal(file, word_nr);
+ options.module.global.prefix.l, word_nr);
+ print_icache_function_formal (file, word_nr);
lf_printf (file, ");\n");
lf_printf (file, "\n");
}
- if (options.gen.code == generate_calls
- && options.gen.icache)
+ if (options.gen.code == generate_calls && options.gen.icache)
{
function_entry_traverse (file, functions,
print_icache_internal_function_declaration,
@@ -737,13 +721,11 @@ gen_icache_h (lf *file,
static void
gen_icache_c (lf *file,
insn_list *semantic,
- function_entry *functions,
- cache_entry *cache_rules)
+ function_entry * functions, cache_entry *cache_rules)
{
/* output `internal' invalid/floating-point unavailable functions
where needed */
- if (options.gen.code == generate_calls
- && options.gen.icache)
+ if (options.gen.code == generate_calls && options.gen.icache)
{
lf_printf (file, "\n");
lf_printf (file, "#include \"cpu.h\"\n");
@@ -779,9 +761,7 @@ gen_icache_c (lf *file,
static void
gen_idecode_h (lf *file,
- gen_table *gen,
- insn_table *insns,
- cache_entry *cache_rules)
+ gen_table *gen, insn_table *insns, cache_entry *cache_rules)
{
lf_printf (file, "typedef unsigned%d %sinstruction_word;\n",
options.insn_bit_size, options.module.global.prefix.l);
@@ -791,13 +771,14 @@ gen_idecode_h (lf *file,
options.module.global.prefix.l);
lf_printf (file, " address_word ip; /* instruction pointer */\n");
lf_printf (file, " address_word dp; /* delayed-slot pointer */\n");
- lf_printf (file, "} %sinstruction_address;\n", options.module.global.prefix.l);
+ lf_printf (file, "} %sinstruction_address;\n",
+ options.module.global.prefix.l);
}
else
{
lf_printf (file, "typedef address_word %sinstruction_address;\n",
options.module.global.prefix.l);
-
+
}
if (options.gen.nia == nia_is_invalid
&& strlen (options.module.global.prefix.u) > 0)
@@ -824,14 +805,14 @@ gen_idecode_h (lf *file,
? entry->model->name
: NULL),
is_function_declaration,
- 1/*ALWAYS ONE WORD*/);
+ 1 /*ALWAYS ONE WORD */ );
}
if (options.gen.multi_sim)
{
print_idecode_issue_function_header (file,
NULL,
is_function_variable,
- 1/*ALWAYS ONE WORD*/);
+ 1 /*ALWAYS ONE WORD */ );
}
}
}
@@ -839,9 +820,7 @@ gen_idecode_h (lf *file,
static void
gen_idecode_c (lf *file,
- gen_table *gen,
- insn_table *isa,
- cache_entry *cache_rules)
+ gen_table *gen, insn_table *isa, cache_entry *cache_rules)
{
/* the intro */
print_includes (file);
@@ -850,7 +829,7 @@ gen_idecode_c (lf *file,
print_idecode_globals (file);
lf_printf (file, "\n");
-
+
switch (options.gen.code)
{
case generate_calls:
@@ -859,7 +838,7 @@ gen_idecode_c (lf *file,
for (entry = gen->tables; entry != NULL; entry = entry->next)
{
print_idecode_lookups (file, entry->table, cache_rules);
-
+
/* output the main idecode routine */
if (!options.gen.icache)
{
@@ -867,8 +846,8 @@ gen_idecode_c (lf *file,
(options.gen.multi_sim
? entry->model->name
: NULL),
- 1/*is definition*/,
- 1/*ALWAYS ONE WORD*/);
+ 1 /*is definition */ ,
+ 1 /*ALWAYS ONE WORD */ );
lf_printf (file, "{\n");
lf_indent (file, +2);
lf_printf (file, "%sinstruction_address nia;\n",
@@ -894,8 +873,7 @@ gen_idecode_c (lf *file,
static void
-gen_run_c (lf *file,
- gen_table *gen)
+gen_run_c (lf *file, gen_table *gen)
{
gen_list *entry;
lf_printf (file, "#include \"sim-main.h\"\n");
@@ -906,12 +884,13 @@ gen_run_c (lf *file,
if (options.gen.multi_sim)
{
- print_idecode_issue_function_header (file, NULL, is_function_variable, 1);
+ print_idecode_issue_function_header (file, NULL, is_function_variable,
+ 1);
lf_printf (file, "\n");
print_engine_run_function_header (file, NULL, is_function_variable);
lf_printf (file, "\n");
}
-
+
lf_printf (file, "void\n");
lf_printf (file, "sim_engine_run (SIM_DESC sd,\n");
lf_printf (file, " int next_cpu_nr,\n");
@@ -933,36 +912,27 @@ gen_run_c (lf *file,
{
if (options.gen.default_model != NULL
&& (strcmp (entry->model->name, options.gen.default_model) == 0
- || strcmp (entry->model->full_name, options.gen.default_model) == 0))
+ || strcmp (entry->model->full_name,
+ options.gen.default_model) == 0))
lf_printf (file, "default:\n");
lf_printf (file, "case bfd_mach_%s:\n", entry->model->full_name);
lf_indent (file, +2);
- print_function_name (file,
- "issue",
- NULL, /* format name */
- NULL, /* NO processor */
- NULL, /* expanded bits */
+ print_function_name (file, "issue", NULL, /* format name */
+ NULL, /* NO processor */
+ NULL, /* expanded bits */
function_name_prefix_idecode);
lf_printf (file, " = ");
- print_function_name (file,
- "issue",
- NULL, /* format name */
- entry->model->name,
- NULL, /* expanded bits */
+ print_function_name (file, "issue", NULL, /* format name */
+ entry->model->name, NULL, /* expanded bits */
function_name_prefix_idecode);
lf_printf (file, ";\n");
- print_function_name (file,
- "run",
- NULL, /* format name */
- NULL, /* NO processor */
- NULL, /* expanded bits */
+ print_function_name (file, "run", NULL, /* format name */
+ NULL, /* NO processor */
+ NULL, /* expanded bits */
function_name_prefix_engine);
lf_printf (file, " = ");
- print_function_name (file,
- "run",
- NULL, /* format name */
- entry->model->name,
- NULL, /* expanded bits */
+ print_function_name (file, "run", NULL, /* format name */
+ entry->model->name, NULL, /* expanded bits */
function_name_prefix_engine);
lf_printf (file, ";\n");
lf_printf (file, "break;\n");
@@ -973,18 +943,17 @@ gen_run_c (lf *file,
lf_printf (file, "default:\n");
lf_indent (file, +2);
lf_printf (file, "sim_engine_abort (sd, NULL, NULL_CIA,\n");
- lf_printf (file, " \"sim_engine_run - unknown machine\");\n");
+ lf_printf (file,
+ " \"sim_engine_run - unknown machine\");\n");
lf_printf (file, "break;\n");
lf_indent (file, -2);
}
lf_indent (file, -2);
lf_printf (file, " }\n");
}
- print_function_name (file,
- "run",
- NULL, /* format name */
- NULL, /* NO processor */
- NULL, /* expanded bits */
+ print_function_name (file, "run", NULL, /* format name */
+ NULL, /* NO processor */
+ NULL, /* expanded bits */
function_name_prefix_engine);
lf_printf (file, " (sd, next_cpu_nr, nr_cpus, siggnal);\n");
lf_indent (file, -2);
@@ -994,8 +963,7 @@ gen_run_c (lf *file,
/****************************************************************/
static gen_table *
-do_gen (insn_table *isa,
- decode_table *decode_rules)
+do_gen (insn_table *isa, decode_table *decode_rules)
{
gen_table *gen;
if (decode_rules == NULL)
@@ -1015,9 +983,7 @@ do_gen (insn_table *isa,
igen_options options;
int
-main (int argc,
- char **argv,
- char **envp)
+main (int argc, char **argv, char **envp)
{
cache_entry *cache_rules = NULL;
lf_file_references file_references = lf_include_references;
@@ -1027,7 +993,8 @@ main (int argc,
char *real_file_name = NULL;
int is_header = 0;
int ch;
- lf *standard_out = lf_open ("-", "stdout", lf_omit_references, lf_is_text, "igen");
+ lf *standard_out =
+ lf_open ("-", "stdout", lf_omit_references, lf_is_text, "igen");
INIT_OPTIONS ();
@@ -1041,95 +1008,140 @@ main (int argc,
printf ("\n");
printf (" -B <bit-size>\n");
printf ("\t Set the number of bits in an instruction (deprecated).\n");
- printf ("\t This option can now be set directly in the instruction table.\n");
+ printf
+ ("\t This option can now be set directly in the instruction table.\n");
printf ("\n");
printf (" -D <data-structure>\n");
- printf ("\t Dump the specified data structure to stdout. Valid structures include:\n");
- printf ("\t processor-names - list the names of all the processors (models)\n");
+ printf
+ ("\t Dump the specified data structure to stdout. Valid structures include:\n");
+ printf
+ ("\t processor-names - list the names of all the processors (models)\n");
printf ("\n");
printf (" -F <filter-list>\n");
- printf ("\t Filter out any instructions with a non-empty flags field that contains\n");
+ printf
+ ("\t Filter out any instructions with a non-empty flags field that contains\n");
printf ("\t a flag not listed in the <filter-list>.\n");
printf ("\n");
printf (" -H <high-bit>\n");
- printf ("\t Set the number of the high (most significant) instruction bit (deprecated).\n");
- printf ("\t This option can now be set directly in the instruction table.\n");
+ printf
+ ("\t Set the number of the high (most significant) instruction bit (deprecated).\n");
+ printf
+ ("\t This option can now be set directly in the instruction table.\n");
printf ("\n");
printf (" -I <directory>\n");
- printf ("\t Add <directory> to the list of directories searched when opening a file\n");
+ printf
+ ("\t Add <directory> to the list of directories searched when opening a file\n");
printf ("\n");
printf (" -M <model-list>\n");
- printf ("\t Filter out any instructions that do not support at least one of the listed\n");
- printf ("\t models (An instructions with no model information is considered to support\n");
+ printf
+ ("\t Filter out any instructions that do not support at least one of the listed\n");
+ printf
+ ("\t models (An instructions with no model information is considered to support\n");
printf ("\t all models.).\n");
printf ("\n");
printf (" -N <nr-cpus>\n");
printf ("\t Generate a simulator supporting <nr-cpus>\n");
- printf ("\t Specify `-N 0' to disable generation of the SMP. Specifying `-N 1' will\n");
- printf ("\t still generate an SMP enabled simulator but will only support one CPU.\n");
+ printf
+ ("\t Specify `-N 0' to disable generation of the SMP. Specifying `-N 1' will\n");
+ printf
+ ("\t still generate an SMP enabled simulator but will only support one CPU.\n");
printf ("\n");
printf (" -T <mechanism>\n");
- printf ("\t Override the decode mechanism specified by the decode rules\n");
+ printf
+ ("\t Override the decode mechanism specified by the decode rules\n");
printf ("\n");
printf (" -P <prefix>\n");
- printf ("\t Prepend global names (except itable) with the string <prefix>.\n");
- printf ("\t Specify -P <module>=<prefix> to set a specific <module>'s prefix.\n");
+ printf
+ ("\t Prepend global names (except itable) with the string <prefix>.\n");
+ printf
+ ("\t Specify -P <module>=<prefix> to set a specific <module>'s prefix.\n");
printf ("\n");
printf (" -S <suffix>\n");
- printf ("\t Replace a global name (suffix) (except itable) with the string <suffix>.\n");
- printf ("\t Specify -S <module>=<suffix> to change a specific <module>'s name (suffix).\n");
+ printf
+ ("\t Replace a global name (suffix) (except itable) with the string <suffix>.\n");
+ printf
+ ("\t Specify -S <module>=<suffix> to change a specific <module>'s name (suffix).\n");
printf ("\n");
printf (" -Werror\n");
printf ("\t Make warnings errors\n");
printf (" -Wnodiscard\n");
- printf ("\t Suppress warnings about discarded functions and instructions\n");
+ printf
+ ("\t Suppress warnings about discarded functions and instructions\n");
printf (" -Wnowidth\n");
- printf ("\t Suppress warnings about instructions with invalid widths\n");
+ printf
+ ("\t Suppress warnings about instructions with invalid widths\n");
printf (" -Wnounimplemented\n");
printf ("\t Suppress warnings about unimplemented instructions\n");
printf ("\n");
printf (" -G [!]<gen-option>\n");
printf ("\t Any of the following options:\n");
printf ("\n");
- printf ("\t decode-duplicate - Override the decode rules, forcing the duplication of\n");
+ printf
+ ("\t decode-duplicate - Override the decode rules, forcing the duplication of\n");
printf ("\t semantic functions\n");
- printf ("\t decode-combine - Combine any duplicated entries within a table\n");
- printf ("\t decode-zero-reserved - Override the decode rules, forcing reserved bits to be\n");
+ printf
+ ("\t decode-combine - Combine any duplicated entries within a table\n");
+ printf
+ ("\t decode-zero-reserved - Override the decode rules, forcing reserved bits to be\n");
printf ("\t treated as zero.\n");
- printf ("\t decode-switch-is-goto - Overfide the padded-switch code type as a goto-switch\n");
+ printf
+ ("\t decode-switch-is-goto - Overfide the padded-switch code type as a goto-switch\n");
printf ("\n");
- printf ("\t gen-conditional-issue - conditionally issue each instruction\n");
- printf ("\t gen-delayed-branch - need both cia and nia passed around\n");
- printf ("\t gen-direct-access - use #defines to directly access values\n");
- printf ("\t gen-zero-r<N> - arch assumes GPR(<N>) == 0, keep it that way\n");
- printf ("\t gen-icache[=<N> - generate an instruction cracking cache of size <N>\n");
- printf ("\t Default size is %d\n", options.gen.icache_size);
- printf ("\t gen-insn-in-icache - save original instruction when cracking\n");
- printf ("\t gen-multi-sim[=MODEL] - generate multiple simulators - one per model\n");
- printf ("\t If specified MODEL is made the default architecture.\n");
- printf ("\t By default, a single simulator that will\n");
- printf ("\t execute any instruction is generated\n");
- printf ("\t gen-multi-word - generate code allowing for multi-word insns\n");
- printf ("\t gen-semantic-icache - include semantic code in cracking functions\n");
- printf ("\t gen-slot-verification - perform slot verification as part of decode\n");
+ printf
+ ("\t gen-conditional-issue - conditionally issue each instruction\n");
+ printf
+ ("\t gen-delayed-branch - need both cia and nia passed around\n");
+ printf
+ ("\t gen-direct-access - use #defines to directly access values\n");
+ printf
+ ("\t gen-zero-r<N> - arch assumes GPR(<N>) == 0, keep it that way\n");
+ printf
+ ("\t gen-icache[=<N> - generate an instruction cracking cache of size <N>\n");
+ printf ("\t Default size is %d\n",
+ options.gen.icache_size);
+ printf
+ ("\t gen-insn-in-icache - save original instruction when cracking\n");
+ printf
+ ("\t gen-multi-sim[=MODEL] - generate multiple simulators - one per model\n");
+ printf
+ ("\t If specified MODEL is made the default architecture.\n");
+ printf
+ ("\t By default, a single simulator that will\n");
+ printf
+ ("\t execute any instruction is generated\n");
+ printf
+ ("\t gen-multi-word - generate code allowing for multi-word insns\n");
+ printf
+ ("\t gen-semantic-icache - include semantic code in cracking functions\n");
+ printf
+ ("\t gen-slot-verification - perform slot verification as part of decode\n");
printf ("\t gen-nia-invalid - NIA defaults to nia_invalid\n");
printf ("\t gen-nia-void - do not compute/return NIA\n");
printf ("\n");
- printf ("\t trace-combine - report combined entries a rule application\n");
- printf ("\t trace-entries - report entries after a rules application\n");
+ printf
+ ("\t trace-combine - report combined entries a rule application\n");
+ printf
+ ("\t trace-entries - report entries after a rules application\n");
printf ("\t trace-rule-rejection - report each rule as rejected\n");
printf ("\t trace-rule-selection - report each rule as selected\n");
- printf ("\t trace-insn-insertion - report each instruction as it is inserted into a decode table\n");
- printf ("\t trace-rule-expansion - report each instruction as it is expanded (before insertion into a decode table)\n");
+ printf
+ ("\t trace-insn-insertion - report each instruction as it is inserted into a decode table\n");
+ printf
+ ("\t trace-rule-expansion - report each instruction as it is expanded (before insertion into a decode table)\n");
printf ("\t trace-all - enable all trace options\n");
printf ("\n");
- printf ("\t field-widths - instruction formats specify widths (deprecated)\n");
- printf ("\t By default, an instruction format specifies bit\n");
+ printf
+ ("\t field-widths - instruction formats specify widths (deprecated)\n");
+ printf
+ ("\t By default, an instruction format specifies bit\n");
printf ("\t positions\n");
- printf ("\t This option can now be set directly in the\n");
+ printf
+ ("\t This option can now be set directly in the\n");
printf ("\t instruction table\n");
- printf ("\t jumps - use jumps instead of function calls\n");
- printf ("\t omit-line-numbers - do not include line number information in the output\n");
+ printf
+ ("\t jumps - use jumps instead of function calls\n");
+ printf
+ ("\t omit-line-numbers - do not include line number information in the output\n");
printf ("\n");
printf ("Input options:\n");
printf ("\n");
@@ -1140,8 +1152,10 @@ main (int argc,
printf ("Output options:\n");
printf ("\n");
printf (" -x Perform expansion (required)\n");
- printf (" -n <real-name> Specify the real name of the next output file\n");
- printf (" -h Generate the header (.h) file rather than the body (.c)\n");
+ printf
+ (" -n <real-name> Specify the real name of the next output file\n");
+ printf
+ (" -h Generate the header (.h) file rather than the body (.c)\n");
printf (" -c <output-file> output icache\n");
printf (" -d <output-file> output idecode\n");
printf (" -e <output-file> output engine\n");
@@ -1151,19 +1165,19 @@ main (int argc,
printf (" -s <output-file> output schematic\n");
printf (" -t <output-file> output itable\n");
}
-
- while ((ch = getopt(argc, argv,
- "B:D:F:G:H:I:M:N:P:T:W:o:k:i:n:hc:d:e:m:r:s:t:f:x"))
+
+ while ((ch = getopt (argc, argv,
+ "B:D:F:G:H:I:M:N:P:T:W:o:k:i:n:hc:d:e:m:r:s:t:f:x"))
!= -1)
{
fprintf (stderr, " -%c ", ch);
if (optarg)
fprintf (stderr, "%s ", optarg);
fprintf (stderr, "\\\n");
-
- switch(ch)
+
+ switch (ch)
{
-
+
case 'M':
filter_parse (&options.model_filter, optarg);
break;
@@ -1184,7 +1198,7 @@ main (int argc,
case 'F':
filter_parse (&options.flags_filter, optarg);
break;
-
+
case 'I':
{
table_include **dir = &options.include;
@@ -1194,7 +1208,7 @@ main (int argc,
(*dir)->dir = strdup (optarg);
}
break;
-
+
case 'B':
options.insn_bit_size = a2i (optarg);
if (options.insn_bit_size <= 0
@@ -1209,7 +1223,7 @@ main (int argc,
error (NULL, "Conflict betweem hi-bit-nr and insn-bit-size\n");
}
break;
-
+
case 'H':
options.hi_bit_nr = a2i (optarg);
if (options.hi_bit_nr != options.insn_bit_size - 1
@@ -1218,11 +1232,11 @@ main (int argc,
error (NULL, "Conflict between hi-bit-nr and insn-bit-size\n");
}
break;
-
+
case 'N':
options.gen.smp = a2i (optarg);
break;
-
+
case 'P':
case 'S':
{
@@ -1237,7 +1251,7 @@ main (int argc,
}
else
{
- chp = chp + 1; /* skip `=' */
+ chp = chp + 1; /* skip `=' */
names = NULL;
if (strncmp (optarg, "global=", chp - optarg) == 0)
{
@@ -1281,23 +1295,25 @@ main (int argc,
name = &names->suffix;
break;
default:
- abort (); /* Bad switch. */
+ abort (); /* Bad switch. */
}
name->u = strdup (chp);
name->l = strdup (chp);
chp = name->u;
- while (*chp) {
- if (islower(*chp))
- *chp = toupper(*chp);
- chp++;
- }
+ while (*chp)
+ {
+ if (islower (*chp))
+ *chp = toupper (*chp);
+ chp++;
+ }
if (name == &options.module.global.prefix)
{
options.module.engine.prefix = options.module.global.prefix;
options.module.icache.prefix = options.module.global.prefix;
options.module.idecode.prefix = options.module.global.prefix;
/* options.module.itable.prefix = options.module.global.prefix; */
- options.module.semantics.prefix = options.module.global.prefix;
+ options.module.semantics.prefix =
+ options.module.global.prefix;
options.module.support.prefix = options.module.global.prefix;
}
if (name == &options.module.global.suffix)
@@ -1306,12 +1322,13 @@ main (int argc,
options.module.icache.suffix = options.module.global.suffix;
options.module.idecode.suffix = options.module.global.suffix;
/* options.module.itable.suffix = options.module.global.suffix; */
- options.module.semantics.suffix = options.module.global.suffix;
+ options.module.semantics.suffix =
+ options.module.global.suffix;
options.module.support.suffix = options.module.global.suffix;
}
break;
}
-
+
case 'W':
{
if (strcmp (optarg, "error") == 0)
@@ -1365,7 +1382,7 @@ main (int argc,
{
options.decode.zero_reserved = enable_p;
}
-
+
else if (strcmp (argp, "gen-conditional-issue") == 0)
{
options.gen.conditional_issue = enable_p;
@@ -1373,7 +1390,8 @@ main (int argc,
else if (strcmp (argp, "conditional-issue") == 0)
{
options.gen.conditional_issue = enable_p;
- options.warning (NULL, "Option conditional-issue replaced by gen-conditional-issue\n");
+ options.warning (NULL,
+ "Option conditional-issue replaced by gen-conditional-issue\n");
}
else if (strcmp (argp, "gen-delayed-branch") == 0)
{
@@ -1382,7 +1400,8 @@ main (int argc,
else if (strcmp (argp, "delayed-branch") == 0)
{
options.gen.delayed_branch = enable_p;
- options.warning (NULL, "Option delayed-branch replaced by gen-delayed-branch\n");
+ options.warning (NULL,
+ "Option delayed-branch replaced by gen-delayed-branch\n");
}
else if (strcmp (argp, "gen-direct-access") == 0)
{
@@ -1391,7 +1410,8 @@ main (int argc,
else if (strcmp (argp, "direct-access") == 0)
{
options.gen.direct_access = enable_p;
- options.warning (NULL, "Option direct-access replaced by gen-direct-access\n");
+ options.warning (NULL,
+ "Option direct-access replaced by gen-direct-access\n");
}
else if (strncmp (argp, "gen-zero-r", strlen ("gen-zero-r")) == 0)
{
@@ -1402,28 +1422,32 @@ main (int argc,
{
options.gen.zero_reg = enable_p;
options.gen.zero_reg_nr = atoi (argp + strlen ("zero-r"));
- options.warning (NULL, "Option zero-r<N> replaced by gen-zero-r<N>\n");
+ options.warning (NULL,
+ "Option zero-r<N> replaced by gen-zero-r<N>\n");
}
else if (strncmp (argp, "gen-icache", strlen ("gen-icache")) == 0)
{
switch (argp[strlen ("gen-icache")])
{
case '=':
- options.gen.icache_size = atoi (argp + strlen ("gen-icache") + 1);
+ options.gen.icache_size =
+ atoi (argp + strlen ("gen-icache") + 1);
options.gen.icache = enable_p;
break;
case '\0':
options.gen.icache = enable_p;
break;
default:
- error (NULL, "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
+ error (NULL,
+ "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
}
}
else if (strcmp (argp, "gen-insn-in-icache") == 0)
{
options.gen.insn_in_icache = enable_p;
}
- else if (strncmp (argp, "gen-multi-sim", strlen ("gen-multi-sim")) == 0)
+ else if (strncmp (argp, "gen-multi-sim", strlen ("gen-multi-sim"))
+ == 0)
{
char *arg = &argp[strlen ("gen-multi-sim")];
switch (arg[0])
@@ -1431,15 +1455,18 @@ main (int argc,
case '=':
options.gen.multi_sim = enable_p;
options.gen.default_model = arg + 1;
- if (! filter_is_member (options.model_filter, options.gen.default_model))
- error (NULL, "multi-sim model %s unknown\n", options.gen.default_model);
+ if (!filter_is_member
+ (options.model_filter, options.gen.default_model))
+ error (NULL, "multi-sim model %s unknown\n",
+ options.gen.default_model);
break;
case '\0':
options.gen.multi_sim = enable_p;
options.gen.default_model = NULL;
break;
default:
- error (NULL, "Expecting -Ggen-multi-sim or -Ggen-multi-sim=<MODEL>\n");
+ error (NULL,
+ "Expecting -Ggen-multi-sim or -Ggen-multi-sim=<MODEL>\n");
break;
}
}
@@ -1458,7 +1485,8 @@ main (int argc,
else if (strcmp (argp, "verify-slot") == 0)
{
options.gen.slot_verification = enable_p;
- options.warning (NULL, "Option verify-slot replaced by gen-slot-verification\n");
+ options.warning (NULL,
+ "Option verify-slot replaced by gen-slot-verification\n");
}
else if (strcmp (argp, "gen-nia-invalid") == 0)
{
@@ -1467,7 +1495,8 @@ main (int argc,
else if (strcmp (argp, "default-nia-minus-one") == 0)
{
options.gen.nia = nia_is_invalid;
- options.warning (NULL, "Option default-nia-minus-one replaced by gen-nia-invalid\n");
+ options.warning (NULL,
+ "Option default-nia-minus-one replaced by gen-nia-invalid\n");
}
else if (strcmp (argp, "gen-nia-void") == 0)
{
@@ -1519,7 +1548,7 @@ main (int argc,
}
break;
}
-
+
case 'i':
isa = load_insn_table (optarg, cache_rules);
if (isa->illegal_insn == NULL)
@@ -1541,13 +1570,13 @@ main (int argc,
break;
case 'n':
- real_file_name = strdup(optarg);
+ real_file_name = strdup (optarg);
break;
case 'h':
is_header = 1;
break;
-
+
case 'c':
case 'd':
case 'e':
@@ -1557,15 +1586,16 @@ main (int argc,
case 's':
case 't':
{
- lf *file = lf_open(optarg, real_file_name, file_references,
- (is_header ? lf_is_h : lf_is_c),
- argv[0]);
+ lf *file = lf_open (optarg, real_file_name, file_references,
+ (is_header ? lf_is_h : lf_is_c),
+ argv[0]);
if (gen == NULL && ch != 't' && ch != 'm' && ch != 'f')
{
- options.warning (NULL, "Explicitly generate tables with -x option\n");
+ options.warning (NULL,
+ "Explicitly generate tables with -x option\n");
gen = do_gen (isa, decode_rules);
}
- lf_print__file_start(file);
+ lf_print__file_start (file);
switch (ch)
{
case 'm':
@@ -1593,7 +1623,7 @@ main (int argc,
gen_run_c (file, gen);
break;
case 's':
- if(is_header)
+ if (is_header)
gen_semantics_h (file, gen->semantics, isa->max_nr_words);
else
gen_semantics_c (file, gen->semantics, isa->caches);
@@ -1614,21 +1644,18 @@ main (int argc,
if (is_header)
gen_icache_h (file,
gen->semantics,
- isa->functions,
- isa->max_nr_words);
+ isa->functions, isa->max_nr_words);
else
gen_icache_c (file,
- gen->semantics,
- isa->functions,
- cache_rules);
+ gen->semantics, isa->functions, cache_rules);
break;
}
- lf_print__file_finish(file);
- lf_close(file);
+ lf_print__file_finish (file);
+ lf_close (file);
is_header = 0;
}
- real_file_name = NULL;
- break;
+ real_file_name = NULL;
+ break;
default:
ERROR ("Bad switch");
}
diff --git a/sim/igen/igen.h b/sim/igen/igen.h
index 6367f3b..1ca456e 100644
--- a/sim/igen/igen.h
+++ b/sim/igen/igen.h
@@ -24,7 +24,8 @@
/* code-generation options: */
-typedef enum {
+typedef enum
+{
/* Transfer control to an instructions semantic code using the the
standard call/return mechanism */
@@ -37,18 +38,22 @@ typedef enum {
generate_jumps,
-} igen_code;
+}
+igen_code;
-typedef enum {
+typedef enum
+{
nia_is_cia_plus_one,
nia_is_void,
nia_is_invalid,
-} igen_nia;
+}
+igen_nia;
typedef struct _igen_gen_options igen_gen_options;
-struct _igen_gen_options {
+struct _igen_gen_options
+{
int direct_access;
int semantic_icache;
int insn_in_icache;
@@ -87,7 +92,8 @@ struct _igen_gen_options {
typedef struct _igen_trace_options igen_trace_options;
-struct _igen_trace_options {
+struct _igen_trace_options
+{
int rule_selection;
int rule_rejection;
int insn_insertion;
@@ -96,16 +102,21 @@ struct _igen_trace_options {
int combine;
};
-typedef struct _igen_name {
+typedef struct _igen_name
+{
char *u;
char *l;
-} igen_name;
-typedef struct _igen_module {
+}
+igen_name;
+typedef struct _igen_module
+{
igen_name prefix;
igen_name suffix;
-} igen_module;
+}
+igen_module;
-typedef struct _igen_module_options {
+typedef struct _igen_module_options
+{
igen_module global;
igen_module engine;
igen_module icache;
@@ -113,10 +124,12 @@ typedef struct _igen_module_options {
igen_module itable;
igen_module semantics;
igen_module support;
-} igen_module_options;
+}
+igen_module_options;
-typedef struct _igen_decode_options igen_decode_options ;
-struct _igen_decode_options {
+typedef struct _igen_decode_options igen_decode_options;
+struct _igen_decode_options
+{
/* Combine tables? Should the generator make a second pass through
each generated table looking for any sub-entries that contain the
@@ -143,7 +156,8 @@ struct _igen_decode_options {
typedef struct _igen_warn_options igen_warn_options;
-struct _igen_warn_options {
+struct _igen_warn_options
+{
/* Issue warning about discarded instructions */
int discard;
@@ -159,7 +173,8 @@ struct _igen_warn_options {
typedef struct _igen_options igen_options;
-struct _igen_options {
+struct _igen_options
+{
/* What does the instruction look like - bit ordering, size, widths or
offesets */
@@ -201,7 +216,7 @@ struct _igen_options {
extern igen_options options;
-/* default options - hopefully backward compatible */ \
+/* default options - hopefully backward compatible */
#define INIT_OPTIONS() \
do { \
memset (&options, 0, sizeof options); \
diff --git a/sim/igen/ld-cache.c b/sim/igen/ld-cache.c
index 3fa75b7..c46aa9a 100644
--- a/sim/igen/ld-cache.c
+++ b/sim/igen/ld-cache.c
@@ -37,7 +37,8 @@
#endif
-enum {
+enum
+{
ca_type,
ca_field_name,
ca_derived_name,
@@ -47,10 +48,10 @@ enum {
};
static const name_map cache_type_map[] = {
- { "cache", cache_value },
- { "compute", compute_value },
- { "scratch", scratch_value },
- { NULL, 0 },
+ {"cache", cache_value},
+ {"compute", compute_value},
+ {"scratch", scratch_value},
+ {NULL, 0},
};
@@ -67,8 +68,7 @@ load_cache_table (char *file_name)
new_rule->line = entry->line;
new_rule->entry_type = name2i (entry->field[ca_type], cache_type_map);
new_rule->name = entry->field[ca_derived_name];
- filter_parse (&new_rule->original_fields,
- entry->field[ca_field_name]);
+ filter_parse (&new_rule->original_fields, entry->field[ca_field_name]);
new_rule->type = entry->field[ca_type_def];
/* expression is the concatenation of the remaining fields */
if (entry->nr_fields > ca_expression)
@@ -101,7 +101,7 @@ load_cache_table (char *file_name)
igen_options options;
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
cache_entry *rules = NULL;
lf *l;
diff --git a/sim/igen/ld-cache.h b/sim/igen/ld-cache.h
index 168bf3b..2ad60ea 100644
--- a/sim/igen/ld-cache.h
+++ b/sim/igen/ld-cache.h
@@ -65,5 +65,4 @@
new name had better be the same. */
-extern cache_entry *load_cache_table
-(char *file_name);
+extern cache_entry *load_cache_table (char *file_name);
diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c
index 62b7942..856b1ad 100644
--- a/sim/igen/ld-decode.c
+++ b/sim/igen/ld-decode.c
@@ -39,45 +39,44 @@
static const name_map decode_type_map[] = {
- { "normal", normal_decode_rule },
- { "boolean", boolean_rule },
- { NULL, normal_decode_rule },
+ {"normal", normal_decode_rule},
+ {"boolean", boolean_rule},
+ {NULL, normal_decode_rule},
};
static const name_map decode_gen_map[] = {
- { "array", array_gen },
- { "switch", switch_gen },
- { "padded-switch", padded_switch_gen },
- { "goto-switch", goto_switch_gen },
- { NULL, -1 },
+ {"array", array_gen},
+ {"switch", switch_gen},
+ {"padded-switch", padded_switch_gen},
+ {"goto-switch", goto_switch_gen},
+ {NULL, -1},
};
static const name_map decode_reserved_map[] = {
- { "zero-reserved", 1 },
- { NULL, 0 },
+ {"zero-reserved", 1},
+ {NULL, 0},
};
static const name_map decode_duplicates_map[] = {
- { "duplicate", 1 },
- { NULL, 0 },
+ {"duplicate", 1},
+ {NULL, 0},
};
static const name_map decode_combine_map[] = {
- { "combine", 1 },
- { NULL, 0 },
+ {"combine", 1},
+ {NULL, 0},
};
static const name_map decode_search_map[] = {
- { "constants", decode_find_constants },
- { "mixed", decode_find_mixed },
- { "strings", decode_find_strings },
- { NULL, decode_find_mixed },
+ {"constants", decode_find_constants},
+ {"mixed", decode_find_mixed},
+ {"strings", decode_find_strings},
+ {NULL, decode_find_mixed},
};
static void
-set_bits (int bit[max_insn_bit_size],
- unsigned64 value)
+set_bits (int bit[max_insn_bit_size], unsigned64 value)
{
int bit_nr;
for (bit_nr = 0; bit_nr < max_insn_bit_size; bit_nr++)
@@ -90,7 +89,7 @@ set_bits (int bit[max_insn_bit_size],
}
decode_table *
-load_decode_table(char *file_name)
+load_decode_table (char *file_name)
{
table *file = table_open (file_name);
table_entry *entry;
@@ -107,20 +106,22 @@ load_decode_table(char *file_name)
/* the options field */
new_rule->type = name2i (decode_options, decode_type_map);
if (options.decode.overriding_gen != NULL)
- new_rule->gen = name2i (options.decode.overriding_gen, decode_gen_map);
+ new_rule->gen =
+ name2i (options.decode.overriding_gen, decode_gen_map);
else
new_rule->gen = name2i (decode_options, decode_gen_map);
- if (new_rule->gen == padded_switch_gen
- && options.decode.switch_as_goto)
+ if (new_rule->gen == padded_switch_gen && options.decode.switch_as_goto)
new_rule->gen = goto_switch_gen;
if (options.decode.zero_reserved)
new_rule->with_zero_reserved = 1;
else
- new_rule->with_zero_reserved = name2i (decode_options, decode_reserved_map);
+ new_rule->with_zero_reserved =
+ name2i (decode_options, decode_reserved_map);
if (options.decode.duplicate)
new_rule->with_duplicates = 1;
else
- new_rule->with_duplicates = name2i (decode_options, decode_duplicates_map);
+ new_rule->with_duplicates =
+ name2i (decode_options, decode_duplicates_map);
if (options.decode.combine)
new_rule->with_combine = 1;
else
@@ -169,7 +170,9 @@ load_decode_table(char *file_name)
&& strlen (entry->field[decode_force_first_field]) > 0)
{
new_rule->force_first = target_a2i (options.hi_bit_nr,
- entry->field[decode_force_first_field]);
+ entry->
+ field
+ [decode_force_first_field]);
if (new_rule->force_first < new_rule->first
|| new_rule->force_first > new_rule->last + 1)
error (new_rule->line, "Force first out of range\n");
@@ -180,7 +183,8 @@ load_decode_table(char *file_name)
&& strlen (entry->field[decode_force_last_field]) > 0)
{
new_rule->force_last = target_a2i (options.hi_bit_nr,
- entry->field[decode_force_last_field]);
+ entry->
+ field[decode_force_last_field]);
if (new_rule->force_last > new_rule->last
|| new_rule->force_last < new_rule->first - 1)
error (new_rule->line, "Force-last out of range\n");
@@ -217,7 +221,7 @@ load_decode_table(char *file_name)
{
(*last) = ZALLOC (decode_path_list);
/* extra root/zero entry */
- (*last)->path = ZALLOC (decode_path);
+ (*last)->path = ZALLOC (decode_path);
do
{
decode_path *entry = ZALLOC (decode_path);
@@ -244,22 +248,32 @@ load_decode_table(char *file_name)
decode_cond *cond = ZALLOC (decode_cond);
decode_cond **last;
if (entry->nr_fields > field_nr + decode_cond_mask_field)
- set_bits (cond->mask, a2i (entry->field[field_nr + decode_cond_mask_field]));
+ set_bits (cond->mask,
+ a2i (entry->
+ field[field_nr + decode_cond_mask_field]));
if (entry->nr_fields > field_nr + decode_cond_value_field)
- {
- if (entry->field[field_nr + decode_cond_value_field][0] == '!')
- {
- cond->is_equal = 0;
- set_bits (cond->value, a2i (entry->field[field_nr + decode_cond_value_field] + 1));
- }
- else
- {
- cond->is_equal = 1;
- set_bits (cond->value, a2i (entry->field[field_nr + decode_cond_value_field]));
- }
- }
+ {
+ if (entry->field[field_nr + decode_cond_value_field][0] ==
+ '!')
+ {
+ cond->is_equal = 0;
+ set_bits (cond->value,
+ a2i (entry->
+ field[field_nr + decode_cond_value_field] +
+ 1));
+ }
+ else
+ {
+ cond->is_equal = 1;
+ set_bits (cond->value,
+ a2i (entry->
+ field[field_nr +
+ decode_cond_value_field]));
+ }
+ }
if (entry->nr_fields > field_nr + decode_cond_word_nr_field)
- cond->word_nr = a2i (entry->field[field_nr + decode_cond_word_nr_field]);
+ cond->word_nr =
+ a2i (entry->field[field_nr + decode_cond_word_nr_field]);
field_nr += nr_decode_cond_fields;
/* insert it */
last = &new_rule->conditions;
@@ -274,7 +288,7 @@ load_decode_table(char *file_name)
return table;
}
-
+
int
decode_table_max_word_nr (decode_table *entry)
{
@@ -297,10 +311,7 @@ decode_table_max_word_nr (decode_table *entry)
static void
-dump_decode_cond (lf *file,
- char *prefix,
- decode_cond *cond,
- char *suffix)
+dump_decode_cond (lf *file, char *prefix, decode_cond *cond, char *suffix)
{
lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond);
if (cond != NULL)
@@ -318,10 +329,7 @@ dump_decode_cond (lf *file,
static void
-dump_decode_conds (lf *file,
- char *prefix,
- decode_cond *cond,
- char *suffix)
+dump_decode_conds (lf *file, char *prefix, decode_cond *cond, char *suffix)
{
lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond);
while (cond != NULL)
@@ -334,23 +342,21 @@ dump_decode_conds (lf *file,
void
-dump_decode_rule (lf *file,
- char *prefix,
- decode_table *rule,
- char *suffix)
+dump_decode_rule (lf *file, char *prefix, decode_table *rule, char *suffix)
{
lf_printf (file, "%s(decode_table *) 0x%lx", prefix, (long) rule);
if (rule != NULL)
{
lf_indent (file, +1);
dump_line_ref (file, "\n(line ", rule->line, ")");
- lf_printf (file, "\n(type %s)", i2name(rule->type, decode_type_map));
- lf_printf (file, "\n(gen %s)", i2name(rule->gen, decode_gen_map));
+ lf_printf (file, "\n(type %s)", i2name (rule->type, decode_type_map));
+ lf_printf (file, "\n(gen %s)", i2name (rule->gen, decode_gen_map));
lf_printf (file, "\n(first %d)", rule->first);
lf_printf (file, "\n(last %d)", rule->last);
lf_printf (file, "\n(force_first %d)", rule->force_first);
lf_printf (file, "\n(force_last %d)", rule->force_last);
- dump_filter (file, "\n(constant_field_names \"", rule->constant_field_names, "\")");
+ dump_filter (file, "\n(constant_field_names \"",
+ rule->constant_field_names, "\")");
lf_printf (file, "\n(constant 0x%x)", rule->constant);
lf_printf (file, "\n(word_nr %d)", rule->word_nr);
lf_printf (file, "\n(with_zero_reserved %d)", rule->with_zero_reserved);
@@ -369,10 +375,7 @@ dump_decode_rule (lf *file,
#ifdef MAIN
static void
-dump_decode_rules (lf *file,
- char *prefix,
- decode_table *rule,
- char *suffix)
+dump_decode_rules (lf *file, char *prefix, decode_table *rule, char *suffix)
{
lf_printf (file, "%s", prefix);
while (rule != NULL)
@@ -388,7 +391,7 @@ dump_decode_rules (lf *file,
igen_options options;
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
lf *l;
decode_table *rules;
diff --git a/sim/igen/ld-decode.h b/sim/igen/ld-decode.h
index 1060f9c..329e80d 100644
--- a/sim/igen/ld-decode.h
+++ b/sim/igen/ld-decode.h
@@ -133,22 +133,27 @@
*/
-typedef enum {
+typedef enum
+{
normal_decode_rule,
boolean_rule,
-} decode_special_type;
+}
+decode_special_type;
-typedef enum {
+typedef enum
+{
invalid_gen,
array_gen,
switch_gen,
padded_switch_gen,
goto_switch_gen,
-} decode_gen_type;
+}
+decode_gen_type;
-enum {
+enum
+{
decode_cond_mask_field,
decode_cond_value_field,
decode_cond_word_nr_field,
@@ -156,20 +161,23 @@ enum {
};
typedef struct _decode_path decode_path;
-struct _decode_path {
+struct _decode_path
+{
int opcode_nr;
decode_path *parent;
};
typedef struct _decode_path_list decode_path_list;
-struct _decode_path_list {
+struct _decode_path_list
+{
decode_path *path;
decode_path_list *next;
};
typedef struct _decode_cond decode_cond;
-struct _decode_cond {
+struct _decode_cond
+{
int word_nr;
int mask[max_insn_bit_size];
int value[max_insn_bit_size];
@@ -177,13 +185,16 @@ struct _decode_cond {
decode_cond *next;
};
-typedef enum {
+typedef enum
+{
decode_find_mixed,
decode_find_constants,
decode_find_strings,
-} decode_search_type;
+}
+decode_search_type;
-enum {
+enum
+{
decode_options_field,
decode_first_field,
decode_last_field,
@@ -200,7 +211,8 @@ enum {
typedef struct _decode_table decode_table;
-struct _decode_table {
+struct _decode_table
+{
line_ref *line;
decode_special_type type;
decode_gen_type gen;
@@ -226,14 +238,9 @@ struct _decode_table {
};
-extern decode_table *load_decode_table
-(char *file_name);
+extern decode_table *load_decode_table (char *file_name);
-extern int decode_table_max_word_nr
-(decode_table *rule);
+extern int decode_table_max_word_nr (decode_table *rule);
extern void dump_decode_rule
-(lf *file,
- char *prefix,
- decode_table *rule,
- char *suffix);
+ (lf *file, char *prefix, decode_table *rule, char *suffix);
diff --git a/sim/igen/ld-insn.c b/sim/igen/ld-insn.c
index 01f1f5a..d74ff5b 100644
--- a/sim/igen/ld-insn.c
+++ b/sim/igen/ld-insn.c
@@ -30,9 +30,7 @@
#include "ld-insn.h"
static insn_word_entry *
-parse_insn_word (line_ref *line,
- char *string,
- int word_nr)
+parse_insn_word (line_ref *line, char *string, int word_nr)
{
char *chp;
insn_word_entry *word = ZALLOC (insn_word_entry);
@@ -56,241 +54,244 @@ parse_insn_word (line_ref *line,
/* now work through the formats */
chp = skip_spaces (string);
- while (*chp != '\0') {
- char *start_pos;
- int strlen_pos;
- char *start_val;
- int strlen_val;
- insn_field_entry *new_field;
-
- /* create / link in the new field */
- new_field = ZALLOC (insn_field_entry);
- new_field->next = word->last;
- new_field->prev = word->last->prev;
- new_field->next->prev = new_field;
- new_field->prev->next = new_field;
- new_field->word_nr = word_nr;
-
- /* break out the first field (if present) */
- start_pos = chp;
- chp = skip_to_separator (chp, ".,!");
- strlen_pos = back_spaces (start_pos, chp) - start_pos;
-
- /* break out the second field (if present) */
- if (*chp != '.')
- {
- /* assume what was specified was the value (and not the start
- position). Assume the value length implicitly specifies
- the number of bits */
- start_val = start_pos;
- strlen_val = strlen_pos;
- start_pos = "";
- strlen_pos = 0;
- }
- else
- {
- chp++; /* skip `.' */
- chp = skip_spaces (chp);
- start_val = chp;
- if (*chp == '/' || *chp == '*')
- {
- do
- {
- chp++;
- }
- while (*chp == '/' || *chp == '*');
- }
- else if (isalpha(*start_val))
- {
- do
- {
- chp++;
- }
- while (isalnum(*chp) || *chp == '_');
- }
- else if (isdigit(*start_val))
- {
- do {
- chp++;
+ while (*chp != '\0')
+ {
+ char *start_pos;
+ int strlen_pos;
+ char *start_val;
+ int strlen_val;
+ insn_field_entry *new_field;
+
+ /* create / link in the new field */
+ new_field = ZALLOC (insn_field_entry);
+ new_field->next = word->last;
+ new_field->prev = word->last->prev;
+ new_field->next->prev = new_field;
+ new_field->prev->next = new_field;
+ new_field->word_nr = word_nr;
+
+ /* break out the first field (if present) */
+ start_pos = chp;
+ chp = skip_to_separator (chp, ".,!");
+ strlen_pos = back_spaces (start_pos, chp) - start_pos;
+
+ /* break out the second field (if present) */
+ if (*chp != '.')
+ {
+ /* assume what was specified was the value (and not the start
+ position). Assume the value length implicitly specifies
+ the number of bits */
+ start_val = start_pos;
+ strlen_val = strlen_pos;
+ start_pos = "";
+ strlen_pos = 0;
+ }
+ else
+ {
+ chp++; /* skip `.' */
+ chp = skip_spaces (chp);
+ start_val = chp;
+ if (*chp == '/' || *chp == '*')
+ {
+ do
+ {
+ chp++;
+ }
+ while (*chp == '/' || *chp == '*');
}
- while (isalnum(*chp));
- }
- strlen_val = chp - start_val;
- chp = skip_spaces (chp);
- }
- if (strlen_val == 0)
- error (line, "Empty value field\n");
-
- /* break out any conditional fields - { [ "!" | "=" [ <value> | <field-name> } */
- while (*chp == '!' || *chp == '=')
- {
- char *start;
- char *end;
- int len;
- insn_field_cond *new_cond = ZALLOC (insn_field_cond);
-
- /* determine the conditional test */
- switch (*chp)
- {
- case '=':
- new_cond->test = insn_field_cond_eq;
- break;
- case '!':
- new_cond->test = insn_field_cond_ne;
- break;
- default:
- ASSERT (0);
- }
-
- /* save the value */
- chp++;
- chp = skip_spaces (chp);
- start = chp;
- chp = skip_to_separator (chp, "+,:!=");
- end = back_spaces (start, chp);
- len = end - start;
- if (len == 0)
- error (line, "Missing or invalid conditional value\n");
- new_cond->string = NZALLOC (char, len + 1);
- strncpy (new_cond->string, start, len);
-
- /* determine the conditional type */
- if (isdigit (*start))
- {
- /* [ "!" | "=" ] <value> */
- new_cond->type = insn_field_cond_value;
- new_cond->value = a2i (new_cond->string);
- }
- else
+ else if (isalpha (*start_val))
+ {
+ do
+ {
+ chp++;
+ }
+ while (isalnum (*chp) || *chp == '_');
+ }
+ else if (isdigit (*start_val))
+ {
+ do
+ {
+ chp++;
+ }
+ while (isalnum (*chp));
+ }
+ strlen_val = chp - start_val;
+ chp = skip_spaces (chp);
+ }
+ if (strlen_val == 0)
+ error (line, "Empty value field\n");
+
+ /* break out any conditional fields - { [ "!" | "=" [ <value> | <field-name> } */
+ while (*chp == '!' || *chp == '=')
+ {
+ char *start;
+ char *end;
+ int len;
+ insn_field_cond *new_cond = ZALLOC (insn_field_cond);
+
+ /* determine the conditional test */
+ switch (*chp)
+ {
+ case '=':
+ new_cond->test = insn_field_cond_eq;
+ break;
+ case '!':
+ new_cond->test = insn_field_cond_ne;
+ break;
+ default:
+ ASSERT (0);
+ }
+
+ /* save the value */
+ chp++;
+ chp = skip_spaces (chp);
+ start = chp;
+ chp = skip_to_separator (chp, "+,:!=");
+ end = back_spaces (start, chp);
+ len = end - start;
+ if (len == 0)
+ error (line, "Missing or invalid conditional value\n");
+ new_cond->string = NZALLOC (char, len + 1);
+ strncpy (new_cond->string, start, len);
+
+ /* determine the conditional type */
+ if (isdigit (*start))
+ {
+ /* [ "!" | "=" ] <value> */
+ new_cond->type = insn_field_cond_value;
+ new_cond->value = a2i (new_cond->string);
+ }
+ else
+ {
+ /* [ "!" | "=" ] <field> - check field valid */
+ new_cond->type = insn_field_cond_field;
+ /* new_cond->field is determined in later */
+ }
+
+ /* Only a single `=' is permitted. */
+ if ((new_cond->test == insn_field_cond_eq
+ && new_field->conditions != NULL)
+ || (new_field->conditions != NULL
+ && new_field->conditions->test == insn_field_cond_eq))
+ error (line, "Only single conditional when `=' allowed\n");
+
+ /* insert it */
{
- /* [ "!" | "=" ] <field> - check field valid */
- new_cond->type = insn_field_cond_field;
- /* new_cond->field is determined in later */
+ insn_field_cond **last = &new_field->conditions;
+ while (*last != NULL)
+ last = &(*last)->next;
+ *last = new_cond;
}
-
- /* Only a single `=' is permitted. */
- if ((new_cond->test == insn_field_cond_eq
- && new_field->conditions != NULL)
- || (new_field->conditions != NULL
- && new_field->conditions->test == insn_field_cond_eq))
- error (line, "Only single conditional when `=' allowed\n");
-
- /* insert it */
+ }
+
+ /* NOW verify that the field was finished */
+ if (*chp == ',')
{
- insn_field_cond **last = &new_field->conditions;
- while (*last != NULL)
- last = &(*last)->next;
- *last = new_cond;
+ chp = skip_spaces (chp + 1);
+ if (*chp == '\0')
+ error (line, "empty field\n");
+ }
+ else if (*chp != '\0')
+ {
+ error (line, "Missing field separator\n");
}
- }
- /* NOW verify that the field was finished */
- if (*chp == ',')
- {
- chp = skip_spaces (chp + 1);
- if (*chp == '\0')
- error (line, "empty field\n");
- }
- else if (*chp != '\0')
- {
- error (line, "Missing field separator\n");
- }
+ /* copy the value */
+ new_field->val_string = NZALLOC (char, strlen_val + 1);
+ strncpy (new_field->val_string, start_val, strlen_val);
+ if (isdigit (new_field->val_string[0]))
+ {
+ if (strlen_pos == 0)
+ {
+ /* when the length/pos field is omited, an integer field
+ is always binary */
+ unsigned64 val = 0;
+ int i;
+ for (i = 0; i < strlen_val; i++)
+ {
+ if (new_field->val_string[i] != '0'
+ && new_field->val_string[i] != '1')
+ error (line, "invalid binary field %s\n",
+ new_field->val_string);
+ val = (val << 1) + (new_field->val_string[i] == '1');
+ }
+ new_field->val_int = val;
+ new_field->type = insn_field_int;
+ }
+ else
+ {
+ new_field->val_int = a2i (new_field->val_string);
+ new_field->type = insn_field_int;
+ }
+ }
+ else if (new_field->val_string[0] == '/')
+ {
+ new_field->type = insn_field_reserved;
+ }
+ else if (new_field->val_string[0] == '*')
+ {
+ new_field->type = insn_field_wild;
+ }
+ else
+ {
+ new_field->type = insn_field_string;
+ if (filter_is_member (word->field_names, new_field->val_string))
+ error (line, "Field name %s is duplicated\n",
+ new_field->val_string);
+ filter_parse (&word->field_names, new_field->val_string);
+ }
+ if (new_field->type != insn_field_string
+ && new_field->conditions != NULL)
+ error (line, "Conditionals can only be applied to named fields\n");
- /* copy the value */
- new_field->val_string = NZALLOC (char, strlen_val+1);
- strncpy (new_field->val_string, start_val, strlen_val);
- if (isdigit (new_field->val_string[0]))
- {
- if (strlen_pos == 0)
- {
- /* when the length/pos field is omited, an integer field
- is always binary */
- unsigned64 val = 0;
- int i;
- for (i = 0; i < strlen_val; i++)
- {
- if (new_field->val_string[i] != '0'
- && new_field->val_string[i] != '1')
- error (line, "invalid binary field %s\n",
- new_field->val_string);
- val = (val << 1) + (new_field->val_string[i] == '1');
- }
- new_field->val_int = val;
- new_field->type = insn_field_int;
- }
- else
- {
- new_field->val_int = a2i (new_field->val_string);
- new_field->type = insn_field_int;
- }
- }
- else if (new_field->val_string[0] == '/')
- {
- new_field->type = insn_field_reserved;
- }
- else if (new_field->val_string[0] == '*')
- {
- new_field->type = insn_field_wild;
- }
- else
- {
- new_field->type = insn_field_string;
- if (filter_is_member (word->field_names, new_field->val_string))
- error (line, "Field name %s is duplicated\n", new_field->val_string);
- filter_parse (&word->field_names, new_field->val_string);
- }
- if (new_field->type != insn_field_string
- && new_field->conditions != NULL)
- error (line, "Conditionals can only be applied to named fields\n");
-
- /* the copy the position */
- new_field->pos_string = NZALLOC (char, strlen_pos + 1);
- strncpy (new_field->pos_string, start_pos, strlen_pos);
- if (strlen_pos == 0)
- {
- new_field->first = new_field->prev->last + 1;
- if (new_field->first == 0 /* first field */
- && *chp == '\0' /* no further fields */
- && new_field->type == insn_field_string)
- {
- /* A single string without any position, assume that it
- represents the entire instruction word */
- new_field->width = options.insn_bit_size;
- }
- else
- {
- /* No explicit width/position, assume value implicitly
- supplies the width */
- new_field->width = strlen_val;
- }
- new_field->last = new_field->first + new_field->width - 1;
- if (new_field->last >= options.insn_bit_size)
- error (line, "Bit position %d exceed instruction bit size (%d)\n",
- new_field->last, options.insn_bit_size);
- }
- else if (options.insn_specifying_widths)
- {
- new_field->first = new_field->prev->last + 1;
- new_field->width = a2i(new_field->pos_string);
- new_field->last = new_field->first + new_field->width - 1;
- if (new_field->last >= options.insn_bit_size)
- error (line, "Bit position %d exceed instruction bit size (%d)\n",
- new_field->last, options.insn_bit_size);
- }
- else
- {
- new_field->first = target_a2i(options.hi_bit_nr,
- new_field->pos_string);
- new_field->last = new_field->next->first - 1; /* guess */
- new_field->width = new_field->last - new_field->first + 1; /* guess */
- new_field->prev->last = new_field->first - 1; /*fix*/
- new_field->prev->width = new_field->first - new_field->prev->first; /*fix*/
- }
- }
+ /* the copy the position */
+ new_field->pos_string = NZALLOC (char, strlen_pos + 1);
+ strncpy (new_field->pos_string, start_pos, strlen_pos);
+ if (strlen_pos == 0)
+ {
+ new_field->first = new_field->prev->last + 1;
+ if (new_field->first == 0 /* first field */
+ && *chp == '\0' /* no further fields */
+ && new_field->type == insn_field_string)
+ {
+ /* A single string without any position, assume that it
+ represents the entire instruction word */
+ new_field->width = options.insn_bit_size;
+ }
+ else
+ {
+ /* No explicit width/position, assume value implicitly
+ supplies the width */
+ new_field->width = strlen_val;
+ }
+ new_field->last = new_field->first + new_field->width - 1;
+ if (new_field->last >= options.insn_bit_size)
+ error (line, "Bit position %d exceed instruction bit size (%d)\n",
+ new_field->last, options.insn_bit_size);
+ }
+ else if (options.insn_specifying_widths)
+ {
+ new_field->first = new_field->prev->last + 1;
+ new_field->width = a2i (new_field->pos_string);
+ new_field->last = new_field->first + new_field->width - 1;
+ if (new_field->last >= options.insn_bit_size)
+ error (line, "Bit position %d exceed instruction bit size (%d)\n",
+ new_field->last, options.insn_bit_size);
+ }
+ else
+ {
+ new_field->first = target_a2i (options.hi_bit_nr,
+ new_field->pos_string);
+ new_field->last = new_field->next->first - 1; /* guess */
+ new_field->width = new_field->last - new_field->first + 1; /* guess */
+ new_field->prev->last = new_field->first - 1; /*fix */
+ new_field->prev->width = new_field->first - new_field->prev->first; /*fix */
+ }
+ }
/* fiddle first/last so that the sentinals disapear */
- ASSERT(word->first->last < 0);
- ASSERT(word->last->first >= options.insn_bit_size);
+ ASSERT (word->first->last < 0);
+ ASSERT (word->last->first >= options.insn_bit_size);
word->first = word->first->next;
word->last = word->last->prev;
@@ -308,8 +309,7 @@ parse_insn_word (line_ref *line,
{
insn_field_entry *field;
for (field = word->first;
- field->last < options.insn_bit_size;
- field = field->next)
+ field->last < options.insn_bit_size; field = field->next)
{
int i;
for (i = field->first; i <= field->last; i++)
@@ -324,21 +324,21 @@ parse_insn_word (line_ref *line,
case insn_field_int:
word->bit[i]->mask = 1;
word->bit[i]->value = ((field->val_int
- & ((insn_uint)1 << (field->last - i)))
- != 0);
+ & ((insn_uint) 1 <<
+ (field->last - i))) != 0);
case insn_field_reserved:
case insn_field_wild:
case insn_field_string:
/* if we encounter a constant conditional, encode
- their bit value. */
+ their bit value. */
if (field->conditions != NULL
&& field->conditions->test == insn_field_cond_eq
&& field->conditions->type == insn_field_cond_value)
{
word->bit[i]->mask = 1;
word->bit[i]->value = ((field->conditions->value
- & ((insn_uint)1 << (field->last - i)))
- != 0);
+ & ((insn_uint) 1 <<
+ (field->last - i))) != 0);
}
break;
}
@@ -351,8 +351,7 @@ parse_insn_word (line_ref *line,
static void
-parse_insn_words (insn_entry *insn,
- char *formats)
+parse_insn_words (insn_entry * insn, char *formats)
{
insn_word_entry **last_word = &insn->words;
char *chp;
@@ -408,8 +407,7 @@ parse_insn_words (insn_entry *insn,
insn_word_entry *word;
insn->word = NZALLOC (insn_word_entry *, insn->nr_words + 1);
for (i = 0, word = insn->words;
- i < insn->nr_words;
- i++, word = word->next)
+ i < insn->nr_words; i++, word = word->next)
insn->word[i] = word;
}
@@ -422,14 +420,10 @@ parse_insn_words (insn_entry *insn,
{
insn_word_entry *word = insn->word[i];
insn_field_entry *f;
- for (f = word->first;
- f->last < options.insn_bit_size;
- f = f->next)
+ for (f = word->first; f->last < options.insn_bit_size; f = f->next)
{
insn_field_cond *cond;
- for (cond = f->conditions;
- cond != NULL;
- cond = cond->next)
+ for (cond = f->conditions; cond != NULL; cond = cond->next)
{
if (cond->type == insn_field_cond_field)
{
@@ -447,7 +441,8 @@ parse_insn_words (insn_entry *insn,
refered_field = refered_field->next)
{
if (refered_field->type == insn_field_string
- && strcmp (refered_field->val_string, cond->string) == 0)
+ && strcmp (refered_field->val_string,
+ cond->string) == 0)
{
/* found field being refered to by conditonal */
cond->field = refered_field;
@@ -456,7 +451,8 @@ parse_insn_words (insn_entry *insn,
if (f->width != refered_field->width)
error (insn->line,
"Conditional `%s' of field `%s' should be of size %s\n",
- cond->string, f->val_string, refered_field->width);
+ cond->string, f->val_string,
+ refered_field->width);
}
}
}
@@ -469,12 +465,13 @@ parse_insn_words (insn_entry *insn,
}
}
}
-
+
}
-typedef enum {
+typedef enum
+{
unknown_record = 0,
- insn_record, /* default */
+ insn_record, /* default */
code_record,
cache_record,
compute_record,
@@ -491,25 +488,26 @@ typedef enum {
model_static_record,
model_function_record,
model_internal_record,
-} insn_record_type;
+}
+insn_record_type;
static const name_map insn_type_map[] = {
- { "option", option_record },
- { "cache", cache_record },
- { "compute", compute_record },
- { "scratch", scratch_record },
- { "define", define_record },
- { "include", include_record },
- { "%s", string_function_record },
- { "function", function_record },
- { "internal", internal_record },
- { "model", model_processor_record },
- { "model-macro", model_macro_record },
- { "model-data", model_data_record },
- { "model-static", model_static_record },
- { "model-internal", model_internal_record },
- { "model-function", model_function_record },
- { NULL, insn_record },
+ {"option", option_record},
+ {"cache", cache_record},
+ {"compute", compute_record},
+ {"scratch", scratch_record},
+ {"define", define_record},
+ {"include", include_record},
+ {"%s", string_function_record},
+ {"function", function_record},
+ {"internal", internal_record},
+ {"model", model_processor_record},
+ {"model-macro", model_macro_record},
+ {"model-data", model_data_record},
+ {"model-static", model_static_record},
+ {"model-internal", model_internal_record},
+ {"model-function", model_function_record},
+ {NULL, insn_record},
};
@@ -554,15 +552,13 @@ record_type (table_entry *entry)
return i;
}
else
- return insn_record; /* default */
+ return insn_record; /* default */
}
return unknown_record;
}
static int
-record_prefix_is (table_entry *entry,
- char ch,
- int nr_fields)
+record_prefix_is (table_entry *entry, char ch, int nr_fields)
{
if (entry->type != table_colon_entry)
return 0;
@@ -577,8 +573,7 @@ static table_entry *
parse_model_data_record (insn_table *isa,
table *file,
table_entry *record,
- int nr_fields,
- model_data **list)
+ int nr_fields, model_data **list)
{
table_entry *model_record = record;
table_entry *code_record = NULL;
@@ -612,7 +607,8 @@ parse_model_data_record (insn_table *isa,
}
-typedef enum {
+typedef enum
+{
insn_bit_size_option = 1,
insn_specifying_widths_option,
hi_bit_nr_option,
@@ -622,23 +618,23 @@ typedef enum {
format_names_option,
gen_delayed_branch,
unknown_option,
-} option_names;
+}
+option_names;
static const name_map option_map[] = {
- { "insn-bit-size", insn_bit_size_option },
- { "insn-specifying-widths", insn_specifying_widths_option },
- { "hi-bit-nr", hi_bit_nr_option },
- { "flags-filter", flags_filter_option },
- { "model-filter", model_filter_option },
- { "multi-sim", multi_sim_option },
- { "format-names", format_names_option },
- { "gen-delayed-branch", gen_delayed_branch },
- { NULL, unknown_option },
+ {"insn-bit-size", insn_bit_size_option},
+ {"insn-specifying-widths", insn_specifying_widths_option},
+ {"hi-bit-nr", hi_bit_nr_option},
+ {"flags-filter", flags_filter_option},
+ {"model-filter", model_filter_option},
+ {"multi-sim", multi_sim_option},
+ {"format-names", format_names_option},
+ {"gen-delayed-branch", gen_delayed_branch},
+ {NULL, unknown_option},
};
static table_entry *
-parse_include_record (table *file,
- table_entry *record)
+parse_include_record (table *file, table_entry *record)
{
/* parse the include record */
if (record->nr_fields < nr_include_fields)
@@ -651,7 +647,7 @@ parse_include_record (table *file,
{
table_push (file, record->line, options.include,
record->field[include_filename_field]);
- }
+ }
/* nb: can't read next record until after the file has been pushed */
record = table_read (file);
return record;
@@ -659,8 +655,7 @@ parse_include_record (table *file,
static table_entry *
-parse_option_record (table *file,
- table_entry *record)
+parse_option_record (table *file, table_entry *record)
{
table_entry *option_record;
/* parse the option record */
@@ -684,10 +679,12 @@ parse_option_record (table *file,
options.insn_bit_size = a2i (value);
if (options.insn_bit_size < 0
|| options.insn_bit_size > max_insn_bit_size)
- error (option_record->line, "Instruction bit size out of range\n");
+ error (option_record->line,
+ "Instruction bit size out of range\n");
if (options.hi_bit_nr != options.insn_bit_size - 1
&& options.hi_bit_nr != 0)
- error (option_record->line, "insn-bit-size / hi-bit-nr conflict\n");
+ error (option_record->line,
+ "insn-bit-size / hi-bit-nr conflict\n");
break;
}
case insn_specifying_widths_option:
@@ -700,7 +697,8 @@ parse_option_record (table *file,
options.hi_bit_nr = a2i (value);
if (options.hi_bit_nr != 0
&& options.hi_bit_nr != options.insn_bit_size - 1)
- error (option_record->line, "hi-bit-nr / insn-bit-size conflict\n");
+ error (option_record->line,
+ "hi-bit-nr / insn-bit-size conflict\n");
break;
}
case flags_filter_option:
@@ -734,7 +732,7 @@ parse_option_record (table *file,
break;
}
}
- }
+ }
return record;
}
@@ -742,10 +740,9 @@ parse_option_record (table *file,
static table_entry *
parse_function_record (table *file,
table_entry *record,
- function_entry **list,
- function_entry **list_entry,
- int is_internal,
- model_table *model)
+ function_entry ** list,
+ function_entry ** list_entry,
+ int is_internal, model_table *model)
{
function_entry *new_function;
new_function = ZALLOC (function_entry);
@@ -779,7 +776,7 @@ parse_function_record (table *file,
while (record != NULL
&& record_prefix_is (record, '*', nr_function_model_fields))
{
- char *model_name = record->field[function_model_name_field] + 1; /*skip `*'*/
+ char *model_name = record->field[function_model_name_field] + 1; /*skip `*' */
filter_parse (&new_function->models, model_name);
if (!filter_is_subset (model->processors, new_function->models))
{
@@ -804,7 +801,8 @@ parse_function_record (table *file,
&& !filter_is_common (options.model_filter, new_function->models))
{
if (options.warn.discard)
- notify (new_function->line, "Discarding function %s - filter models\n",
+ notify (new_function->line,
+ "Discarding function %s - filter models\n",
new_function->name);
}
else
@@ -822,8 +820,7 @@ parse_function_record (table *file,
static void
parse_insn_model_record (table *file,
table_entry *record,
- insn_entry *insn,
- model_table *model)
+ insn_entry * insn, model_table *model)
{
insn_model_entry **last_insn_model;
insn_model_entry *new_insn_model = ZALLOC (insn_model_entry);
@@ -835,11 +832,11 @@ parse_insn_model_record (table *file,
/* parse the model names, verify that all were defined */
new_insn_model->names = NULL;
filter_parse (&new_insn_model->names,
- record->field[insn_model_name_field] + 1 /*skip `*'*/);
+ record->field[insn_model_name_field] + 1 /*skip `*' */ );
if (new_insn_model->names == NULL)
{
/* No processor names - a generic model entry, enter it into all
- the non-empty fields */
+ the non-empty fields */
int index;
for (index = 0; index < model->nr_models; index++)
if (insn->model[index] == 0)
@@ -858,7 +855,8 @@ parse_insn_model_record (table *file,
while (1)
{
name = filter_next (new_insn_model->names, name);
- if (name == NULL) break;
+ if (name == NULL)
+ break;
index = filter_is_member (model->processors, name) - 1;
if (index < 0)
{
@@ -866,8 +864,7 @@ parse_insn_model_record (table *file,
"machine model `%s' undefined\n", name);
}
/* store it in the corresponding model array entry */
- if (insn->model[index] != NULL
- && insn->model[index]->names != NULL)
+ if (insn->model[index] != NULL && insn->model[index]->names != NULL)
{
warning (new_insn_model->line,
"machine model `%s' previously defined\n", name);
@@ -896,8 +893,7 @@ parse_insn_model_record (table *file,
static void
parse_insn_mnemonic_record (table *file,
- table_entry *record,
- insn_entry *insn)
+ table_entry *record, insn_entry * insn)
{
insn_mnemonic_entry **last_insn_mnemonic;
insn_mnemonic_entry *new_insn_mnemonic = ZALLOC (insn_mnemonic_entry);
@@ -906,10 +902,13 @@ parse_insn_mnemonic_record (table *file,
ASSERT (record->nr_fields > insn_mnemonic_format_field);
new_insn_mnemonic->format = record->field[insn_mnemonic_format_field];
ASSERT (new_insn_mnemonic->format[0] == '"');
- if (new_insn_mnemonic->format[strlen (new_insn_mnemonic->format) - 1] != '"')
- error (new_insn_mnemonic->line, "Missing closing double quote in mnemonic field\n");
+ if (new_insn_mnemonic->format[strlen (new_insn_mnemonic->format) - 1] !=
+ '"')
+ error (new_insn_mnemonic->line,
+ "Missing closing double quote in mnemonic field\n");
if (record->nr_fields > insn_mnemonic_condition_field)
- new_insn_mnemonic->condition = record->field[insn_mnemonic_condition_field];
+ new_insn_mnemonic->condition =
+ record->field[insn_mnemonic_condition_field];
new_insn_mnemonic->insn = insn;
/* insert it */
last_insn_mnemonic = &insn->mnemonics;
@@ -921,8 +920,7 @@ parse_insn_mnemonic_record (table *file,
static table_entry *
-parse_macro_record (table *file,
- table_entry *record)
+parse_macro_record (table *file, table_entry *record)
{
#if 1
error (record->line, "Macros are not implemented");
@@ -941,7 +939,7 @@ parse_macro_record (table *file,
record->field[macro_name_field],
record->field[macro_args_field],
record->field[macro_expr_field]);
- }
+ }
record = table_read (file);
#endif
return record;
@@ -949,15 +947,14 @@ parse_macro_record (table *file,
insn_table *
-load_insn_table (char *file_name,
- cache_entry *cache)
+load_insn_table (char *file_name, cache_entry *cache)
{
table *file = table_open (file_name);
table_entry *record = table_read (file);
insn_table *isa = ZALLOC (insn_table);
model_table *model = ZALLOC (model_table);
-
+
isa->model = model;
isa->caches = cache;
@@ -980,22 +977,20 @@ load_insn_table (char *file_name,
record = parse_option_record (file, record);
break;
}
-
+
case string_function_record:
{
function_entry *function = NULL;
record = parse_function_record (file, record,
&isa->functions,
- &function,
- 0/*is-internal*/,
+ &function, 0 /*is-internal */ ,
model);
/* convert a string function record into an internal function */
if (function != NULL)
{
char *name = NZALLOC (char,
(strlen ("str_")
- + strlen (function->name)
- + 1));
+ + strlen (function->name) + 1));
strcat (name, "str_");
strcat (name, function->name);
function->name = name;
@@ -1003,13 +998,12 @@ load_insn_table (char *file_name,
}
break;
}
-
- case function_record: /* function record */
+
+ case function_record: /* function record */
{
record = parse_function_record (file, record,
&isa->functions,
- NULL,
- 0/*is-internal*/,
+ NULL, 0 /*is-internal */ ,
model);
break;
}
@@ -1020,11 +1014,10 @@ load_insn_table (char *file_name,
function_entry *function = NULL;
record = parse_function_record (file, record,
&isa->functions,
- &function,
- 1/*is-internal*/,
+ &function, 1 /*is-internal */ ,
model);
/* check what was inserted to see if a pseudo-instruction
- entry also needs to be created */
+ entry also needs to be created */
if (function != NULL)
{
insn_entry **insn = NULL;
@@ -1051,8 +1044,8 @@ load_insn_table (char *file_name,
}
break;
}
-
- case scratch_record: /* cache macro records */
+
+ case scratch_record: /* cache macro records */
case cache_record:
case compute_record:
{
@@ -1076,13 +1069,16 @@ load_insn_table (char *file_name,
/* insert it but only if not filtered out */
if (!filter_is_subset (options.flags_filter, new_cache->flags))
{
- notify (new_cache->line, "Discarding cache entry %s - filter flags\n",
+ notify (new_cache->line,
+ "Discarding cache entry %s - filter flags\n",
new_cache->name);
}
else if (is_filtered_out (options.model_filter,
- record->field[record_filter_models_field]))
+ record->
+ field[record_filter_models_field]))
{
- notify (new_cache->line, "Discarding cache entry %s - filter models\n",
+ notify (new_cache->line,
+ "Discarding cache entry %s - filter models\n",
new_cache->name);
}
else
@@ -1097,14 +1093,15 @@ load_insn_table (char *file_name,
record = table_read (file);
break;
}
-
- /* model records */
+
+ /* model records */
case model_processor_record:
{
model_entry *new_model;
/* parse the model */
if (record->nr_fields < nr_model_processor_fields)
- error (record->line, "Incorrect nr of fields for model record\n");
+ error (record->line,
+ "Incorrect nr of fields for model record\n");
if (isa->insns != NULL)
error (record->line, "Model appears after first instruction\n");
new_model = ZALLOC (model_entry);
@@ -1117,13 +1114,16 @@ load_insn_table (char *file_name,
/* only insert it if not filtered out */
if (!filter_is_subset (options.flags_filter, new_model->flags))
{
- notify (new_model->line, "Discarding processor model %s - filter flags\n",
+ notify (new_model->line,
+ "Discarding processor model %s - filter flags\n",
new_model->name);
}
else if (is_filtered_out (options.model_filter,
- record->field[record_filter_models_field]))
+ record->
+ field[record_filter_models_field]))
{
- notify (new_model->line, "Discarding processor model %s - filter models\n",
+ notify (new_model->line,
+ "Discarding processor model %s - filter models\n",
new_model->name);
}
else if (filter_is_member (model->processors, new_model->name))
@@ -1139,70 +1139,69 @@ load_insn_table (char *file_name,
last = &(*last)->next;
*last = new_model;
/* count it */
- model->nr_models ++;
+ model->nr_models++;
filter_parse (&model->processors, new_model->name);
}
/* advance things */
record = table_read (file);
}
break;
-
+
case model_macro_record:
record = parse_model_data_record (isa, file, record,
nr_model_macro_fields,
&model->macros);
break;
-
+
case model_data_record:
record = parse_model_data_record (isa, file, record,
nr_model_data_fields,
&model->data);
break;
-
+
case model_static_record:
record = parse_function_record (file, record,
&model->statics,
- NULL,
- 0/*is internal*/,
+ NULL, 0 /*is internal */ ,
model);
break;
-
+
case model_internal_record:
record = parse_function_record (file, record,
&model->internals,
- NULL,
- 1/*is internal*/,
+ NULL, 1 /*is internal */ ,
model);
break;
-
+
case model_function_record:
record = parse_function_record (file, record,
&model->functions,
- NULL,
- 0/*is internal*/,
+ NULL, 0 /*is internal */ ,
model);
break;
-
- case insn_record: /* instruction records */
+
+ case insn_record: /* instruction records */
{
insn_entry *new_insn;
char *format;
/* parse the instruction */
if (record->nr_fields < nr_insn_fields)
- error (record->line, "Incorrect nr of fields for insn record\n");
+ error (record->line,
+ "Incorrect nr of fields for insn record\n");
new_insn = ZALLOC (insn_entry);
new_insn->line = record->line;
filter_parse (&new_insn->flags,
record->field[record_filter_flags_field]);
/* save the format field. Can't parse it until after the
- filter-out checks. Could be filtered out because the
- format is invalid */
+ filter-out checks. Could be filtered out because the
+ format is invalid */
format = record->field[insn_word_field];
new_insn->format_name = record->field[insn_format_name_field];
if (options.format_name_filter != NULL
&& !filter_is_member (options.format_name_filter,
new_insn->format_name))
- error (new_insn->line, "Unreconized instruction format name `%s'\n",
+ error (new_insn->line,
+ "Unreconized instruction format name `%s'\n",
new_insn->format_name);
filter_parse (&new_insn->options,
record->field[insn_options_field]);
@@ -1210,12 +1209,14 @@ load_insn_table (char *file_name,
record = table_read (file);
/* Parse any model/assember records */
new_insn->nr_models = model->nr_models;
- new_insn->model = NZALLOC (insn_model_entry*, model->nr_models + 1);
+ new_insn->model =
+ NZALLOC (insn_model_entry *, model->nr_models + 1);
while (record != NULL)
{
if (record_prefix_is (record, '*', nr_insn_model_fields))
parse_insn_model_record (file, record, new_insn, model);
- else if (record_prefix_is (record, '"', nr_insn_mnemonic_fields))
+ else
+ if (record_prefix_is (record, '"', nr_insn_mnemonic_fields))
parse_insn_mnemonic_record (file, record, new_insn);
else
break;
@@ -1244,8 +1245,8 @@ load_insn_table (char *file_name,
new_insn->processors))
{
/* only discard an instruction based in the processor
- model when both the instruction and the options are
- nonempty */
+ model when both the instruction and the options are
+ nonempty */
if (options.warn.discard)
notify (new_insn->line,
"Discarding instruction %s (processor-model)\n",
@@ -1262,7 +1263,7 @@ load_insn_table (char *file_name,
last = &(*last)->next;
*last = new_insn;
/* update global isa counters */
- isa->nr_insns ++;
+ isa->nr_insns++;
if (isa->max_nr_words < new_insn->nr_words)
isa->max_nr_words = new_insn->nr_words;
filter_add (&isa->flags, new_insn->flags);
@@ -1270,7 +1271,7 @@ load_insn_table (char *file_name,
}
break;
}
-
+
case define_record:
record = parse_macro_record (file, record);
break;
@@ -1287,8 +1288,7 @@ load_insn_table (char *file_name,
void
-print_insn_words (lf *file,
- insn_entry *insn)
+print_insn_words (lf *file, insn_entry * insn)
{
insn_word_entry *word = insn->words;
if (word != NULL)
@@ -1301,7 +1301,8 @@ print_insn_words (lf *file,
if (options.insn_specifying_widths)
lf_printf (file, "%d.", field->width);
else
- lf_printf (file, "%d.", i2target (options.hi_bit_nr, field->first));
+ lf_printf (file, "%d.",
+ i2target (options.hi_bit_nr, field->first));
switch (field->type)
{
case insn_field_invalid:
@@ -1332,14 +1333,13 @@ print_insn_words (lf *file,
}
}
}
+
-
void
function_entry_traverse (lf *file,
- function_entry *functions,
- function_entry_handler *handler,
- void *data)
+ function_entry * functions,
+ function_entry_handler * handler, void *data)
{
function_entry *function;
for (function = functions; function != NULL; function = function->next)
@@ -1351,8 +1351,7 @@ function_entry_traverse (lf *file,
void
insn_table_traverse_insn (lf *file,
insn_table *isa,
- insn_entry_handler *handler,
- void *data)
+ insn_entry_handler * handler, void *data)
{
insn_entry *insn;
for (insn = isa->insns; insn != NULL; insn = insn->next)
@@ -1360,13 +1359,11 @@ insn_table_traverse_insn (lf *file,
handler (file, isa, insn, data);
}
}
-
+
static void
dump_function_entry (lf *file,
- char *prefix,
- function_entry *entry,
- char *suffix)
+ char *prefix, function_entry * entry, char *suffix)
{
lf_printf (file, "%s(function_entry *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -1385,9 +1382,7 @@ dump_function_entry (lf *file,
static void
dump_function_entries (lf *file,
- char *prefix,
- function_entry *entry,
- char *suffix)
+ char *prefix, function_entry * entry, char *suffix)
{
lf_printf (file, "%s", prefix);
lf_indent (file, +1);
@@ -1405,26 +1400,27 @@ cache_entry_type_to_str (cache_entry_type type)
{
switch (type)
{
- case scratch_value: return "scratch";
- case cache_value: return "cache";
- case compute_value: return "compute";
+ case scratch_value:
+ return "scratch";
+ case cache_value:
+ return "cache";
+ case compute_value:
+ return "compute";
}
ERROR ("Bad switch");
return 0;
}
static void
-dump_cache_entry (lf *file,
- char *prefix,
- cache_entry *entry,
- char *suffix)
+dump_cache_entry (lf *file, char *prefix, cache_entry *entry, char *suffix)
{
lf_printf (file, "%s(cache_entry *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
{
dump_line_ref (file, "\n(line ", entry->line, ")");
dump_filter (file, "\n(flags ", entry->flags, ")");
- lf_printf (file, "\n(entry_type \"%s\")", cache_entry_type_to_str (entry->entry_type));
+ lf_printf (file, "\n(entry_type \"%s\")",
+ cache_entry_type_to_str (entry->entry_type));
lf_printf (file, "\n(name \"%s\")", entry->name);
dump_filter (file, "\n(original_fields ", entry->original_fields, ")");
lf_printf (file, "\n(type \"%s\")", entry->type);
@@ -1435,10 +1431,7 @@ dump_cache_entry (lf *file,
}
void
-dump_cache_entries (lf *file,
- char *prefix,
- cache_entry *entry,
- char *suffix)
+dump_cache_entries (lf *file, char *prefix, cache_entry *entry, char *suffix)
{
lf_printf (file, "%s", prefix);
lf_indent (file, +1);
@@ -1452,10 +1445,7 @@ dump_cache_entries (lf *file,
}
static void
-dump_model_data (lf *file,
- char *prefix,
- model_data *entry,
- char *suffix)
+dump_model_data (lf *file, char *prefix, model_data *entry, char *suffix)
{
lf_printf (file, "%s(model_data *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -1472,10 +1462,7 @@ dump_model_data (lf *file,
}
static void
-dump_model_datas (lf *file,
- char *prefix,
- model_data *entry,
- char *suffix)
+dump_model_datas (lf *file, char *prefix, model_data *entry, char *suffix)
{
lf_printf (file, "%s", prefix);
lf_indent (file, +1);
@@ -1489,10 +1476,7 @@ dump_model_datas (lf *file,
}
static void
-dump_model_entry (lf *file,
- char *prefix,
- model_entry *entry,
- char *suffix)
+dump_model_entry (lf *file, char *prefix, model_entry *entry, char *suffix)
{
lf_printf (file, "%s(model_entry *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -1510,10 +1494,7 @@ dump_model_entry (lf *file,
}
static void
-dump_model_entries (lf *file,
- char *prefix,
- model_entry *entry,
- char *suffix)
+dump_model_entries (lf *file, char *prefix, model_entry *entry, char *suffix)
{
lf_printf (file, "%s", prefix);
lf_indent (file, +1);
@@ -1528,10 +1509,7 @@ dump_model_entries (lf *file,
static void
-dump_model_table (lf *file,
- char *prefix,
- model_table *entry,
- char *suffix)
+dump_model_table (lf *file, char *prefix, model_table *entry, char *suffix)
{
lf_printf (file, "%s(model_table *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -1556,11 +1534,17 @@ insn_field_type_to_str (insn_field_type type)
{
switch (type)
{
- case insn_field_invalid: ASSERT (0); return "(invalid)";
- case insn_field_int: return "int";
- case insn_field_reserved: return "reserved";
- case insn_field_wild: return "wild";
- case insn_field_string: return "string";
+ case insn_field_invalid:
+ ASSERT (0);
+ return "(invalid)";
+ case insn_field_int:
+ return "int";
+ case insn_field_reserved:
+ return "reserved";
+ case insn_field_wild:
+ return "wild";
+ case insn_field_string:
+ return "string";
}
ERROR ("bad switch");
return 0;
@@ -1568,9 +1552,7 @@ insn_field_type_to_str (insn_field_type type)
void
dump_insn_field (lf *file,
- char *prefix,
- insn_field_entry *field,
- char *suffix)
+ char *prefix, insn_field_entry *field, char *suffix)
{
char *sep = " ";
lf_printf (file, "%s(insn_field_entry *) 0x%lx", prefix, (long) field);
@@ -1580,7 +1562,8 @@ dump_insn_field (lf *file,
lf_printf (file, "%s(first %d)", sep, field->first);
lf_printf (file, "%s(last %d)", sep, field->last);
lf_printf (file, "%s(width %d)", sep, field->width);
- lf_printf (file, "%s(type %s)", sep, insn_field_type_to_str (field->type));
+ lf_printf (file, "%s(type %s)", sep,
+ insn_field_type_to_str (field->type));
switch (field->type)
{
case insn_field_invalid:
@@ -1608,9 +1591,7 @@ dump_insn_field (lf *file,
void
dump_insn_word_entry (lf *file,
- char *prefix,
- insn_word_entry *word,
- char *suffix)
+ char *prefix, insn_word_entry *word, char *suffix)
{
lf_printf (file, "%s(insn_word_entry *) 0x%lx", prefix, (long) word);
if (word != NULL)
@@ -1623,7 +1604,8 @@ dump_insn_word_entry (lf *file,
lf_printf (file, "\n(bit");
for (i = 0; i < options.insn_bit_size; i++)
lf_printf (file, "\n ((value %d) (mask %d) (field 0x%lx))",
- word->bit[i]->value, word->bit[i]->mask, (long) word->bit[i]->field);
+ word->bit[i]->value, word->bit[i]->mask,
+ (long) word->bit[i]->field);
lf_printf (file, ")");
for (field = word->first; field != NULL; field = field->next)
dump_insn_field (file, "\n(", field, ")");
@@ -1636,9 +1618,7 @@ dump_insn_word_entry (lf *file,
static void
dump_insn_word_entries (lf *file,
- char *prefix,
- insn_word_entry *word,
- char *suffix)
+ char *prefix, insn_word_entry *word, char *suffix)
{
lf_printf (file, "%s", prefix);
while (word != NULL)
@@ -1651,9 +1631,7 @@ dump_insn_word_entries (lf *file,
static void
dump_insn_model_entry (lf *file,
- char *prefix,
- insn_model_entry *model,
- char *suffix)
+ char *prefix, insn_model_entry *model, char *suffix)
{
lf_printf (file, "%s(insn_model_entry *) 0x%lx", prefix, (long) model);
if (model != NULL)
@@ -1673,9 +1651,7 @@ dump_insn_model_entry (lf *file,
static void
dump_insn_model_entries (lf *file,
- char *prefix,
- insn_model_entry *model,
- char *suffix)
+ char *prefix, insn_model_entry *model, char *suffix)
{
lf_printf (file, "%s", prefix);
while (model != NULL)
@@ -1690,10 +1666,10 @@ dump_insn_model_entries (lf *file,
static void
dump_insn_mnemonic_entry (lf *file,
char *prefix,
- insn_mnemonic_entry *mnemonic,
- char *suffix)
+ insn_mnemonic_entry *mnemonic, char *suffix)
{
- lf_printf (file, "%s(insn_mnemonic_entry *) 0x%lx", prefix, (long) mnemonic);
+ lf_printf (file, "%s(insn_mnemonic_entry *) 0x%lx", prefix,
+ (long) mnemonic);
if (mnemonic != NULL)
{
lf_indent (file, +1);
@@ -1712,8 +1688,7 @@ dump_insn_mnemonic_entry (lf *file,
static void
dump_insn_mnemonic_entries (lf *file,
char *prefix,
- insn_mnemonic_entry *mnemonic,
- char *suffix)
+ insn_mnemonic_entry *mnemonic, char *suffix)
{
lf_printf (file, "%s", prefix);
while (mnemonic != NULL)
@@ -1725,10 +1700,7 @@ dump_insn_mnemonic_entries (lf *file,
}
void
-dump_insn_entry (lf *file,
- char *prefix,
- insn_entry *entry,
- char *suffix)
+dump_insn_entry (lf *file, char *prefix, insn_entry * entry, char *suffix)
{
lf_printf (file, "%s(insn_entry *) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -1754,19 +1726,17 @@ dump_insn_entry (lf *file,
lf_printf (file, " 0x%lx", (long) entry->model[i]);
lf_printf (file, ")");
dump_filter (file, "\n(processors ", entry->processors, ")");
- dump_insn_mnemonic_entries (file, "\n(mnemonics ", entry->mnemonics, ")");
+ dump_insn_mnemonic_entries (file, "\n(mnemonics ", entry->mnemonics,
+ ")");
dump_table_entry (file, "\n(code ", entry->code, ")");
lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
lf_indent (file, -1);
- }
+ }
lf_printf (file, "%s", suffix);
}
static void
-dump_insn_entries (lf *file,
- char *prefix,
- insn_entry *entry,
- char *suffix)
+dump_insn_entries (lf *file, char *prefix, insn_entry * entry, char *suffix)
{
lf_printf (file, "%s", prefix);
lf_indent (file, +1);
@@ -1782,10 +1752,7 @@ dump_insn_entries (lf *file,
void
-dump_insn_table (lf *file,
- char *prefix,
- insn_table *isa,
- char *suffix)
+dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix)
{
lf_printf (file, "%s(insn_table *) 0x%lx", prefix, (long) isa);
if (isa != NULL)
diff --git a/sim/igen/ld-insn.h b/sim/igen/ld-insn.h
index a8dd456..08a6bd0 100644
--- a/sim/igen/ld-insn.h
+++ b/sim/igen/ld-insn.h
@@ -38,7 +38,8 @@ typedef unsigned64 insn_uint;
*/
-enum {
+enum
+{
record_type_field = 1,
old_record_type_field = 2,
record_filter_flags_field = 2,
@@ -60,7 +61,8 @@ enum {
*/
-enum {
+enum
+{
include_filename_field = 4,
nr_include_fields,
};
@@ -99,10 +101,11 @@ enum {
;
- These update the global options structure. */
+ These update the global options structure. */
-enum {
+enum
+{
option_name_field = 4,
option_value_field,
nr_option_fields,
@@ -129,7 +132,8 @@ enum {
*/
-enum {
+enum
+{
macro_name_field = 4,
macro_args_field,
macro_expr_field,
@@ -177,29 +181,33 @@ enum {
*/
-enum {
+enum
+{
function_typedef_field = 4,
function_name_field,
function_param_field,
nr_function_fields,
};
-enum {
+enum
+{
function_model_name_field = 0,
nr_function_model_fields = 1,
};
-enum {
+enum
+{
old_function_typedef_field = 0,
old_function_type_field = 2,
old_function_name_field = 4,
old_function_param_field = 5,
- nr_old_function_fields = 5, /* parameter-list is optional */
+ nr_old_function_fields = 5, /* parameter-list is optional */
};
typedef struct _function_entry function_entry;
-struct _function_entry {
+struct _function_entry
+{
line_ref *line;
filter *flags;
filter *models;
@@ -213,15 +221,11 @@ struct _function_entry {
typedef void function_entry_handler
-(lf *file,
- function_entry *function,
- void *data);
+ (lf *file, function_entry * function, void *data);
extern void function_entry_traverse
-(lf *file,
- function_entry *functions,
- function_entry_handler *handler,
- void *data);
+ (lf *file,
+ function_entry * functions, function_entry_handler * handler, void *data);
/* cache-macro:
@@ -258,7 +262,8 @@ extern void function_entry_traverse
*/
-enum {
+enum
+{
cache_typedef_field = 4,
cache_name_field,
cache_original_fields_field,
@@ -266,14 +271,17 @@ enum {
nr_cache_fields,
};
-typedef enum {
+typedef enum
+{
scratch_value,
cache_value,
compute_value,
-} cache_entry_type;
+}
+cache_entry_type;
typedef struct _cache_entry cache_entry;
-struct _cache_entry {
+struct _cache_entry
+{
line_ref *line;
filter *flags;
filter *models;
@@ -332,7 +340,8 @@ struct _cache_entry {
*/
-enum {
+enum
+{
nr_model_macro_fields = 4,
nr_model_data_fields = 4,
nr_model_static_fields = nr_function_fields,
@@ -341,7 +350,8 @@ enum {
};
typedef struct _model_data model_data;
-struct _model_data {
+struct _model_data
+{
line_ref *line;
filter *flags;
table_entry *entry;
@@ -349,7 +359,8 @@ struct _model_data {
model_data *next;
};
-enum {
+enum
+{
model_name_field = 4,
model_full_name_field,
model_unit_data_field,
@@ -357,7 +368,8 @@ enum {
};
typedef struct _model_entry model_entry;
-struct _model_entry {
+struct _model_entry
+{
line_ref *line;
filter *flags;
char *name;
@@ -368,7 +380,8 @@ struct _model_entry {
typedef struct _model_table model_table;
-struct _model_table {
+struct _model_table
+{
filter *processors;
int nr_models;
model_entry *models;
@@ -410,16 +423,21 @@ struct _model_table {
*/
-typedef enum _insn_field_cond_type {
+typedef enum _insn_field_cond_type
+{
insn_field_cond_value,
insn_field_cond_field,
-} insn_field_cond_type;
-typedef enum _insn_field_cond_test {
+}
+insn_field_cond_type;
+typedef enum _insn_field_cond_test
+{
insn_field_cond_eq,
insn_field_cond_ne,
-} insn_field_cond_test;
+}
+insn_field_cond_test;
typedef struct _insn_field_cond insn_field_cond;
-struct _insn_field_cond {
+struct _insn_field_cond
+{
insn_field_cond_type type;
insn_field_cond_test test;
insn_uint value;
@@ -429,16 +447,19 @@ struct _insn_field_cond {
};
-typedef enum _insn_field_type {
+typedef enum _insn_field_type
+{
insn_field_invalid,
insn_field_int,
insn_field_reserved,
insn_field_wild,
insn_field_string,
-} insn_field_type;
+}
+insn_field_type;
typedef struct _insn_field_entry insn_field_entry;
-struct _insn_field_entry {
+struct _insn_field_entry
+{
int first;
int last;
int width;
@@ -453,7 +474,8 @@ struct _insn_field_entry {
};
typedef struct _insn_bit_entry insn_bit_entry;
-struct _insn_bit_entry {
+struct _insn_bit_entry
+{
int value;
int mask;
insn_field_entry *field;
@@ -462,10 +484,11 @@ struct _insn_bit_entry {
-typedef struct _insn_entry insn_entry; /* forward */
+typedef struct _insn_entry insn_entry; /* forward */
typedef struct _insn_word_entry insn_word_entry;
-struct _insn_word_entry {
+struct _insn_word_entry
+{
/* list of sub-fields making up the instruction. bit provides
faster access to the field data for bit N. */
insn_field_entry *first;
@@ -499,14 +522,16 @@ struct _insn_word_entry {
*/
-enum {
+enum
+{
insn_model_name_field = 0,
insn_model_unit_data_field = 1,
nr_insn_model_fields = 1,
};
typedef struct _insn_model_entry insn_model_entry;
-struct _insn_model_entry {
+struct _insn_model_entry
+{
line_ref *line;
insn_entry *insn;
filter *names;
@@ -554,14 +579,16 @@ struct _insn_model_entry {
*/
-enum {
+enum
+{
insn_mnemonic_format_field = 0,
insn_mnemonic_condition_field = 1,
nr_insn_mnemonic_fields = 1,
};
typedef struct _insn_mnemonic_entry insn_mnemonic_entry;
-struct _insn_mnemonic_entry {
+struct _insn_mnemonic_entry
+{
line_ref *line;
insn_entry *insn;
char *format;
@@ -586,7 +613,8 @@ struct _insn_mnemonic_entry {
*/
-enum {
+enum
+{
insn_word_field = 0,
insn_format_name_field = 1,
insn_filter_flags_field = 2,
@@ -597,9 +625,10 @@ enum {
/* typedef struct _insn_entry insn_entry; */
-struct _insn_entry {
+struct _insn_entry
+{
line_ref *line;
- filter *flags; /* filtered by options.filters */
+ filter *flags; /* filtered by options.filters */
char *format_name;
filter *options;
char *name;
@@ -630,7 +659,8 @@ struct _insn_entry {
*/
typedef struct _insn_table insn_table;
-struct _insn_table {
+struct _insn_table
+{
cache_entry *caches;
int max_nr_words;
int nr_insns;
@@ -642,65 +672,37 @@ struct _insn_table {
filter *flags;
};
-extern insn_table *load_insn_table
-(char *file_name,
- cache_entry *cache);
+extern insn_table *load_insn_table (char *file_name, cache_entry *cache);
typedef void insn_entry_handler
-(lf *file,
- insn_table *isa,
- insn_entry *insn,
- void *data);
+ (lf *file, insn_table *isa, insn_entry * insn, void *data);
extern void insn_table_traverse_insn
-(lf *file,
- insn_table *isa,
- insn_entry_handler *handler,
- void *data);
+ (lf *file, insn_table *isa, insn_entry_handler * handler, void *data);
/* Printing */
-extern void print_insn_words
-(lf *file,
- insn_entry *insn);
+extern void print_insn_words (lf *file, insn_entry * insn);
/* Debugging */
void
-dump_insn_field
-(lf *file,
- char *prefix,
- insn_field_entry *field,
- char *suffix);
+ dump_insn_field
+ (lf *file, char *prefix, insn_field_entry *field, char *suffix);
void
-dump_insn_word_entry
-(lf *file,
- char *prefix,
- insn_word_entry *word,
- char *suffix);
+ dump_insn_word_entry
+ (lf *file, char *prefix, insn_word_entry *word, char *suffix);
void
-dump_insn_entry
-(lf *file,
- char *prefix,
- insn_entry *insn,
- char *suffix);
+ dump_insn_entry (lf *file, char *prefix, insn_entry * insn, char *suffix);
void
-dump_cache_entries
-(lf *file,
- char *prefix,
- cache_entry *entry,
- char *suffix);
+ dump_cache_entries
+ (lf *file, char *prefix, cache_entry *entry, char *suffix);
-void
-dump_insn_table
-(lf *file,
- char *prefix,
- insn_table *isa,
- char *suffix);
+void dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix);
diff --git a/sim/igen/lf.c b/sim/igen/lf.c
index 5364f41..42985f2 100644
--- a/sim/igen/lf.c
+++ b/sim/igen/lf.c
@@ -43,9 +43,10 @@
#endif
#endif
-struct _lf {
+struct _lf
+{
FILE *stream;
- int line_nr; /* nr complete lines written, curr line is line_nr+1 */
+ int line_nr; /* nr complete lines written, curr line is line_nr+1 */
int indent;
int line_blank;
const char *name;
@@ -59,70 +60,73 @@ lf *
lf_open (char *name,
char *real_name,
lf_file_references references,
- lf_file_type type,
- const char *program)
+ lf_file_type type, const char *program)
{
/* create a file object */
- lf *new_lf = ZALLOC(lf);
+ lf *new_lf = ZALLOC (lf);
ASSERT (new_lf != NULL);
new_lf->references = references;
new_lf->type = type;
new_lf->name = (real_name == NULL ? name : real_name);
new_lf->program = program;
/* attach to stdout if pipe */
- if (!strcmp(name, "-")) {
- new_lf->stream = stdout;
- }
- else {
- /* create a new file */
- new_lf->stream = fopen(name, "w");
- if (new_lf->stream == NULL) {
- perror(name);
- exit(1);
+ if (!strcmp (name, "-"))
+ {
+ new_lf->stream = stdout;
+ }
+ else
+ {
+ /* create a new file */
+ new_lf->stream = fopen (name, "w");
+ if (new_lf->stream == NULL)
+ {
+ perror (name);
+ exit (1);
+ }
}
- }
return new_lf;
}
void
-lf_close(lf *file)
+lf_close (lf *file)
{
- if (file->stream != stdout) {
- if (fclose(file->stream)) {
- perror("lf_close.fclose");
- exit(1);
+ if (file->stream != stdout)
+ {
+ if (fclose (file->stream))
+ {
+ perror ("lf_close.fclose");
+ exit (1);
+ }
+ free (file);
}
- free(file);
- }
}
int
-lf_putchr(lf *file,
- const char chr)
+lf_putchr (lf *file, const char chr)
{
int nr = 0;
- if (chr == '\n') {
- file->line_nr += 1;
- file->line_blank = 1;
- }
- else if (file->line_blank) {
- int pad;
- for (pad = file->indent; pad > 0; pad--)
- putc(' ', file->stream);
- nr += file->indent;
- file->line_blank = 0;
- }
- putc(chr, file->stream);
+ if (chr == '\n')
+ {
+ file->line_nr += 1;
+ file->line_blank = 1;
+ }
+ else if (file->line_blank)
+ {
+ int pad;
+ for (pad = file->indent; pad > 0; pad--)
+ putc (' ', file->stream);
+ nr += file->indent;
+ file->line_blank = 0;
+ }
+ putc (chr, file->stream);
nr += 1;
return nr;
}
int
-lf_write (lf *file,
- const char *string,
- int strlen_string)
+lf_write (lf *file, const char *string, int strlen_string)
{
int nr = 0;
int i;
@@ -133,63 +137,63 @@ lf_write (lf *file,
void
-lf_indent_suppress(lf *file)
+lf_indent_suppress (lf *file)
{
file->line_blank = 0;
}
int
-lf_putstr(lf *file,
- const char *string)
+lf_putstr (lf *file, const char *string)
{
int nr = 0;
const char *chp;
- if (string != NULL) {
- for (chp = string; *chp != '\0'; chp++) {
- nr += lf_putchr(file, *chp);
+ if (string != NULL)
+ {
+ for (chp = string; *chp != '\0'; chp++)
+ {
+ nr += lf_putchr (file, *chp);
+ }
}
- }
return nr;
}
static int
-do_lf_putunsigned(lf *file,
- unsigned u)
+do_lf_putunsigned (lf *file, unsigned u)
{
int nr = 0;
- if (u > 0) {
- nr += do_lf_putunsigned(file, u / 10);
- nr += lf_putchr(file, (u % 10) + '0');
- }
+ if (u > 0)
+ {
+ nr += do_lf_putunsigned (file, u / 10);
+ nr += lf_putchr (file, (u % 10) + '0');
+ }
return nr;
}
int
-lf_putint(lf *file,
- int decimal)
+lf_putint (lf *file, int decimal)
{
int nr = 0;
if (decimal == 0)
- nr += lf_putchr(file, '0');
- else if (decimal < 0) {
- nr += lf_putchr(file, '-');
- nr += do_lf_putunsigned(file, -decimal);
- }
- else if (decimal > 0) {
- nr += do_lf_putunsigned(file, decimal);
- }
+ nr += lf_putchr (file, '0');
+ else if (decimal < 0)
+ {
+ nr += lf_putchr (file, '-');
+ nr += do_lf_putunsigned (file, -decimal);
+ }
+ else if (decimal > 0)
+ {
+ nr += do_lf_putunsigned (file, decimal);
+ }
else
- ASSERT(0);
+ ASSERT (0);
return nr;
}
int
-lf_printf (lf *file,
- const char *fmt,
- ...)
+lf_printf (lf *file, const char *fmt, ...)
{
int nr = 0;
char buf[1024];
@@ -200,28 +204,25 @@ lf_printf (lf *file,
/* FIXME - this is really stuffed but so is vsprintf() on a sun! */
ASSERT (strlen (buf) < sizeof (buf));
nr += lf_putstr (file, buf);
- va_end(ap);
+ va_end (ap);
return nr;
}
int
-lf_print__line_ref (lf *file,
- line_ref *line)
+lf_print__line_ref (lf *file, line_ref *line)
{
return lf_print__external_ref (file, line->line_nr, line->file_name);
}
int
-lf_print__external_ref (lf *file,
- int line_nr,
- const char *file_name)
+lf_print__external_ref (lf *file, int line_nr, const char *file_name)
{
int nr = 0;
switch (file->references)
{
case lf_include_references:
- lf_indent_suppress(file);
+ lf_indent_suppress (file);
nr += lf_putstr (file, "#line ");
nr += lf_putint (file, line_nr);
nr += lf_putstr (file, " \"");
@@ -243,7 +244,7 @@ int
lf_print__internal_ref (lf *file)
{
int nr = 0;
- nr += lf_print__external_ref (file, file->line_nr+2, file->name);
+ nr += lf_print__external_ref (file, file->line_nr + 2, file->name);
/* line_nr == last_line, want to number from next */
return nr;
}
@@ -259,10 +260,11 @@ int
lf_print__gnu_copyleft (lf *file)
{
int nr = 0;
- switch (file->type) {
- case lf_is_c:
- case lf_is_h:
- nr += lf_printf(file, "\
+ switch (file->type)
+ {
+ case lf_is_c:
+ case lf_is_h:
+ nr += lf_printf (file, "\
/* This file is part of GDB.\n\
\n\
Copyright 2002 Free Software Foundation, Inc.\n\
@@ -285,110 +287,115 @@ lf_print__gnu_copyleft (lf *file)
--\n\
\n\
This file was generated by the program %s */\n\
-", filter_filename(file->program));
- break;
- default:
- ASSERT(0);
- break;
- }
+", filter_filename (file->program));
+ break;
+ default:
+ ASSERT (0);
+ break;
+ }
return nr;
}
int
-lf_putbin(lf *file, int decimal, int width)
+lf_putbin (lf *file, int decimal, int width)
{
int nr = 0;
int bit;
- ASSERT(width > 0);
- for (bit = 1 << (width-1); bit != 0; bit >>= 1) {
- if (decimal & bit)
- nr += lf_putchr(file, '1');
- else
- nr += lf_putchr(file, '0');
- }
+ ASSERT (width > 0);
+ for (bit = 1 << (width - 1); bit != 0; bit >>= 1)
+ {
+ if (decimal & bit)
+ nr += lf_putchr (file, '1');
+ else
+ nr += lf_putchr (file, '0');
+ }
return nr;
}
int
-lf_print__this_file_is_empty(lf *file,
- const char *reason)
+lf_print__this_file_is_empty (lf *file, const char *reason)
{
int nr = 0;
- switch (file->type) {
- case lf_is_c:
- case lf_is_h:
- nr += lf_printf (file,
- "/* This generated file (%s) is intentionally left blank",
- file->name);
- if (reason != NULL)
- nr += lf_printf (file, " - %s", reason);
- nr += lf_printf (file, " */\n");
- break;
- default:
- ERROR ("Bad switch");
- }
+ switch (file->type)
+ {
+ case lf_is_c:
+ case lf_is_h:
+ nr += lf_printf (file,
+ "/* This generated file (%s) is intentionally left blank",
+ file->name);
+ if (reason != NULL)
+ nr += lf_printf (file, " - %s", reason);
+ nr += lf_printf (file, " */\n");
+ break;
+ default:
+ ERROR ("Bad switch");
+ }
return nr;
}
int
-lf_print__ucase_filename(lf *file)
+lf_print__ucase_filename (lf *file)
{
int nr = 0;
const char *chp = file->name;
- while (*chp != '\0') {
- char ch = *chp;
- if (islower(ch)) {
- nr += lf_putchr(file, toupper(ch));
+ while (*chp != '\0')
+ {
+ char ch = *chp;
+ if (islower (ch))
+ {
+ nr += lf_putchr (file, toupper (ch));
+ }
+ else if (ch == '.')
+ nr += lf_putchr (file, '_');
+ else
+ nr += lf_putchr (file, ch);
+ chp++;
}
- else if (ch == '.')
- nr += lf_putchr(file, '_');
- else
- nr += lf_putchr(file, ch);
- chp++;
- }
return nr;
}
int
-lf_print__file_start(lf *file)
+lf_print__file_start (lf *file)
{
int nr = 0;
- switch (file->type) {
- case lf_is_h:
- case lf_is_c:
- nr += lf_print__gnu_copyleft(file);
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "#ifndef ");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "#define ");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "\n");
- break;
- default:
- ASSERT(0);
- }
+ switch (file->type)
+ {
+ case lf_is_h:
+ case lf_is_c:
+ nr += lf_print__gnu_copyleft (file);
+ nr += lf_printf (file, "\n");
+ nr += lf_printf (file, "#ifndef ");
+ nr += lf_print__ucase_filename (file);
+ nr += lf_printf (file, "\n");
+ nr += lf_printf (file, "#define ");
+ nr += lf_print__ucase_filename (file);
+ nr += lf_printf (file, "\n");
+ nr += lf_printf (file, "\n");
+ break;
+ default:
+ ASSERT (0);
+ }
return nr;
}
int
-lf_print__file_finish(lf *file)
+lf_print__file_finish (lf *file)
{
int nr = 0;
- switch (file->type) {
- case lf_is_h:
- case lf_is_c:
- nr += lf_printf(file, "\n");
- nr += lf_printf(file, "#endif /* _");
- nr += lf_print__ucase_filename(file);
- nr += lf_printf(file, "_*/\n");
- break;
- default:
- ASSERT(0);
- }
+ switch (file->type)
+ {
+ case lf_is_h:
+ case lf_is_c:
+ nr += lf_printf (file, "\n");
+ nr += lf_printf (file, "#endif /* _");
+ nr += lf_print__ucase_filename (file);
+ nr += lf_printf (file, "_*/\n");
+ break;
+ default:
+ ASSERT (0);
+ }
return nr;
}
@@ -396,8 +403,7 @@ lf_print__file_finish(lf *file)
int
lf_print__function_type (lf *file,
const char *type,
- const char *prefix,
- const char *trailing_space)
+ const char *prefix, const char *trailing_space)
{
int nr = 0;
nr += lf_printf (file, "%s\\\n(%s)", prefix, type);
@@ -408,7 +414,7 @@ lf_print__function_type (lf *file,
int
lf_print__function_type_function (lf *file,
- print_function *print_type,
+ print_function * print_type,
const char *prefix,
const char *trailing_space)
{
@@ -420,4 +426,3 @@ lf_print__function_type_function (lf *file,
nr += lf_printf (file, "%s", trailing_space);
return nr;
}
-
diff --git a/sim/igen/lf.h b/sim/igen/lf.h
index ff79558..7eb4ee4 100644
--- a/sim/igen/lf.h
+++ b/sim/igen/lf.h
@@ -27,17 +27,21 @@
typedef struct _lf lf;
-typedef enum {
+typedef enum
+{
lf_is_h,
lf_is_c,
lf_is_text,
-} lf_file_type;
+}
+lf_file_type;
-typedef enum {
+typedef enum
+{
lf_include_references,
lf_omit_references,
-} lf_file_references;
+}
+lf_file_references;
/* Open the file NAME for writing ("-" for stdout). Use REAL_NAME
@@ -47,44 +51,28 @@ typedef enum {
the print messages below. */
extern lf *lf_open
-(char *name,
- char *real_name,
- lf_file_references file_references,
- lf_file_type type,
- const char *program);
+ (char *name,
+ char *real_name,
+ lf_file_references file_references,
+ lf_file_type type, const char *program);
-extern void lf_close
-(lf *file);
+extern void lf_close (lf *file);
/* Basic output functions */
-extern int lf_write
-(lf *file,
- const char *string,
- int len);
+extern int lf_write (lf *file, const char *string, int len);
-extern int lf_putchr
-(lf *file,
- const char ch);
+extern int lf_putchr (lf *file, const char ch);
-extern int lf_putstr
-(lf *file,
- const char *string);
+extern int lf_putstr (lf *file, const char *string);
-extern int lf_putint
-(lf *file,
- int decimal);
+extern int lf_putint (lf *file, int decimal);
-extern int lf_putbin
-(lf *file,
- int decimal,
- int width);
+extern int lf_putbin (lf *file, int decimal, int width);
extern int lf_printf
-(lf *file,
- const char *fmt,
- ...) __attribute__((format(printf, 2, 3)));
+ (lf *file, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
/* Indentation control.
@@ -92,56 +80,38 @@ extern int lf_printf
lf_indent_suppress suppresses indentation on the next line (current
line if that has not yet been started) */
-extern void lf_indent_suppress
-(lf *file);
+extern void lf_indent_suppress (lf *file);
-extern void lf_indent
-(lf *file,
- int delta);
+extern void lf_indent (lf *file, int delta);
/* Print generic text: */
-extern int lf_print__gnu_copyleft
-(lf *file);
+extern int lf_print__gnu_copyleft (lf *file);
-extern int lf_print__file_start
-(lf *file);
+extern int lf_print__file_start (lf *file);
-extern int lf_print__this_file_is_empty
-(lf *file,
- const char *reason);
+extern int lf_print__this_file_is_empty (lf *file, const char *reason);
-extern int lf_print__file_finish
-(lf *file);
+extern int lf_print__file_finish (lf *file);
-extern int lf_print__internal_ref
-(lf *file);
+extern int lf_print__internal_ref (lf *file);
extern int lf_print__external_ref
-(lf *file,
- int line_nr,
- const char *file_name);
+ (lf *file, int line_nr, const char *file_name);
-extern int lf_print__line_ref
-(lf *file,
- line_ref *line);
+extern int lf_print__line_ref (lf *file, line_ref *line);
-extern int lf_print__ucase_filename
-(lf *file);
+extern int lf_print__ucase_filename (lf *file);
extern int lf_print__function_type
-(lf *file,
- const char *type,
- const char *prefix,
- const char *trailing_space);
+ (lf *file,
+ const char *type, const char *prefix, const char *trailing_space);
-typedef int print_function(lf *file);
+typedef int print_function (lf *file);
extern int lf_print__function_type_function
-(lf *file,
- print_function *print_type,
- const char *prefix,
- const char *trailing_space);
-
+ (lf *file,
+ print_function * print_type,
+ const char *prefix, const char *trailing_space);
diff --git a/sim/igen/misc.c b/sim/igen/misc.c
index 6283482..c538926 100644
--- a/sim/igen/misc.c
+++ b/sim/igen/misc.c
@@ -46,9 +46,7 @@
trailing '\n' */
void
-error (const line_ref *line,
- char *msg,
- ...)
+error (const line_ref *line, char *msg, ...)
{
va_list ap;
if (line != NULL)
@@ -60,9 +58,7 @@ error (const line_ref *line,
}
void
-warning (const line_ref *line,
- char *msg,
- ...)
+warning (const line_ref *line, char *msg, ...)
{
va_list ap;
if (line != NULL)
@@ -73,25 +69,23 @@ warning (const line_ref *line,
}
void
-notify (const line_ref *line,
- char *msg,
- ...)
+notify (const line_ref *line, char *msg, ...)
{
va_list ap;
if (line != NULL)
fprintf (stdout, "%s %d: info: ", line->file_name, line->line_nr);
- va_start(ap, msg);
+ va_start (ap, msg);
vfprintf (stdout, msg, ap);
- va_end(ap);
+ va_end (ap);
}
void *
-zalloc(long size)
+zalloc (long size)
{
- void *memory = malloc(size);
+ void *memory = malloc (size);
if (memory == NULL)
ERROR ("zalloc failed");
- memset(memory, 0, size);
+ memset (memory, 0, size);
return memory;
}
@@ -103,16 +97,14 @@ a2i (const char *a)
int base = 10;
unsigned long long num = 0;
int looping;
-
+
while (isspace (*a))
a++;
-
- if (strcmp (a, "true") == 0
- || strcmp (a, "TRUE") == 0)
+
+ if (strcmp (a, "true") == 0 || strcmp (a, "TRUE") == 0)
return 1;
- if (strcmp (a, "false") == 0
- || strcmp (a, "false") == 0)
+ if (strcmp (a, "false") == 0 || strcmp (a, "false") == 0)
return 0;
if (*a == '-')
@@ -120,7 +112,7 @@ a2i (const char *a)
neg = 1;
a++;
}
-
+
if (*a == '0')
{
if (a[1] == 'x' || a[1] == 'X')
@@ -136,18 +128,18 @@ a2i (const char *a)
else
base = 8;
}
-
+
looping = 1;
while (looping)
{
int ch = *a++;
-
+
switch (base)
{
default:
looping = 0;
break;
-
+
case 2:
if (ch >= '0' && ch <= '1')
{
@@ -158,7 +150,7 @@ a2i (const char *a)
looping = 0;
}
break;
-
+
case 10:
if (ch >= '0' && ch <= '9')
{
@@ -169,7 +161,7 @@ a2i (const char *a)
looping = 0;
}
break;
-
+
case 8:
if (ch >= '0' && ch <= '7')
{
@@ -180,7 +172,7 @@ a2i (const char *a)
looping = 0;
}
break;
-
+
case 16:
if (ch >= '0' && ch <= '9')
{
@@ -201,26 +193,24 @@ a2i (const char *a)
break;
}
}
-
+
if (neg)
- num = - num;
+ num = -num;
return num;
}
unsigned
-target_a2i(int ms_bit_nr,
- const char *a)
+target_a2i (int ms_bit_nr, const char *a)
{
if (ms_bit_nr)
- return (ms_bit_nr - a2i(a));
+ return (ms_bit_nr - a2i (a));
else
- return a2i(a);
+ return a2i (a);
}
unsigned
-i2target(int ms_bit_nr,
- unsigned bit)
+i2target (int ms_bit_nr, unsigned bit)
{
if (ms_bit_nr)
return ms_bit_nr - bit;
@@ -230,20 +220,19 @@ i2target(int ms_bit_nr,
int
-name2i (const char *names,
- const name_map *map)
+name2i (const char *names, const name_map * map)
{
const name_map *curr;
const char *name = names;
while (*name != '\0')
{
/* find our name */
- char *end = strchr(name, ',');
+ char *end = strchr (name, ',');
char *next;
unsigned len;
if (end == NULL)
{
- end = strchr(name, '\0');
+ end = strchr (name, '\0');
next = end;
}
else
@@ -274,8 +263,7 @@ name2i (const char *names,
}
const char *
-i2name (const int i,
- const name_map *map)
+i2name (const int i, const name_map * map)
{
while (map->name != NULL)
{
diff --git a/sim/igen/misc.h b/sim/igen/misc.h
index 7efb37c..54e6c9f 100644
--- a/sim/igen/misc.h
+++ b/sim/igen/misc.h
@@ -28,7 +28,8 @@
#include "config.h"
-enum {
+enum
+{
default_insn_bit_size = 32,
max_insn_bit_size = 64,
};
@@ -42,7 +43,7 @@ enum {
typedef long long signed64;
typedef unsigned long long unsigned64;
-#else /* _WIN32 */
+#else /* _WIN32 */
typedef __int64 signed64;
typedef unsigned __int64 unsigned64;
@@ -77,16 +78,14 @@ typedef unsigned __int64 unsigned64;
#include "filter_host.h"
typedef struct _line_ref line_ref;
-struct _line_ref {
+struct _line_ref
+{
const char *file_name;
int line_nr;
};
/* Error appends a new line, warning and notify do not */
-typedef void error_func
-(const line_ref *line,
- char *msg,
- ...);
+typedef void error_func (const line_ref *line, char *msg, ...);
extern error_func error;
extern error_func warning;
@@ -118,19 +117,13 @@ do { \
#define STRNDUP(STRING,LEN) (strncpy (zalloc ((LEN) + 1), (STRING), (LEN)))
#endif
-extern void *zalloc
-(long size);
+extern void *zalloc (long size);
-extern unsigned target_a2i
-(int ms_bit_nr,
- const char *a);
+extern unsigned target_a2i (int ms_bit_nr, const char *a);
-extern unsigned i2target
-(int ms_bit_nr,
- unsigned bit);
+extern unsigned i2target (int ms_bit_nr, unsigned bit);
-extern unsigned long long a2i
-(const char *a);
+extern unsigned long long a2i (const char *a);
/* Try looking for name in the map table (returning the corresponding
@@ -139,15 +132,13 @@ extern unsigned long long a2i
If the the sentinal (NAME == NULL) its value if >= zero is returned
as the default. */
-typedef struct _name_map {
+typedef struct _name_map
+{
const char *name;
int i;
-} name_map;
+}
+name_map;
-extern int name2i
-(const char *name,
- const name_map *map);
+extern int name2i (const char *name, const name_map * map);
-extern const char *i2name
-(const int i,
- const name_map *map);
+extern const char *i2name (const int i, const name_map * map);
diff --git a/sim/igen/table.c b/sim/igen/table.c
index 05e4ecc..29f7188 100644
--- a/sim/igen/table.c
+++ b/sim/igen/table.c
@@ -43,7 +43,8 @@
#endif
typedef struct _open_table open_table;
-struct _open_table {
+struct _open_table
+{
size_t size;
char *buffer;
char *pos;
@@ -52,13 +53,14 @@ struct _open_table {
open_table *parent;
table *root;
};
-struct _table {
+struct _table
+{
open_table *current;
};
static line_ref *
-current_line (open_table *file)
+current_line (open_table * file)
{
line_ref *entry = ZALLOC (line_ref);
*entry = file->pseudo_line;
@@ -66,8 +68,7 @@ current_line (open_table *file)
}
static table_entry *
-new_table_entry (open_table *file,
- table_entry_type type)
+new_table_entry (open_table * file, table_entry_type type)
{
table_entry *entry;
entry = ZALLOC (table_entry);
@@ -78,19 +79,16 @@ new_table_entry (open_table *file,
}
static void
-set_nr_table_entry_fields (table_entry *entry,
- int nr_fields)
+set_nr_table_entry_fields (table_entry *entry, int nr_fields)
{
- entry->field = NZALLOC (char*, nr_fields + 1);
+ entry->field = NZALLOC (char *, nr_fields + 1);
entry->nr_fields = nr_fields;
}
void
table_push (table *root,
- line_ref *line,
- table_include *includes,
- const char *file_name)
+ line_ref *line, table_include *includes, const char *file_name)
{
FILE *ff;
open_table *file;
@@ -115,7 +113,8 @@ table_push (table *root,
while (1)
{
/* save the file name */
- char *dup_name = NZALLOC (char, strlen (include->dir) + strlen (file_name) + 2);
+ char *dup_name =
+ NZALLOC (char, strlen (include->dir) + strlen (file_name) + 2);
if (dup_name == NULL)
{
perror (file_name);
@@ -143,7 +142,7 @@ table_push (table *root,
exit (1);
}
include = include->next;
- }
+ }
/* determine the size */
@@ -152,7 +151,7 @@ table_push (table *root,
fseek (ff, 0, SEEK_SET);
/* allocate this much memory */
- file->buffer = (char*) zalloc (file->size + 1);
+ file->buffer = (char *) zalloc (file->size + 1);
if (file->buffer == NULL)
{
perror (file_name);
@@ -161,15 +160,16 @@ table_push (table *root,
file->pos = file->buffer;
/* read it all in */
- if (fread (file->buffer, 1, file->size, ff) < file->size) {
- perror (file_name);
- exit (1);
- }
+ if (fread (file->buffer, 1, file->size, ff) < file->size)
+ {
+ perror (file_name);
+ exit (1);
+ }
file->buffer[file->size] = '\0';
/* set the initial line numbering */
- file->real_line.line_nr = 1; /* specifies current line */
- file->pseudo_line.line_nr = 1; /* specifies current line */
+ file->real_line.line_nr = 1; /* specifies current line */
+ file->pseudo_line.line_nr = 1; /* specifies current line */
/* done */
fclose (ff);
@@ -197,9 +197,7 @@ skip_spaces (char *chp)
{
while (1)
{
- if (*chp == '\0'
- || *chp == '\n'
- || !isspace (*chp))
+ if (*chp == '\0' || *chp == '\n' || !isspace (*chp))
return chp;
chp++;
}
@@ -211,8 +209,7 @@ back_spaces (char *start, char *chp)
{
while (1)
{
- if (chp <= start
- || !isspace (chp[-1]))
+ if (chp <= start || !isspace (chp[-1]))
return chp;
chp--;
}
@@ -223,17 +220,14 @@ skip_digits (char *chp)
{
while (1)
{
- if (*chp == '\0'
- || *chp == '\n'
- || !isdigit (*chp))
+ if (*chp == '\0' || *chp == '\n' || !isdigit (*chp))
return chp;
chp++;
}
}
char *
-skip_to_separator (char *chp,
- char *separators)
+skip_to_separator (char *chp, char *separators)
{
while (1)
{
@@ -258,14 +252,14 @@ skip_to_null (char *chp)
static char *
-skip_to_nl (char * chp)
+skip_to_nl (char *chp)
{
return skip_to_separator (chp, "\n");
}
static void
-next_line (open_table *file)
+next_line (open_table * file)
{
file->pos = skip_to_nl (file->pos);
if (*file->pos == '0')
@@ -282,7 +276,7 @@ table_read (table *root)
{
open_table *file = root->current;
table_entry *entry = NULL;
- while(1)
+ while (1)
{
/* end-of-file? */
@@ -301,7 +295,7 @@ table_read (table *root)
if (*file->pos == '{')
{
char *chp;
- next_line (file); /* discard leading brace */
+ next_line (file); /* discard leading brace */
entry = new_table_entry (file, table_code_entry);
chp = file->pos;
/* determine how many lines are involved - look for <nl> "}" */
@@ -368,7 +362,7 @@ table_read (table *root)
if (*chp == '\t')
entry->field[line_nr] = chp + 1;
else
- entry->field[line_nr] = ""; /* blank */
+ entry->field[line_nr] = ""; /* blank */
chp = skip_to_null (chp) + 1;
}
}
@@ -389,27 +383,28 @@ table_read (table *root)
char *file_name;
file->pos = chp;
/* parse the number */
- line_nr = atoi(file->pos) - 1;
+ line_nr = atoi (file->pos) - 1;
/* skip to the file name */
while (file->pos[0] != '0'
- && file->pos[0] != '"'
- && file->pos[0] != '\0')
+ && file->pos[0] != '"' && file->pos[0] != '\0')
file->pos++;
if (file->pos[0] != '"')
- error (&file->real_line, "Missing opening quote in cpp directive\n");
+ error (&file->real_line,
+ "Missing opening quote in cpp directive\n");
/* parse the file name */
file->pos++;
file_name = file->pos;
- while (file->pos[0] != '"'
- && file->pos[0] != '\0')
+ while (file->pos[0] != '"' && file->pos[0] != '\0')
file->pos++;
if (file->pos[0] != '"')
- error (&file->real_line, "Missing closing quote in cpp directive\n");
+ error (&file->real_line,
+ "Missing closing quote in cpp directive\n");
file->pos[0] = '\0';
file->pos++;
file->pos = skip_to_nl (file->pos);
if (file->pos[0] != '\n')
- error (&file->real_line, "Missing newline in cpp directive\n");
+ error (&file->real_line,
+ "Missing newline in cpp directive\n");
file->pseudo_line.file_name = file_name;
file->pseudo_line.line_nr = line_nr;
next_line (file);
@@ -498,40 +493,35 @@ table_read (table *root)
}
extern void
-table_print_code (lf *file,
- table_entry *entry)
+table_print_code (lf *file, table_entry *entry)
{
int field_nr;
int nr = 0;
- for (field_nr = 0;
- field_nr < entry->nr_fields;
- field_nr++)
+ for (field_nr = 0; field_nr < entry->nr_fields; field_nr++)
{
char *chp = entry->field[field_nr];
int in_bit_field = 0;
if (*chp == '#')
- lf_indent_suppress(file);
- while (*chp != '\0')
+ lf_indent_suppress (file);
+ while (*chp != '\0')
{
- if (chp[0] == '{'
- && !isspace(chp[1])
- && chp[1] != '\0')
+ if (chp[0] == '{' && !isspace (chp[1]) && chp[1] != '\0')
{
in_bit_field = 1;
- nr += lf_putchr(file, '_');
+ nr += lf_putchr (file, '_');
}
else if (in_bit_field && chp[0] == ':')
{
- nr += lf_putchr(file, '_');
+ nr += lf_putchr (file, '_');
}
else if (in_bit_field && *chp == '}')
{
- nr += lf_putchr(file, '_');
+ nr += lf_putchr (file, '_');
in_bit_field = 0;
}
- else
+ else
{
- nr += lf_putchr(file, *chp);
+ nr += lf_putchr (file, *chp);
}
chp++;
}
@@ -541,17 +531,14 @@ table_print_code (lf *file,
line.line_nr += field_nr;
error (&line, "Bit field brace miss match\n");
}
- nr += lf_putchr(file, '\n');
+ nr += lf_putchr (file, '\n');
}
}
void
-dump_line_ref (lf *file,
- char *prefix,
- const line_ref *line,
- char *suffix)
+dump_line_ref (lf *file, char *prefix, const line_ref *line, char *suffix)
{
lf_printf (file, "%s(line_ref*) 0x%lx", prefix, (long) line);
if (line != NULL)
@@ -570,17 +557,17 @@ table_entry_type_to_str (table_entry_type type)
{
switch (type)
{
- case table_code_entry: return "code-entry";
- case table_colon_entry: return "colon-entry";
+ case table_code_entry:
+ return "code-entry";
+ case table_colon_entry:
+ return "colon-entry";
}
return "*invalid*";
}
void
-dump_table_entry(lf *file,
- char *prefix,
- const table_entry *entry,
- char *suffix)
+dump_table_entry (lf *file,
+ char *prefix, const table_entry *entry, char *suffix)
{
lf_printf (file, "%s(table_entry*) 0x%lx", prefix, (long) entry);
if (entry != NULL)
@@ -604,7 +591,7 @@ dump_table_entry(lf *file,
#ifdef MAIN
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
table *t;
table_entry *entry;
@@ -613,7 +600,7 @@ main(int argc, char **argv)
if (argc != 2)
{
- printf("Usage: table <file>\n");
+ printf ("Usage: table <file>\n");
exit (1);
}
@@ -625,7 +612,7 @@ main(int argc, char **argv)
{
char line[10];
entry = table_read (t);
- line_nr ++;
+ line_nr++;
sprintf (line, "(%d ", line_nr);
dump_table_entry (l, line, entry, ")\n");
}
diff --git a/sim/igen/table.h b/sim/igen/table.h
index 1901274..1a9e42c 100644
--- a/sim/igen/table.h
+++ b/sim/igen/table.h
@@ -64,14 +64,17 @@
typedef struct _table table;
-typedef enum {
+typedef enum
+{
table_colon_entry,
table_code_entry,
-} table_entry_type;
+}
+table_entry_type;
typedef struct _table_entry table_entry;
-struct _table_entry {
+struct _table_entry
+{
table *file;
line_ref *line;
table_entry_type type;
@@ -82,7 +85,8 @@ struct _table_entry {
/* List of directories to search when opening a pushed file. Current
directory is always searched first */
typedef struct _table_include table_include;
-struct _table_include {
+struct _table_include
+{
char *dir;
table_include *next;
};
@@ -91,68 +95,47 @@ struct _table_include {
/* Open/read a table file. Since the file is read once during open
(and then closed immediatly) there is no close method. */
-extern table *table_open
-(const char *file_name);
+extern table *table_open (const char *file_name);
-extern table_entry *table_read
-(table *file);
+extern table_entry *table_read (table *file);
/* Push the the state of the current file and open FILE_NAME. When
the end of FILE_NAME is reached, return to the pushed file */
extern void table_push
-(table *file,
- line_ref *line,
- table_include *search,
- const char *file_name);
+ (table *file, line_ref *line, table_include *search, const char *file_name);
/* Expand the specified field_nr using the internal expansion table.
A field is only expanded when explicitly specified. */
-extern void table_expand_field
-(table_entry *entry,
- int field_nr);
+extern void table_expand_field (table_entry *entry, int field_nr);
/* Given a code entry, write the code to FILE. Since any
leading/trailing braces were striped as part of the read, they are
not written. */
-extern void table_print_code
-(lf *file,
- table_entry *entry);
+extern void table_print_code (lf *file, table_entry *entry);
/* Debugging */
extern void dump_line_ref
-(lf *file,
- char *prefix,
- const line_ref *line,
- char *suffix);
+ (lf *file, char *prefix, const line_ref *line, char *suffix);
extern void dump_table_entry
-(lf *file,
- char *prefix,
- const table_entry *entry,
- char *suffix);
+ (lf *file, char *prefix, const table_entry *entry, char *suffix);
/* Utilities for skipping around text */
-extern char *skip_digits
-(char *chp);
+extern char *skip_digits (char *chp);
-extern char *skip_spaces
-(char *chp);
+extern char *skip_spaces (char *chp);
-extern char *skip_to_separator
-(char *chp,
- char *separators);
+extern char *skip_to_separator (char *chp, char *separators);
-extern char *back_spaces
-(char *start,
- char *chp);
+extern char *back_spaces (char *start, char *chp);