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 always_true_p(const RISCVCPUConfig * cfg)34static inline bool always_true_p(const RISCVCPUConfig *cfg __attribute__((__unused__))) 35 { 36 return true; 37 } 38 has_xthead_p(const RISCVCPUConfig * cfg)39static inline bool has_xthead_p(const RISCVCPUConfig *cfg) 40 { 41 return cfg->ext_xtheadba || cfg->ext_xtheadbb || 42 cfg->ext_xtheadbs || cfg->ext_xtheadcmo || 43 cfg->ext_xtheadcondmov || 44 cfg->ext_xtheadfmemidx || cfg->ext_xtheadfmv || 45 cfg->ext_xtheadmac || cfg->ext_xtheadmemidx || 46 cfg->ext_xtheadmempair || cfg->ext_xtheadsync; 47 } 48 49 #define MATERIALISE_EXT_PREDICATE(ext) \ 50 static inline bool has_ ## ext ## _p(const RISCVCPUConfig *cfg) \ 51 { \ 52 return cfg->ext_ ## ext ; \ 53 } 54 55 MATERIALISE_EXT_PREDICATE(xtheadba) 56 MATERIALISE_EXT_PREDICATE(xtheadbb) 57 MATERIALISE_EXT_PREDICATE(xtheadbs) 58 MATERIALISE_EXT_PREDICATE(xtheadcmo) 59 MATERIALISE_EXT_PREDICATE(xtheadcondmov) 60 MATERIALISE_EXT_PREDICATE(xtheadfmemidx) 61 MATERIALISE_EXT_PREDICATE(xtheadfmv) 62 MATERIALISE_EXT_PREDICATE(xtheadmac) 63 MATERIALISE_EXT_PREDICATE(xtheadmemidx) 64 MATERIALISE_EXT_PREDICATE(xtheadmempair) 65 MATERIALISE_EXT_PREDICATE(xtheadsync) 66 MATERIALISE_EXT_PREDICATE(XVentanaCondOps) 67 68 #endif 69