diff options
Diffstat (limited to 'sim/igen')
-rw-r--r-- | sim/igen/ChangeLog | 22 | ||||
-rw-r--r-- | sim/igen/gen-idecode.c | 75 | ||||
-rw-r--r-- | sim/igen/gen-semantics.c | 303 | ||||
-rw-r--r-- | sim/igen/gen-support.c | 165 | ||||
-rw-r--r-- | sim/igen/igen.c | 18 |
5 files changed, 546 insertions, 37 deletions
diff --git a/sim/igen/ChangeLog b/sim/igen/ChangeLog index a889da4..fa5eba8 100644 --- a/sim/igen/ChangeLog +++ b/sim/igen/ChangeLog @@ -1,3 +1,25 @@ +Tue Apr 22 21:46:28 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * igen.c (main), igen.h: Support new option - delayed-branch - + generate code to drive a delayed branch processor. + + * gen-idecode.c (gen_idecode_h): Define instruction_address type. + + * igen.c (print_icache_function_formal): Replace address_word with + instruction_address. + (print_semantic_function_formal): Ditto. + (print_semantic_function_type): Ditto. + * gen-idecode.c (print_idecode_issue_function_body): Ditto. + + * gen-semantics.c (print_semantic_body): Ditto. + (print_c_semantic): Ditto. + + * gen-support.c (support_c_function): Return a zeroed CIA instead + of just zero - works with any cia type. + + * igen.c (print_itrace): For delayed branch case, print just the + current instruction. + Thu Apr 17 07:02:33 1997 Doug Evans <dje@canuck.cygnus.com> * igen.c (print_itrace): Use TRACE_FOO_P and trace_printf. diff --git a/sim/igen/gen-idecode.c b/sim/igen/gen-idecode.c index c097295..8dfe145 100644 --- a/sim/igen/gen-idecode.c +++ b/sim/igen/gen-idecode.c @@ -732,22 +732,22 @@ print_idecode_issue_function_body(lf *file, { lf_printf(file, "{\n"); lf_indent(file, +2); - lf_printf(file, "address_word nia;\n"); + lf_printf(file, "instruction_address nia;\n"); if (!(code & generate_with_icache)) { print_idecode_body(file, table, "nia =");; } else { error("FIXME - idecode with cache?\n"); lf_putstr(file, "idecode_cache *cache_entry =\n"); - lf_putstr(file, " cpu_icache_entry(processor, cia);\n"); + lf_putstr(file, " cpu_icache_entry(cpu, cia);\n"); lf_putstr(file, "if (cache_entry->address == cia) {\n"); lf_putstr(file, " /* cache hit */\n"); lf_putstr(file, " idecode_semantic *const semantic = cache_entry->semantic;\n"); - lf_putstr(file, " cia = semantic(processor, cache_entry, cia);\n"); + lf_putstr(file, " cia = semantic(cpu, cache_entry, cia);\n"); /* tail */ if (can_stop) { lf_putstr(file, "if (keep_running != NULL && !*keep_running)\n"); - lf_putstr(file, " cpu_halt(processor, cia, was_continuing, 0/*ignore*/);\n"); + lf_putstr(file, " cpu_halt(cpu, cia, was_continuing, 0/*ignore*/);\n"); } lf_putstr(file, "}\n"); lf_putstr(file, "else {\n"); @@ -758,9 +758,9 @@ print_idecode_issue_function_body(lf *file, lf_indent(file, -2); } lf_putstr(file, " instruction_word instruction =\n"); - lf_putstr(file, " vm_instruction_map_read(cpu_instruction_map(processor), processor, cia);\n"); + lf_putstr(file, " vm_instruction_map_read(cpu_instruction_map(cpu), cpu, cia);\n"); lf_putstr(file, " if (WITH_MON != 0)\n"); - lf_putstr(file, " mon_event(mon_event_icache_miss, processor, cia);\n"); + lf_putstr(file, " mon_event(mon_event_icache_miss, cpu, cia);\n"); if ((code & generate_with_semantic_icache)) { lf_putstr(file, "{\n"); lf_indent(file, +2); @@ -770,7 +770,7 @@ print_idecode_issue_function_body(lf *file, } else { print_idecode_body(file, table, "semantic ="); - lf_putstr(file, " cia = semantic(processor, cache_entry, cia);\n"); + lf_putstr(file, " cia = semantic(cpu, cache_entry, cia);\n"); } lf_putstr(file, "}\n"); } @@ -788,22 +788,22 @@ print_jump(lf *file, { if (is_tail) { lf_putstr(file, "if (keep_running != NULL && !*keep_running)\n"); - lf_putstr(file, " cpu_halt(processor, nia, was_continuing, 0/*na*/);\n"); + lf_putstr(file, " cpu_halt(cpu, nia, was_continuing, 0/*na*/);\n"); } if (!generate_smp) { lf_putstr(file, "if (WITH_EVENTS) {\n"); lf_putstr(file, " if (event_queue_tick(events)) {\n"); - lf_putstr(file, " cpu_set_program_counter(processor, nia);\n"); + lf_putstr(file, " cpu_set_program_counter(cpu, nia);\n"); lf_putstr(file, " event_queue_process(events);\n"); - lf_putstr(file, " nia = cpu_get_program_counter(processor);\n"); + lf_putstr(file, " nia = cpu_get_program_counter(cpu);\n"); lf_putstr(file, " }\n"); lf_putstr(file, "}\n"); } if (generate_smp) { if (is_tail) - lf_putstr(file, "cpu_set_program_counter(processor, nia);\n"); + lf_putstr(file, "cpu_set_program_counter(cpu, nia);\n"); lf_putstr(file, "if (WITH_EVENTS) {\n"); lf_putstr(file, " current_cpu += 1;\n"); lf_putstr(file, " if (current_cpu >= nr_cpus) {\n"); @@ -816,12 +816,12 @@ print_jump(lf *file, lf_putstr(file, "else {\n"); lf_putstr(file, " current_cpu = (current_cpu + 1) % nr_cpus;\n"); lf_putstr(file, "}\n"); - lf_putstr(file, "processor = processors[current_cpu];\n"); - lf_putstr(file, "nia = cpu_get_program_counter(processor);\n"); + lf_putstr(file, "cpu = cpus[current_cpu];\n"); + lf_putstr(file, "nia = cpu_get_program_counter(cpu);\n"); } if ((code & generate_with_icache)) { - lf_putstr(file, "cache_entry = cpu_icache_entry(processor, nia);\n"); + lf_putstr(file, "cache_entry = cpu_icache_entry(cpu, nia);\n"); lf_putstr(file, "if (cache_entry->address == nia) {\n"); lf_putstr(file, " /* cache hit */\n"); lf_putstr(file, " goto *cache_entry->semantic;\n"); @@ -1020,7 +1020,7 @@ print_jump_until_stop_body(lf *file, lf_printf(file, "int *keep_running = NULL;\n"); lf_putstr(file, "jmp_buf halt;\n"); lf_putstr(file, "jmp_buf restart;\n"); - lf_putstr(file, "cpu *processor = NULL;\n"); + 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)) { @@ -1039,7 +1039,7 @@ print_jump_until_stop_body(lf *file, 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(processors[cpu_nr]);\n"); + lf_putstr(file, " cpu_flush_icache(cpus[cpu_nr]);\n"); lf_putstr(file, "}\n"); } @@ -1055,8 +1055,8 @@ print_jump_until_stop_body(lf *file, lf_putstr(file, "\n"); if (!generate_smp) { - lf_putstr(file, "processor = processors[0];\n"); - lf_putstr(file, "nia = cpu_get_program_counter(processor);\n"); + 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"); @@ -1078,8 +1078,8 @@ print_jump_until_stop_body(lf *file, } lf_putstr(file, "instruction\n"); - lf_putstr(file, " = vm_instruction_map_read(cpu_instruction_map(processor),\n"); - lf_putstr(file, " processor, nia);\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 out a table of all the internals functions */ @@ -1220,7 +1220,7 @@ print_idecode_validate(lf *file, lf_printf(file, "\n"); lf_indent_suppress(file); lf_printf(file, "#if defined(IS_FP_AVAILABLE)\n"); - lf_printf(file, "/* Validate: FP available according to processor */\n"); + 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); @@ -1284,21 +1284,34 @@ print_idecode_issue_function_header(lf *file, void -gen_idecode_h(lf *file, - insn_table *table, - cache_table *cache_rules) +gen_idecode_h (lf *file, + insn_table *table, + cache_table *cache_rules) { lf_printf(file, "typedef unsigned%d %sinstruction_word;\n", insn_bit_size, global_name_prefix); + if ((code & generate_with_semantic_delayed_branch)) + { + lf_printf (file, "typedef struct _instruction_address {\n"); + lf_printf (file, " address_word ip; /* instruction pointer */\n"); + lf_printf (file, " address_word dp; /* delayed-slot pointer */\n"); + lf_printf (file, "} instruction_address;\n"); + } + else + { + lf_printf (file, "typedef address_word instruction_address;\n"); + } lf_printf(file, "\n"); print_icache_struct(table, cache_rules, file); lf_printf(file, "\n"); - if ((code & generate_with_icache)) { - error("FIXME - idecode with icache incomplete"); - } - else { - print_idecode_issue_function_header(file, 0/*is definition*/); - } + if ((code & generate_with_icache)) + { + error("FIXME - idecode with icache incomplete"); + } + else + { + print_idecode_issue_function_header(file, 0/*is definition*/); + } } @@ -1328,7 +1341,7 @@ gen_idecode_c(lf *file, cache_table *cache_rules) { /* the intro */ - lf_printf(file, "#include \"engine.h\"\n"); + lf_printf(file, "#include \"sim-main.h\"\n"); lf_printf(file, "#include \"%sidecode.h\"\n", global_name_prefix); lf_printf(file, "#include \"%ssemantics.h\"\n", global_name_prefix); lf_printf(file, "#include \"%sicache.h\"\n", global_name_prefix); diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c new file mode 100644 index 0000000..57363c9 --- /dev/null +++ b/sim/igen/gen-semantics.c @@ -0,0 +1,303 @@ +/* This file is part of the program psim. + + Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + + + +#include "misc.h" +#include "lf.h" +#include "table.h" +#include "filter.h" + +#include "ld-decode.h" +#include "ld-cache.h" +#include "ld-insn.h" + +#include "igen.h" + +#include "gen-semantics.h" +#include "gen-icache.h" +#include "gen-idecode.h" + + +static void +print_semantic_function_header(lf *file, + const char *basename, + insn_bits *expanded_bits, + int is_function_definition) +{ + int indent; + lf_printf(file, "\n"); + lf_print_function_type_function(file, print_semantic_function_type, "EXTERN_SEMANTICS", + (is_function_definition ? "\n" : " ")); + indent = print_function_name(file, + basename, + expanded_bits, + function_name_prefix_semantics); + if (is_function_definition) + lf_indent(file, +indent); + else + lf_printf(file, "\n"); + lf_printf(file, "("); + print_semantic_function_formal(file); + lf_printf(file, ")"); + if (is_function_definition) + lf_indent(file, -indent); + else + lf_printf(file, ";"); + lf_printf(file, "\n"); +} + +void +print_semantic_declaration(insn_table *entry, + lf *file, + void *data, + insn *instruction, + int depth) +{ + if (generate_expanded_instructions) { + ASSERT(entry->nr_insn == 1); + print_semantic_function_header(file, + instruction->file_entry->fields[insn_name], + entry->expanded_bits, + 0/* is not function definition*/); + } + else { + print_semantic_function_header(file, + instruction->file_entry->fields[insn_name], + NULL, + 0/* is not function definition*/); + } +} + + + +/* generate the semantics.c file */ + + +void +print_idecode_invalid(lf *file, + const char *result, + invalid_type type) +{ + const char *name; + switch (type) { + case invalid_illegal: name = "illegal"; break; + case invalid_fp_unavailable: name = "fp_unavailable"; break; + case invalid_wrong_slot: name = "wrong_slot"; break; + } + if ((code & generate_jumps)) + lf_printf(file, "goto %s_%s;\n", + (code & generate_with_icache) ? "icache" : "semantic", + name); + else if ((code & generate_with_icache)) { + lf_printf(file, "%s %sicache_%s(", result, global_name_prefix, name); + print_icache_function_actual(file); + lf_printf(file, ");\n"); + } + else { + lf_printf(file, "%s %ssemantic_%s(", result, global_name_prefix, name); + print_semantic_function_actual(file); + lf_printf(file, ");\n"); + } +} + + +void +print_semantic_body(lf *file, + insn *instruction, + insn_bits *expanded_bits, + opcode_field *opcodes) +{ + print_itrace(file, instruction->file_entry, 0/*put_value_in_cache*/); + + /* validate the instruction, if a cache this has already been done */ + if (!(code & generate_with_icache)) + print_idecode_validate(file, instruction, opcodes); + + /* generate the profiling call - this is delayed until after the + instruction has been verified */ + lf_printf(file, "\n"); + lf_indent_suppress(file); + lf_printf(file, "#if defined(WITH_MON)\n"); + lf_printf(file, "/* monitoring: */\n"); + lf_printf(file, "if (WITH_MON & MONITOR_INSTRUCTION_ISSUE) {\n"); + lf_printf(file, " mon_issue("); + print_function_name(file, + instruction->file_entry->fields[insn_name], + NULL, + function_name_prefix_itable); + lf_printf(file, ", cpu, cia);\n"); + lf_printf(file, "}\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"); + if ((code & generate_with_semantic_returning_modified_nia_only)) + lf_printf(file, "nia = -1;\n"); + else if ((code & generate_with_semantic_delayed_branch)) { + lf_printf(file, "nia.ip = cia.dp; /* instruction pointer */\n"); + lf_printf(file, "nia.dp = cia.dp + %d; /* delayed-slot pointer\n", + insn_bit_size / 8); + } + else + lf_printf(file, "nia = cia + %d;\n", insn_bit_size / 8); + + /* if conditional, generate code to verify that the instruction + should be issued */ + if (it_is("c", instruction->file_entry->fields[insn_options]) + || (code & generate_with_semantic_conditional_issue)) { + lf_printf(file, "\n"); + lf_printf(file, "/* execute only if conditional passes */\n"); + lf_printf(file, "if (IS_CONDITION_OK) {\n"); + lf_indent(file, +2); + /* FIXME - need to log a conditional failure */ + } + + /* generate the code (or at least something */ + lf_printf(file, "\n"); + lf_printf(file, "/* semantics: */\n"); + if (instruction->file_entry->annex != NULL) { + /* true code */ + table_entry_print_cpp_line_nr(file, instruction->file_entry); + lf_printf(file, "{\n"); + lf_indent(file, +2); + lf_print__c_code(file, instruction->file_entry->annex); + lf_indent(file, -2); + lf_printf(file, "}\n"); + lf_print__internal_reference(file); + } + else if (it_is("nop", instruction->file_entry->fields[insn_flags])) { + lf_print__internal_reference(file); + } + else { + /* abort so it is implemented now */ + table_entry_print_cpp_line_nr(file, instruction->file_entry); + lf_printf(file, "engine_error(system, \"%s:%d:0x%%08lx:%%s unimplemented\\n\",\n", + filter_filename(instruction->file_entry->file_name), + instruction->file_entry->line_nr); + lf_printf(file, " (long)cia, itable[MY_INDEX].name);\n"); + lf_print__internal_reference(file); + } + + /* Close off the conditional execution */ + if (it_is("c", instruction->file_entry->fields[insn_options]) + || (code & generate_with_semantic_conditional_issue)) { + lf_indent(file, -2); + lf_printf(file, "}\n"); + } +} + +static void +print_c_semantic(lf *file, + insn *instruction, + insn_bits *expanded_bits, + opcode_field *opcodes, + cache_table *cache_rules) +{ + + lf_printf(file, "{\n"); + lf_indent(file, +2); + + print_my_defines(file, expanded_bits, instruction->file_entry); + lf_printf(file, "\n"); + print_icache_body(file, + instruction, + expanded_bits, + cache_rules, + ((code & generate_with_direct_access) + ? define_variables + : declare_variables), + ((code & generate_with_icache) + ? get_values_from_icache + : do_not_use_icache)); + + lf_printf(file, "instruction_address nia;\n"); + 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 (code & generate_with_direct_access) + print_icache_body(file, + instruction, + expanded_bits, + cache_rules, + undef_variables, + ((code & generate_with_icache) + ? get_values_from_icache + : do_not_use_icache)); + + lf_indent(file, -2); + lf_printf(file, "}\n"); +} + +static void +print_c_semantic_function(lf *file, + insn *instruction, + insn_bits *expanded_bits, + opcode_field *opcodes, + cache_table *cache_rules) +{ + /* build the semantic routine to execute the instruction */ + print_semantic_function_header(file, + instruction->file_entry->fields[insn_name], + expanded_bits, + 1/*is-function-definition*/); + print_c_semantic(file, + instruction, + expanded_bits, + opcodes, + cache_rules); +} + +void +print_semantic_definition(insn_table *entry, + lf *file, + void *data, + insn *instruction, + int depth) +{ + cache_table *cache_rules = (cache_table*)data; + if (generate_expanded_instructions) { + ASSERT(entry->nr_insn == 1 + && entry->opcode == NULL + && entry->parent != NULL + && entry->parent->opcode != NULL); + ASSERT(entry->nr_insn == 1 + && entry->opcode == NULL + && entry->parent != NULL + && entry->parent->opcode != NULL + && entry->parent->opcode_rule != NULL); + print_c_semantic_function(file, + entry->insns, + entry->expanded_bits, + entry->parent->opcode, + cache_rules); + } + else { + print_c_semantic_function(file, instruction, + NULL, NULL, + cache_rules); + } +} diff --git a/sim/igen/gen-support.c b/sim/igen/gen-support.c new file mode 100644 index 0000000..d73a0de --- /dev/null +++ b/sim/igen/gen-support.c @@ -0,0 +1,165 @@ +/* This file is part of the program psim. + + Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + */ + +#include "misc.h" +#include "lf.h" +#include "table.h" +#include "filter.h" + +#include "ld-decode.h" +#include "ld-cache.h" +#include "ld-insn.h" + +#include "igen.h" + +#include "gen-semantics.h" +#include "gen-support.h" + +static void +print_support_function_name(lf *file, + table_entry *function, + int is_function_definition) +{ + if (it_is("internal", function->fields[insn_flags])) { + lf_print_function_type_function(file, print_semantic_function_type, "INLINE_SUPPORT", + (is_function_definition ? "\n" : " ")); + print_function_name(file, + function->fields[function_name], + NULL, + function_name_prefix_semantics); + lf_printf(file, "\n("); + print_semantic_function_formal(file); + lf_printf(file, ")"); + if (!is_function_definition) + lf_printf(file, ";"); + lf_printf(file, "\n"); + } + else { + /* map the name onto a globally valid name */ + if (!is_function_definition && strcmp(global_name_prefix, "") != 0) { + lf_indent_suppress(file); + lf_printf(file, "#define %s %s%s\n", + function->fields[function_name], + global_name_prefix, + function->fields[function_name]); + } + lf_print_function_type(file, + function->fields[function_type], + "INLINE_SUPPORT", + (is_function_definition ? "\n" : " ")); + lf_printf(file, "%s%s\n(", + global_name_prefix, + function->fields[function_name]); + if (generate_smp) + lf_printf(file, "sim_cpu *cpu"); + else + lf_printf(file, "SIM_DESC sd"); + if (strcmp(function->fields[function_param], "") != 0) + lf_printf(file, ", %s", function->fields[function_param]); + lf_printf(file, ")%s", (is_function_definition ? "\n" : ";\n")); + } +} + + +static void +support_h_function(insn_table *entry, + lf *file, + void *data, + table_entry *function) +{ + ASSERT(function->fields[function_type] != NULL); + ASSERT(function->fields[function_param] != NULL); + print_support_function_name(file, + function, + 0/*!is_definition*/); + lf_printf(file, "\n"); +} + + +extern void +gen_support_h(insn_table *table, + lf *file) +{ + /* output the definition of `_SD'*/ + if (generate_smp) { + lf_printf(file, "#define _SD cpu\n"); + lf_printf(file, "#define SD cpu->sd\n"); + lf_printf(file, "#define CPU cpu\n"); + } + else { + lf_printf(file, "#define _SD sd\n"); + lf_printf(file, "#define SD sd\n"); + lf_printf(file, "#define CPU (&sd->cpu)\n"); + } + lf_printf(file, "\n"); + /* output a declaration for all functions */ + insn_table_traverse_function(table, + file, NULL, + support_h_function); + 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", global_name_prefix); + lf_printf(file, "# endif\n"); + lf_printf(file, "#endif\n"); +} + +static void +support_c_function(insn_table *table, + lf *file, + void *data, + table_entry *function) +{ + ASSERT (function->fields[function_type] != NULL); + print_support_function_name (file, + function, + 1/*!is_definition*/); + table_entry_print_cpp_line_nr (file, function); + lf_printf (file, "{\n"); + lf_indent (file, +2); + lf_print__c_code (file, function->annex); + if (it_is ("internal", function->fields[insn_flags])) + { + lf_printf (file, "sim_io_error (sd, \"Internal function must longjump\\n\");\n"); + lf_printf (file, "memset (&cia, 0, sizeof cia);\n"); + lf_printf (file, "return cia;\n"); + } + lf_indent (file, -2); + lf_printf (file, "}\n"); + lf_print__internal_reference (file); + lf_printf (file, "\n"); +} + + +void +gen_support_c(insn_table *table, + lf *file) +{ + lf_printf(file, "#include \"sim-main.h\"\n"); + lf_printf(file, "#include \"%sidecode.h\"\n", global_name_prefix); + lf_printf(file, "#include \"%ssupport.h\"\n", global_name_prefix); + lf_printf(file, "\n"); + + /* output a definition (c-code) for all functions */ + insn_table_traverse_function(table, + file, NULL, + support_c_function); +} diff --git a/sim/igen/igen.c b/sim/igen/igen.c index d7a0b94..2590dc5 100644 --- a/sim/igen/igen.c +++ b/sim/igen/igen.c @@ -64,13 +64,13 @@ print_semantic_function_formal(lf *file) { int nr; if ((code & generate_with_icache)) - nr = lf_printf(file, "SIM_DESC sd,\n %sidecode_cache *cache_entry,\n address_word cia", + nr = lf_printf(file, "SIM_DESC sd,\n %sidecode_cache *cache_entry,\n instruction_address cia", global_name_prefix); else if (generate_smp) - nr = lf_printf(file, "sim_cpu *cpu,\n %sinstruction_word instruction,\n address_word cia", + nr = lf_printf(file, "sim_cpu *cpu,\n %sinstruction_word instruction,\n instruction_address cia", global_name_prefix); else - nr = lf_printf(file, "SIM_DESC sd,\n %sinstruction_word instruction,\n address_word cia", + nr = lf_printf(file, "SIM_DESC sd,\n %sinstruction_word instruction,\n instruction_address cia", global_name_prefix); return nr; } @@ -92,7 +92,7 @@ int print_semantic_function_type(lf *file) { int nr; - nr = lf_printf(file, "address_word"); + nr = lf_printf(file, "instruction_address"); return nr; } @@ -108,7 +108,7 @@ print_icache_function_formal(lf *file) else nr += lf_printf(file, "SIM_DESC sd,\n"); nr += lf_printf(file, " %sinstruction_word instruction,\n", global_name_prefix); - nr += lf_printf(file, " address_word cia,\n"); + nr += lf_printf(file, " instruction_address cia,\n"); nr += lf_printf(file, " %sidecode_cache *cache_entry", global_name_prefix); return nr; } @@ -257,7 +257,7 @@ print_itrace(lf *file, lf_printf(file, " \"%s:%d:0x%%08lx:%%s\\n\", %s, %s);\n", filter_filename(file_entry->file_name), file_entry->line_nr, - "(long)cia", + ((code & generate_with_semantic_delayed_branch) ? "(long)cia.ip" : "(long)cia"), "itable[MY_INDEX].name"); lf_printf(file, "}\n"); lf_indent_suppress(file); @@ -450,6 +450,7 @@ main(int argc, printf(" semantic-icache - include semantic code in cracking functions\n"); printf(" insn-in-icache - save original instruction when cracking\n"); printf(" default-nia-minus-one - instead of cia + insn-size\n"); + printf(" delayed-branch - instead of cia + insn-size\n"); printf(" conditional-issue - conditionally issue each instruction\n"); printf(" validate-slot - perform slot verification as part of decode\n"); printf("\n"); @@ -548,6 +549,11 @@ main(int argc, } else if (strcmp(optarg, "default-nia-minus-one") == 0) { code |= generate_with_semantic_returning_modified_nia_only; + code &= ~generate_with_semantic_delayed_branch; + } + else if (strcmp(optarg, "delayed-branch") == 0) { + code |= generate_with_semantic_delayed_branch; + code &= ~generate_with_semantic_returning_modified_nia_only; } else if (strcmp(optarg, "conditional-issue") == 0) { code |= generate_with_semantic_conditional_issue; |