1 /* CPU family header for lm32bf.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996-2016 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, see <http://www.gnu.org/licenses/>.
27 /* Maximum number of instructions that are fetched at a time.
28 This is for LIW type instructions sets (e.g. m32r). */
29 #define MAX_LIW_INSNS 1
31 /* Maximum number of instructions that can be executed in parallel. */
32 #define MAX_PARALLEL_INSNS 1
34 /* The size of an "int" needed to hold an instruction word.
35 This is usually 32 bits, but some architectures needs 64 bits. */
36 typedef CGEN_INSN_INT CGEN_INSN_WORD;
38 #include "cgen-engine.h"
40 /* CPU state information. */
42 /* Hardware elements. */
46 #define GET_H_PC() CPU (h_pc)
47 #define SET_H_PC(x) (CPU (h_pc) = (x))
48 /* General purpose registers */
50 #define GET_H_GR(a1) CPU (h_gr)[a1]
51 #define SET_H_GR(a1, x) (CPU (h_gr)[a1] = (x))
52 /* Control and status registers */
54 #define GET_H_CSR(a1) CPU (h_csr)[a1]
55 #define SET_H_CSR(a1, x) (CPU (h_csr)[a1] = (x))
57 #define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)
60 /* Cover fns for register access. */
61 USI lm32bf_h_pc_get (SIM_CPU *);
62 void lm32bf_h_pc_set (SIM_CPU *, USI);
63 SI lm32bf_h_gr_get (SIM_CPU *, UINT);
64 void lm32bf_h_gr_set (SIM_CPU *, UINT, SI);
65 SI lm32bf_h_csr_get (SIM_CPU *, UINT);
66 void lm32bf_h_csr_set (SIM_CPU *, UINT, SI);
68 /* These must be hand-written. */
69 extern CPUREG_FETCH_FN lm32bf_fetch_register;
70 extern CPUREG_STORE_FN lm32bf_store_register;
76 /* Instruction argument buffer. */
79 struct { /* no operands */
115 /* Writeback handler. */
117 /* Pointer to argbuf entry for insn whose results need writing back. */
118 const struct argbuf *abuf;
120 /* x-before handler */
122 /*const SCACHE *insns[MAX_PARALLEL_INSNS];*/
125 /* x-after handler */
129 /* This entry is used to terminate each pbb. */
131 /* Number of insns in pbb. */
133 /* Next pbb to execute. */
135 SCACHE *branch_target;
140 /* The ARGBUF struct. */
142 /* These are the baseclass definitions. */
147 /* ??? Temporary hack for skip insns. */
150 /* cpu specific data follows */
153 union sem_fields fields;
158 ??? SCACHE used to contain more than just argbuf. We could delete the
159 type entirely and always just use ARGBUF, but for future concerns and as
160 a level of abstraction it is left in. */
163 struct argbuf argbuf;
166 /* Macros to simplify extraction, reading and semantic code.
167 These define and assign the local vars that contain the insn's fields. */
169 #define EXTRACT_IFMT_EMPTY_VARS \
171 #define EXTRACT_IFMT_EMPTY_CODE \
174 #define EXTRACT_IFMT_ADD_VARS \
181 #define EXTRACT_IFMT_ADD_CODE \
183 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
184 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
185 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
186 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
187 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
189 #define EXTRACT_IFMT_ADDI_VARS \
195 #define EXTRACT_IFMT_ADDI_CODE \
197 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
198 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
199 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
200 f_imm = EXTRACT_LSB0_SINT (insn, 32, 15, 16); \
202 #define EXTRACT_IFMT_ANDI_VARS \
208 #define EXTRACT_IFMT_ANDI_CODE \
210 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
211 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
212 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
213 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
215 #define EXTRACT_IFMT_ANDHII_VARS \
221 #define EXTRACT_IFMT_ANDHII_CODE \
223 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
224 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
225 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
226 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
228 #define EXTRACT_IFMT_B_VARS \
235 #define EXTRACT_IFMT_B_CODE \
237 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
238 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
239 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
240 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
241 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
243 #define EXTRACT_IFMT_BI_VARS \
247 #define EXTRACT_IFMT_BI_CODE \
249 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
250 f_call = ((pc) + (((SI) (((EXTRACT_LSB0_SINT (insn, 32, 25, 26)) << (6))) >> (4)))); \
252 #define EXTRACT_IFMT_BE_VARS \
258 #define EXTRACT_IFMT_BE_CODE \
260 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
261 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
262 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
263 f_branch = ((pc) + (((SI) (((EXTRACT_LSB0_SINT (insn, 32, 15, 16)) << (16))) >> (14)))); \
265 #define EXTRACT_IFMT_ORI_VARS \
271 #define EXTRACT_IFMT_ORI_CODE \
273 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
274 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
275 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
276 f_uimm = EXTRACT_LSB0_UINT (insn, 32, 15, 16); \
278 #define EXTRACT_IFMT_RCSR_VARS \
285 #define EXTRACT_IFMT_RCSR_CODE \
287 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
288 f_csr = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
289 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
290 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
291 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
293 #define EXTRACT_IFMT_SEXTB_VARS \
300 #define EXTRACT_IFMT_SEXTB_CODE \
302 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
303 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
304 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
305 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
306 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
308 #define EXTRACT_IFMT_USER_VARS \
315 #define EXTRACT_IFMT_USER_CODE \
317 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
318 f_r0 = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
319 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
320 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
321 f_user = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
323 #define EXTRACT_IFMT_WCSR_VARS \
330 #define EXTRACT_IFMT_WCSR_CODE \
332 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
333 f_csr = EXTRACT_LSB0_UINT (insn, 32, 25, 5); \
334 f_r1 = EXTRACT_LSB0_UINT (insn, 32, 20, 5); \
335 f_r2 = EXTRACT_LSB0_UINT (insn, 32, 15, 5); \
336 f_resv0 = EXTRACT_LSB0_UINT (insn, 32, 10, 11); \
338 #define EXTRACT_IFMT_BREAK_VARS \
342 #define EXTRACT_IFMT_BREAK_CODE \
344 f_opcode = EXTRACT_LSB0_UINT (insn, 32, 31, 6); \
345 f_exception = EXTRACT_LSB0_UINT (insn, 32, 25, 26); \
347 /* Collection of various things for the trace handler to use. */
349 typedef struct trace_record {
354 #endif /* CPU_LM32BF_H */