From: Yunsup Lee Date: Tue, 25 Feb 2014 11:44:34 +0000 (-0800) Subject: add extensions to riscv-dis for better disassembly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a048a93ebdab87473fcb50bc647e84098693cd0;p=riscv-isa-sim.git add extensions to riscv-dis for better disassembly --- diff --git a/riscv/riscv-dis.cc b/riscv/riscv-dis.cc index fdeb69f..1b958df 100644 --- a/riscv/riscv-dis.cc +++ b/riscv/riscv-dis.cc @@ -7,16 +7,31 @@ // instruction. #include "disasm.h" +#include "extension.h" #include #include #include +#include using namespace std; -int main() +int main(int argc, char** argv) { string s; disassembler_t d; + std::function extension; + option_parser_t parser; + parser.option(0, "extension", 1, [&](const char* s){ + if (!extensions().count(s)) + fprintf(stderr, "unknown extension %s!\n", s), exit(-1); + extension = extensions()[s]; + + for (auto disasm_insn : extension()->get_disasms()) + d.add_insn(disasm_insn); + }); + + auto argv1 = parser.parse(argv); + while (getline(cin, s)) { for (size_t start = 0; (start = s.find("DASM(", start)) != string::npos; )