X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Figen%2Fgen-semantics.c;h=d28b431fbfa1c4fb8750674e8941894fb248b0d4;hb=196535a69c8568342e62fdf5e3f5ade04470fd6a;hp=88b60121c4c7b7e92be216cb6e6d859ae3edfaff;hpb=e98fe4f7b54cbdf29aef9287bbb1bea8801dd05a;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c index 88b60121c4..d28b431fbf 100644 --- a/sim/igen/gen-semantics.c +++ b/sim/igen/gen-semantics.c @@ -1,22 +1,23 @@ -/* This file is part of the program psim. +/* The IGEN simulator generator for GDB, the GNU Debugger. - Copyright (C) 1994-1997, Andrew Cagney + Copyright 2002-2020 Free Software Foundation, Inc. - 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. + Contributed by Andrew Cagney. - 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. - - */ + This file is part of GDB. + + 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 3 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, see . */ @@ -45,7 +46,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" : " ")); @@ -82,52 +83,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.prefix.global.name, 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.prefix.global.name, name); + lf_printf (file, "%s %ssemantic_%s (", result, + options.module.global.prefix.l, name); print_semantic_function_actual (file, 0); lf_printf (file, ");\n"); } @@ -136,19 +143,32 @@ 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) { - print_itrace (file, instruction, 0/*put_value_in_cache*/); - /* validate the instruction, if a cache this has already been done */ if (!options.gen.icache) { print_idecode_validate (file, instruction, opcodes); } - - /* generate the profiling call - this is delayed until after the + + 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 */ + { + lf_printf (file, "\n"); + lf_indent_suppress (file); + lf_printf (file, "#if defined (%sPROFILE_COUNT_INSN)\n", + options.module.itable.prefix.u); + lf_printf (file, "%sPROFILE_COUNT_INSN (CPU, CIA, MY_INDEX);\n", + options.module.itable.prefix.u); + lf_indent_suppress (file); + lf_printf (file, "#endif\n"); + } + + /* generate the model call - this is delayed until after the instruction has been verified */ { lf_printf (file, "\n"); @@ -160,22 +180,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.prefix.global.uname); + lf_printf (file, "nia = %sINVALID_INSTRUCTION_ADDRESS;\n", + options.module.global.prefix.u); } else { @@ -201,7 +219,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 { @@ -211,7 +229,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") @@ -224,16 +242,17 @@ 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 */ if (options.gen.zero_reg) { lf_printf (file, "\n"); - lf_printf (file, "GPR(%d) = 0;\n", options.gen.zero_reg_nr); + 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"); @@ -254,49 +273,45 @@ print_semantic_body (lf *file, } else { + const char *prefix = "sim_engine_abort ("; + int indent = strlen (prefix); /* abort so it is implemented now */ lf_print__line_ref (file, instruction->line); - lf_printf (file, "sim_engine_abort (SD, CPU, cia, \"%s:%d:0x%%08lx:%%s unimplemented\\n\",\n", + lf_printf (file, "%sSD, CPU, cia, \\\n", prefix); + lf_indent (file, +indent); + lf_printf (file, "\"%s:%d:0x%%08lx:%%s unimplemented\\n\", \\\n", filter_filename (instruction->line->file_name), instruction->line->line_nr); - if (options.gen.delayed_branch) - { - lf_printf (file, " (long)cia.ip,\n"); - } - else - { - lf_printf (file, " (long)cia,\n"); - } - lf_printf (file, " %sitable[MY_INDEX].name);\n", - options.prefix.itable.name); + lf_printf (file, "(long) CIA, \\\n"); + lf_printf (file, "%sitable[MY_INDEX].name);\n", + options.module.itable.prefix.l); + 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, @@ -307,16 +322,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.prefix.global.name); - 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) { @@ -327,51 +339,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); } - -