From 38f085d2fc96fb7fb4c4a60834617446e424f23d Mon Sep 17 00:00:00 2001 From: Weiwei Li Date: Sat, 26 Feb 2022 13:18:39 +0800 Subject: [PATCH] add missed extensions specified by '--extension' to custom_extensions --- riscv/processor.cc | 17 ++++++++++------- riscv/processor.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/riscv/processor.cc b/riscv/processor.cc index 947eab5a..f20ac6ac 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -47,7 +47,7 @@ processor_t::processor_t(const char* isa, const char* priv, const char* varch, mmu = new mmu_t(sim, this); disassembler = new disassembler_t(this); - for (auto e : custom_extensions) + for (auto e : isa_extensions) register_extension(e.second); set_pmp_granularity(1 << PMP_SHIFT); @@ -380,12 +380,11 @@ isa_parser_t::isa_parser_t(const char* str) } else if (ext_str.size() == 1) { bad_isa_string(str, "single 'X' is not a proper name"); } else if (ext_str != "xdummy") { - extension_t* x = find_extension(ext_str.substr(1).c_str())(); - if (!custom_extensions.insert(std::make_pair(x->name(), x)).second) { - fprintf(stderr, "extensions must have unique names (got two named \"%s\"!)\n", x->name()); - abort(); - } - + extension_t* x = find_extension(ext_str.substr(1).c_str())(); + if (!isa_extensions.insert(std::make_pair(x->name(), x)).second) { + fprintf(stderr, "extensions must have unique names (got two named \"%s\"!)\n", x->name()); + abort(); + } } } else { bad_isa_string(str, ("unsupported extension: " + ext_str).c_str()); @@ -1157,6 +1156,10 @@ void processor_t::register_extension(extension_t* x) for (auto disasm_insn : x->get_disasms()) disassembler->add_insn(disasm_insn); + if (!custom_extensions.insert(std::make_pair(x->name(), x)).second) { + fprintf(stderr, "extensions must have unique names (got two named \"%s\"!)\n", x->name()); + abort(); + } x->set_processor(this); } diff --git a/riscv/processor.h b/riscv/processor.h index 9ee3e6c8..9833cfac 100644 --- a/riscv/processor.h +++ b/riscv/processor.h @@ -326,7 +326,7 @@ protected: reg_t max_isa; std::vector extension_table; std::string isa_string; - std::unordered_map custom_extensions; + std::unordered_map isa_extensions; }; // this class represents one processor in a RISC-V machine.