master
h 74 lines 2.31 KB
Raw
1 /*
2 * QEMU RISC-V CPU CFG
3 *
4 * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
5 * Copyright (c) 2017-2018 SiFive, Inc.
6 * Copyright (c) 2021-2023 PLCT Lab
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2 or later, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef RISCV_CPU_CFG_H
22 #define RISCV_CPU_CFG_H
23
24 struct RISCVCPUConfig {
25 #define BOOL_FIELD(x) bool x;
26 #define TYPED_FIELD(type, x, default) type x;
27 #include "cpu_cfg_fields.h.inc"
28 };
29
30 typedef struct RISCVCPUConfig RISCVCPUConfig;
31
32 /* Helper functions to test for extensions. */
33
34 static inline bool always_true_p(const RISCVCPUConfig *cfg __attribute__((__unused__)))
35 {
36 return true;
37 }
38
39 static inline bool has_xmips_p(const RISCVCPUConfig *cfg)
40 {
41 return cfg->ext_xmipscbop || cfg->ext_xmipscmov || cfg->ext_xmipslsp;
42 }
43
44 static inline bool has_xthead_p(const RISCVCPUConfig *cfg)
45 {
46 return cfg->ext_xtheadba || cfg->ext_xtheadbb ||
47 cfg->ext_xtheadbs || cfg->ext_xtheadcmo ||
48 cfg->ext_xtheadcondmov ||
49 cfg->ext_xtheadfmemidx || cfg->ext_xtheadfmv ||
50 cfg->ext_xtheadmac || cfg->ext_xtheadmemidx ||
51 cfg->ext_xtheadmempair || cfg->ext_xtheadsync;
52 }
53
54 #define MATERIALISE_EXT_PREDICATE(ext) \
55 static inline bool has_ ## ext ## _p(const RISCVCPUConfig *cfg) \
56 { \
57 return cfg->ext_ ## ext ; \
58 }
59
60 MATERIALISE_EXT_PREDICATE(xtheadba)
61 MATERIALISE_EXT_PREDICATE(xtheadbb)
62 MATERIALISE_EXT_PREDICATE(xtheadbs)
63 MATERIALISE_EXT_PREDICATE(xtheadcmo)
64 MATERIALISE_EXT_PREDICATE(xtheadcondmov)
65 MATERIALISE_EXT_PREDICATE(xtheadfmemidx)
66 MATERIALISE_EXT_PREDICATE(xtheadfmv)
67 MATERIALISE_EXT_PREDICATE(xtheadmac)
68 MATERIALISE_EXT_PREDICATE(xtheadmemidx)
69 MATERIALISE_EXT_PREDICATE(xtheadmempair)
70 MATERIALISE_EXT_PREDICATE(xtheadsync)
71 MATERIALISE_EXT_PREDICATE(XVentanaCondOps)
72 MATERIALISE_EXT_PREDICATE(xlrbr);
73
74 #endif