diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-11-22 04:20:49 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-11-22 04:20:49 +0000 |
commit | 4e0bf4c4d00096ac436378edaf7718dafec9ff82 (patch) | |
tree | 9a80850d7051a761dee6c6dd1aed8df337a1f92c /sim/igen/gen-idecode.c | |
parent | feaee4bdbb06466822e886f5d1d30b9f1e04d985 (diff) | |
download | gdb-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/gen-idecode.c')
-rw-r--r-- | sim/igen/gen-idecode.c | 475 |
1 files changed, 193 insertions, 282 deletions
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: |