aboutsummaryrefslogtreecommitdiff
path: root/sim/igen/igen.c
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/igen.c
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/igen.c')
-rw-r--r--sim/igen/igen.c485
1 files changed, 256 insertions, 229 deletions
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");
}