1 /* CPU family header for lm32bf.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright (C) 1996-2024 Free Software Foundation, Inc.
7 This file is part of the GNU simulators.
9 This file 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, or (at your option)
14 It is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
28 /* Maximum number of instructions that are fetched at a time.
29 This is for LIW type instructions sets (e.g. m32r). */
30 #define MAX_LIW_INSNS 1
32 /* Maximum number of instructions that can be executed in parallel. */
33 #define MAX_PARALLEL_INSNS 1
35 /* The size of an "int" needed to hold an instruction word.
36 This is usually 32 bits, but some architectures needs 64 bits. */
37 typedef CGEN_INSN_INT CGEN_INSN_WORD
;
39 #include "cgen-engine.h"
41 /* CPU state information. */
43 /* Hardware elements. */
47 #define GET_H_PC() CPU (h_pc)
48 #define SET_H_PC(x) (CPU (h_pc) = (x))
49 /* General purpose registers */
51 #define GET_H_GR(a1) CPU (h_gr)[a1]
52 #define SET_H_GR(a1, x) (CPU (h_gr)[a1] = (x))
53 /* Control and status registers */
55 #define GET_H_CSR(a1) CPU (h_csr)[a1]
56 #define SET_H_CSR(a1, x) (CPU (h_csr)[a1] = (x))
58 #define CPU_CGEN_HW(cpu) (& LM32_SIM_CPU (cpu)->cpu_data.hardware)
61 /* Cover fns for register access. */
62 USI
lm32bf_h_pc_get (SIM_CPU
*);
63 void lm32bf_h_pc_set (SIM_CPU
*, USI
);
64 SI
lm32bf_h_gr_get (SIM_CPU
*, UINT
);
65 void lm32bf_h_gr_set (SIM_CPU
*, UINT
, SI
);
66 SI
lm32bf_h_csr_get (SIM_CPU
*, UINT
);
67 void lm32bf_h_csr_set (SIM_CPU
*, UINT
, SI
);
69 /* These must be hand-written. */
70 extern CPUREG_FETCH_FN lm32bf_fetch_register
;
71 extern CPUREG_STORE_FN lm32bf_store_register
;
77 /* Instruction argument buffer. */
80 struct { /* no operands */
116 /* Writeback handler. */
118 /* Pointer to argbuf entry for insn whose results need writing back. */
119 const struct argbuf
*abuf
;
121 /* x-before handler */
123 /*const SCACHE *insns[MAX_PARALLEL_INSNS];*/
126 /* x-after handler */
130 /* This entry is used to terminate each pbb. */
132 /* Number of insns in pbb. */
134 /* Next pbb to execute. */
136 SCACHE
*branch_target
;
141 /* The ARGBUF struct. */
143 /* These are the baseclass definitions. */
148 /* ??? Temporary hack for skip insns. */
151 /* cpu specific data follows */
154 union sem_fields fields
;
159 ??? SCACHE used to contain more than just argbuf. We could delete the
160 type entirely and always just use ARGBUF, but for future concerns and as
161 a level of abstraction it is left in. */
164 struct argbuf argbuf
;
167 /* Macros to simplify extraction, reading and semantic code.
168 These define and assign the local vars that contain the insn's fields. */
170 #define EXTRACT_IFMT_EMPTY_VARS \
172 #define EXTRACT_IFMT_EMPTY_CODE \
175 #define EXTRACT_IFMT_ADD_VARS \
182 #define EXTRACT_IFMT_ADD_CODE \
184 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
185 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
186 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
187 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
188 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
190 #define EXTRACT_IFMT_ADDI_VARS \
196 #define EXTRACT_IFMT_ADDI_CODE \
198 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
199 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
200 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
201 f_imm = EXTRACT_LSB0_SINT (insn, 32, 15, 16); \
203 #define EXTRACT_IFMT_ANDI_VARS \
209 #define EXTRACT_IFMT_ANDI_CODE \
211 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
212 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
213 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
214 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
216 #define EXTRACT_IFMT_ANDHII_VARS \
222 #define EXTRACT_IFMT_ANDHII_CODE \
224 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
225 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
226 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
227 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
229 #define EXTRACT_IFMT_B_VARS \
236 #define EXTRACT_IFMT_B_CODE \
238 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
239 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
240 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
241 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
242 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
244 #define EXTRACT_IFMT_BI_VARS \
248 #define EXTRACT_IFMT_BI_CODE \
250 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
251 f_call = ((pc) + (((((((((EXTRACT_LSB0_SINT (insn, 32, 25, 26)) & (67108863))) << (2))) ^ (134217728))) - (134217728)))); \
253 #define EXTRACT_IFMT_BE_VARS \
259 #define EXTRACT_IFMT_BE_CODE \
261 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
262 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
263 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
264 f_branch = ((pc) + (((((((((EXTRACT_LSB0_SINT (insn, 32, 15, 16)) & (65535))) << (2))) ^ (131072))) - (131072)))); \
266 #define EXTRACT_IFMT_ORI_VARS \
272 #define EXTRACT_IFMT_ORI_CODE \
274 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
275 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
276 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
277 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
279 #define EXTRACT_IFMT_RCSR_VARS \
286 #define EXTRACT_IFMT_RCSR_CODE \
288 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
289 f_csr = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
290 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
291 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
292 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
294 #define EXTRACT_IFMT_SEXTB_VARS \
301 #define EXTRACT_IFMT_SEXTB_CODE \
303 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
304 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
305 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
306 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
307 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
309 #define EXTRACT_IFMT_USER_VARS \
316 #define EXTRACT_IFMT_USER_CODE \
318 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
319 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
320 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
321 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
322 f_user = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
324 #define EXTRACT_IFMT_WCSR_VARS \
331 #define EXTRACT_IFMT_WCSR_CODE \
333 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
334 f_csr = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
335 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
336 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
337 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
339 #define EXTRACT_IFMT_BREAK_VARS \
343 #define EXTRACT_IFMT_BREAK_CODE \
345 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
346 f_exception = EXTRACT_LSB0_UINT (insn, 32, 25, 26); \
348 /* Collection of various things for the trace handler to use. */
350 typedef struct trace_record
{
355 #endif /* CPU_LM32BF_H */