| 1 | /* Collection of junk for CRIS. |
| 2 | Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
| 3 | Contributed by Axis Communications. |
| 4 | |
| 5 | This file is part of the GNU simulators. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2, or (at your option) |
| 10 | any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License along |
| 18 | with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | /* For other arch:s, this file is described as a "collection of junk", so |
| 22 | let's collect some nice junk of our own. Keep it; it might be useful |
| 23 | some day! */ |
| 24 | |
| 25 | #ifndef CRIS_SIM_H |
| 26 | #define CRIS_SIM_H |
| 27 | |
| 28 | typedef struct { |
| 29 | /* Whether the branch for the current insn was taken. Placed first |
| 30 | here, in hope it'll get closer to the main simulator data. */ |
| 31 | USI branch_taken; |
| 32 | |
| 33 | /* PC of the insn of the branch. */ |
| 34 | USI old_pc; |
| 35 | |
| 36 | /* Static cycle count for all insns executed so far, including |
| 37 | non-context-specific stall cycles, for example when adding to PC. */ |
| 38 | unsigned64 basic_cycle_count; |
| 39 | |
| 40 | /* Stall cycles for unaligned access of memory operands. FIXME: |
| 41 | Should or should not include unaligned [PC+] operands? */ |
| 42 | unsigned64 unaligned_mem_dword_count; |
| 43 | |
| 44 | /* Context-specific stall cycles. */ |
| 45 | unsigned64 memsrc_stall_count; |
| 46 | unsigned64 memraw_stall_count; |
| 47 | unsigned64 movemsrc_stall_count; |
| 48 | unsigned64 movemaddr_stall_count; |
| 49 | unsigned64 movemdst_stall_count; |
| 50 | unsigned64 mulsrc_stall_count; |
| 51 | unsigned64 jumpsrc_stall_count; |
| 52 | unsigned64 branch_stall_count; |
| 53 | unsigned64 jumptarget_stall_count; |
| 54 | |
| 55 | /* What kind of target-specific trace to perform. */ |
| 56 | int flags; |
| 57 | |
| 58 | /* Just the basic cycle count. */ |
| 59 | #define FLAG_CRIS_MISC_PROFILE_SIMPLE 1 |
| 60 | |
| 61 | /* Show unaligned accesses. */ |
| 62 | #define FLAG_CRIS_MISC_PROFILE_UNALIGNED 2 |
| 63 | |
| 64 | /* Show schedulable entities. */ |
| 65 | #define FLAG_CRIS_MISC_PROFILE_SCHEDULABLE 4 |
| 66 | |
| 67 | /* Show everything. */ |
| 68 | #define FLAG_CRIS_MISC_PROFILE_ALL \ |
| 69 | (FLAG_CRIS_MISC_PROFILE_SIMPLE \ |
| 70 | | FLAG_CRIS_MISC_PROFILE_UNALIGNED \ |
| 71 | | FLAG_CRIS_MISC_PROFILE_SCHEDULABLE) |
| 72 | |
| 73 | /* Emit trace of each insn, xsim style. */ |
| 74 | #define FLAG_CRIS_MISC_PROFILE_XSIM_TRACE 8 |
| 75 | |
| 76 | #define N_CRISV32_BRANCH_PREDICTORS 256 |
| 77 | unsigned char branch_predictors[N_CRISV32_BRANCH_PREDICTORS]; |
| 78 | |
| 79 | } CRIS_MISC_PROFILE; |
| 80 | |
| 81 | /* Handler prototypes for functions called from the CGEN description. */ |
| 82 | |
| 83 | extern USI cris_bmod_handler (SIM_CPU *, UINT, USI); |
| 84 | extern void cris_flush_simulator_decode_cache (SIM_CPU *, USI); |
| 85 | extern USI crisv10f_break_handler (SIM_CPU *, USI, USI); |
| 86 | extern USI crisv32f_break_handler (SIM_CPU *, USI, USI); |
| 87 | extern USI cris_break_13_handler (SIM_CPU *, USI, USI, USI, USI, USI, USI, |
| 88 | USI, USI); |
| 89 | |
| 90 | /* Using GNU syntax (not C99) so we can compile this on RH 6.2 |
| 91 | (egcs-1.1.2/gcc-2.91.66). */ |
| 92 | #define cris_trace_printf(SD, CPU, FMT...) \ |
| 93 | do \ |
| 94 | { \ |
| 95 | if (TRACE_FILE (STATE_TRACE_DATA (SD)) != NULL) \ |
| 96 | fprintf (TRACE_FILE (CPU_TRACE_DATA (CPU)), FMT); \ |
| 97 | else \ |
| 98 | sim_io_printf (SD, FMT); \ |
| 99 | } \ |
| 100 | while (0) |
| 101 | |
| 102 | #if WITH_PROFILE_MODEL_P |
| 103 | #define crisv32f_branch_taken(cpu, oldpc, newpc, taken) \ |
| 104 | do \ |
| 105 | { \ |
| 106 | CPU_CRIS_MISC_PROFILE (cpu)->old_pc = oldpc; \ |
| 107 | CPU_CRIS_MISC_PROFILE (cpu)->branch_taken = taken; \ |
| 108 | } \ |
| 109 | while (0) |
| 110 | #else |
| 111 | #define crisv32f_branch_taken(cpu, oldpc, newpc, taken) |
| 112 | #endif |
| 113 | |
| 114 | #define crisv10f_branch_taken(cpu, oldpc, newpc, taken) |
| 115 | |
| 116 | #define crisv32f_read_supr(cpu, index) \ |
| 117 | (cgen_rtx_error (current_cpu, \ |
| 118 | "Read of support register is unimplemented"), \ |
| 119 | 0) |
| 120 | |
| 121 | #define crisv32f_write_supr(cpu, index, val) \ |
| 122 | cgen_rtx_error (current_cpu, \ |
| 123 | "Write to support register is unimplemented") \ |
| 124 | |
| 125 | #define crisv32f_rfg_handler(cpu, pc) \ |
| 126 | cgen_rtx_error (current_cpu, "RFG isn't implemented") |
| 127 | |
| 128 | #define crisv32f_halt_handler(cpu, pc) \ |
| 129 | (cgen_rtx_error (current_cpu, "HALT isn't implemented"), 0) |
| 130 | |
| 131 | #define crisv32f_fidxi_handler(cpu, pc, indx) \ |
| 132 | (cgen_rtx_error (current_cpu, "FIDXI isn't implemented"), 0) |
| 133 | |
| 134 | #define crisv32f_ftagi_handler(cpu, pc, indx) \ |
| 135 | (cgen_rtx_error (current_cpu, "FTAGI isn't implemented"), 0) |
| 136 | |
| 137 | #define crisv32f_fidxd_handler(cpu, pc, indx) \ |
| 138 | (cgen_rtx_error (current_cpu, "FIDXD isn't implemented"), 0) |
| 139 | |
| 140 | #define crisv32f_ftagd_handler(cpu, pc, indx) \ |
| 141 | (cgen_rtx_error (current_cpu, "FTAGD isn't implemented"), 0) |
| 142 | |
| 143 | /* We have nothing special to do when interrupts or NMI are enabled |
| 144 | after having been disabled, so empty macros are enough for these |
| 145 | hooks. */ |
| 146 | #define crisv32f_interrupts_enabled(cpu) |
| 147 | #define crisv32f_nmi_enabled(cpu) |
| 148 | |
| 149 | /* Better warn for this case here, because everything needed is |
| 150 | somewhere within the CPU. Compare to trying to use interrupts and |
| 151 | NMI, which would fail earlier, when trying to make nonexistent |
| 152 | external components generate those exceptions. */ |
| 153 | #define crisv32f_single_step_enabled(cpu) \ |
| 154 | ((crisv32f_h_qbit_get (cpu) != 0 \ |
| 155 | || (crisv32f_h_sr_get (cpu, H_SR_SPC) & ~1) != 0) \ |
| 156 | ? (cgen_rtx_error (cpu, \ |
| 157 | "single-stepping isn't implemented"), 0) \ |
| 158 | : 0) |
| 159 | |
| 160 | /* We don't need to track the value of the PID register here. */ |
| 161 | #define crisv32f_write_pid_handler(cpu, val) |
| 162 | |
| 163 | /* Neither do we need to know of transitions to user mode. */ |
| 164 | #define crisv32f_usermode_enabled(cpu) |
| 165 | |
| 166 | /* House-keeping exported from traps.c */ |
| 167 | extern void cris_set_callbacks (host_callback *); |
| 168 | |
| 169 | /* FIXME: Add more junk. */ |
| 170 | #endif |