aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunsup Lee <yunsup@cs.berkeley.edu>2014-02-25 03:44:34 -0800
committerYunsup Lee <yunsup@cs.berkeley.edu>2014-02-25 03:44:34 -0800
commit0a048a93ebdab87473fcb50bc647e84098693cd0 (patch)
tree1ad16662dd69ca8f638b859b59eef4b8d2ad82f2
parentd47f8ca5b63274404b7d4dde68ab10390cca786e (diff)
downloadriscv-isa-sim-0a048a93ebdab87473fcb50bc647e84098693cd0.zip
riscv-isa-sim-0a048a93ebdab87473fcb50bc647e84098693cd0.tar.gz
riscv-isa-sim-0a048a93ebdab87473fcb50bc647e84098693cd0.tar.bz2
add extensions to riscv-dis for better disassembly
-rw-r--r--riscv/riscv-dis.cc17
1 files changed, 16 insertions, 1 deletions
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 <iostream>
#include <string>
#include <cstdint>
+#include <fesvr/option_parser.h>
using namespace std;
-int main()
+int main(int argc, char** argv)
{
string s;
disassembler_t d;
+ std::function<extension_t*()> 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; )