From d2bbb60aace5ff1c851bc769f47b87d480cd19ad Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 8 Nov 2021 21:24:56 -0800 Subject: [PATCH 1/2] Revert "Disable clang PCH when boost is present" This reverts commit 4f129845021b6086fd259186b0bc09203f5f8069. --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index f964e19e..9b1176c4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -38,7 +38,7 @@ scripts_dir := $(src_dir)/scripts HAVE_INT128 := @HAVE_INT128@ HAVE_DLOPEN := @HAVE_DLOPEN@ -HAVE_CLANG_PCH := $(and @HAVE_CLANG_PCH@, $(if @BOOST_ASIO_LIB@,,yes)) +HAVE_CLANG_PCH := @HAVE_CLANG_PCH@ # If the version information is not in the configure script, then we # assume that we are in a working directory. We use the vcs-version.sh From ad96b52e18a51519b57509ab1964c43ba9559c07 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 8 Nov 2021 22:03:07 -0800 Subject: [PATCH 2/2] Move definitions of P and require macros Avoids namespace conflicts with Boost. Fixes #820 in a better way. --- customext/cflush.cc | 1 + riscv/csrs.cc | 2 ++ riscv/decode.h | 2 -- riscv/insn_macros.h | 9 +++++++++ riscv/insn_template.cc | 1 + riscv/interactive.cc | 8 ++++---- 6 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 riscv/insn_macros.h diff --git a/customext/cflush.cc b/customext/cflush.cc index dedcc037..640c29fc 100644 --- a/customext/cflush.cc +++ b/customext/cflush.cc @@ -1,3 +1,4 @@ +#include "insn_macros.h" #include "extension.h" #include diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 4e540658..29b4bc90 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -8,6 +8,8 @@ #include "decode.h" // For trap_virtual_instruction and trap_illegal_instruction: #include "trap.h" +// For require(): +#include "insn_macros.h" // STATE macro used by require_privilege() macro: #undef STATE diff --git a/riscv/decode.h b/riscv/decode.h index 191bf03a..0ed7f374 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -174,7 +174,6 @@ private: // helpful macros, etc #define MMU (*p->get_mmu()) #define STATE (*p->get_state()) -#define P (*p) #define FLEN (p->get_flen()) #define READ_REG(reg) STATE.XPR[reg] #define READ_FREG(reg) STATE.FPR[reg] @@ -241,7 +240,6 @@ private: #define get_field(reg, mask) (((reg) & (decltype(reg))(mask)) / ((mask) & ~((mask) << 1))) #define set_field(reg, mask, val) (((reg) & ~(decltype(reg))(mask)) | (((decltype(reg))(val) * ((mask) & ~((mask) << 1))) & (decltype(reg))(mask))) -#define require(x) do { if (unlikely(!(x))) throw trap_illegal_instruction(insn.bits()); } while (0) #define require_privilege(p) require(STATE.prv >= (p)) #define require_novirt() if (unlikely(STATE.v)) throw trap_virtual_instruction(insn.bits()) #define require_rv64 require(xlen == 64) diff --git a/riscv/insn_macros.h b/riscv/insn_macros.h new file mode 100644 index 00000000..2fdfcedc --- /dev/null +++ b/riscv/insn_macros.h @@ -0,0 +1,9 @@ +#ifndef _RISCV_INSN_MACROS_H +#define _RISCV_INSN_MACROS_H + +// These conflict with Boost headers so can't be included from insn_template.h +#define P (*p) + +#define require(x) do { if (unlikely(!(x))) throw trap_illegal_instruction(insn.bits()); } while (0) + +#endif diff --git a/riscv/insn_template.cc b/riscv/insn_template.cc index 9d570f99..b3dd3302 100644 --- a/riscv/insn_template.cc +++ b/riscv/insn_template.cc @@ -1,6 +1,7 @@ // See LICENSE for license details. #include "insn_template.h" +#include "insn_macros.h" reg_t rv32_NAME(processor_t* p, insn_t insn, reg_t pc) { diff --git a/riscv/interactive.cc b/riscv/interactive.cc index d0f6b4e2..dc6837d2 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -353,19 +353,19 @@ void sim_t::interactive_vreg(const std::string& cmd, const std::vector(r, e); + val = p->VU.elt(r, e); out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(16) << val << " "; break; case 4: - val = P.VU.elt(r, e); + val = p->VU.elt(r, e); out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint32_t)val << " "; break; case 2: - val = P.VU.elt(r, e); + val = p->VU.elt(r, e); out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint16_t)val << " "; break; case 1: - val = P.VU.elt(r, e); + val = p->VU.elt(r, e); out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (int)(uint8_t)val << " "; break; }