Browse Source

Merge pull request #937 from plctlab/plct-segfault-fix

add missed extensions specified by '--extension' to custom_extensions
pull/939/head
Andrew Waterman 4 years ago
committed by GitHub
parent
commit
5dd71bce9c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      customext/cflush.cc
  2. 9
      riscv/processor.cc
  3. 2
      riscv/processor.h
  4. 8
      riscv/rocc.cc

6
customext/cflush.cc

@ -24,9 +24,9 @@ class cflush_t : public extension_t
std::vector<insn_desc_t> get_instructions() {
std::vector<insn_desc_t> insns;
insns.push_back((insn_desc_t){0xFC000073, 0xFFF07FFF, custom_cflush, custom_cflush});
insns.push_back((insn_desc_t){0xFC200073, 0xFFF07FFF, custom_cflush, custom_cflush});
insns.push_back((insn_desc_t){0xFC100073, 0xFFF07FFF, custom_cflush, custom_cflush});
insns.push_back((insn_desc_t){0xFC000073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
insns.push_back((insn_desc_t){0xFC200073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
insns.push_back((insn_desc_t){0xFC100073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
return insns;
}

9
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);
@ -381,11 +381,10 @@ isa_parser_t::isa_parser_t(const char* str)
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) {
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);
}

2
riscv/processor.h

@ -326,7 +326,7 @@ protected:
reg_t max_isa;
std::vector<bool> extension_table;
std::string isa_string;
std::unordered_map<std::string, extension_t*> custom_extensions;
std::unordered_map<std::string, extension_t*> isa_extensions;
};
// this class represents one processor in a RISC-V machine.

8
riscv/rocc.cc

@ -32,10 +32,10 @@ customX(3)
std::vector<insn_desc_t> rocc_t::get_instructions()
{
std::vector<insn_desc_t> insns;
insns.push_back((insn_desc_t){0x0b, 0x7f, &::illegal_instruction, c0});
insns.push_back((insn_desc_t){0x2b, 0x7f, &::illegal_instruction, c1});
insns.push_back((insn_desc_t){0x5b, 0x7f, &::illegal_instruction, c2});
insns.push_back((insn_desc_t){0x7b, 0x7f, &::illegal_instruction, c3});
insns.push_back((insn_desc_t){0x0b, 0x7f, &::illegal_instruction, c0, &::illegal_instruction, c0});
insns.push_back((insn_desc_t){0x2b, 0x7f, &::illegal_instruction, c1, &::illegal_instruction, c1});
insns.push_back((insn_desc_t){0x5b, 0x7f, &::illegal_instruction, c2, &::illegal_instruction, c2});
insns.push_back((insn_desc_t){0x7b, 0x7f, &::illegal_instruction, c3, &::illegal_instruction, c3});
return insns;
}

Loading…
Cancel
Save