| 1 | /* The IGEN simulator generator for GDB, the GNU Debugger. |
| 2 | |
| 3 | Copyright 2002-2017 Free Software Foundation, Inc. |
| 4 | |
| 5 | Contributed by Andrew Cagney. |
| 6 | |
| 7 | This file is part of GDB. |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 3 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 21 | |
| 22 | |
| 23 | /* Creates the files semantics.[hc]. |
| 24 | |
| 25 | The generated file semantics contains functions that implement the |
| 26 | operations required to model a single target processor instruction. |
| 27 | |
| 28 | Several different variations on the semantics file can be created: |
| 29 | |
| 30 | o uncached |
| 31 | |
| 32 | No instruction cache exists. The semantic function |
| 33 | needs to generate any required values locally. |
| 34 | |
| 35 | o cached - separate cracker and semantic |
| 36 | |
| 37 | Two independant functions are created. Firstly the |
| 38 | function that cracks an instruction entering it into a |
| 39 | cache and secondly the semantic function propper that |
| 40 | uses the cache. |
| 41 | |
| 42 | o cached - semantic + cracking semantic |
| 43 | |
| 44 | The function that cracks the instruction and enters |
| 45 | all values into the cache also contains a copy of the |
| 46 | semantic code (avoiding the need to call both the |
| 47 | cracker and the semantic function when there is a |
| 48 | cache miss). |
| 49 | |
| 50 | For each of these general forms, several refinements can occure: |
| 51 | |
| 52 | o do/don't duplicate/expand semantic functions |
| 53 | |
| 54 | As a consequence of decoding an instruction, the |
| 55 | decoder, as part of its table may have effectivly made |
| 56 | certain of the variable fields in an instruction |
| 57 | constant. Separate functions for each of the |
| 58 | alternative values for what would have been treated as |
| 59 | a variable part can be created. |
| 60 | |
| 61 | o use cache struct directly. |
| 62 | |
| 63 | When a cracking cache is present, the semantic |
| 64 | functions can be generated to either hold intermediate |
| 65 | cache values in local variables or always refer to the |
| 66 | contents of the cache directly. */ |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | extern void print_semantic_declaration |
| 74 | (lf *file, |
| 75 | insn_entry * insn, |
| 76 | opcode_bits *bits, insn_opcodes *opcodes, int nr_prefetched_words); |
| 77 | |
| 78 | extern void print_semantic_definition |
| 79 | (lf *file, |
| 80 | insn_entry * insn, |
| 81 | opcode_bits *bits, |
| 82 | insn_opcodes *opcodes, cache_entry *cache_rules, int nr_prefetched_words); |
| 83 | |
| 84 | |
| 85 | typedef enum |
| 86 | { |
| 87 | invalid_illegal, |
| 88 | invalid_fp_unavailable, |
| 89 | invalid_wrong_slot, |
| 90 | } |
| 91 | invalid_type; |
| 92 | |
| 93 | extern void print_idecode_invalid |
| 94 | (lf *file, const char *result, invalid_type type); |
| 95 | |
| 96 | extern void print_semantic_body |
| 97 | (lf *file, |
| 98 | insn_entry * instruction, |
| 99 | opcode_bits *expanded_bits, insn_opcodes *opcodes); |