aboutsummaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2020-06-10 15:37:00 -0700
committerGitHub <noreply@github.com>2020-06-10 15:37:00 -0700
commitc520402ad3be05ba7e2755cddd985db8d8526dec (patch)
tree591b88178e1dcd98f60e9078044fa9b1579c9a6c /riscv
parente66d7698d0a250fb29a1a3263223e5ccc80894ad (diff)
parent2c5e60b5fc0f1eaf94fdae03f8379a7ddd807423 (diff)
downloadspike-c520402ad3be05ba7e2755cddd985db8d8526dec.zip
spike-c520402ad3be05ba7e2755cddd985db8d8526dec.tar.gz
spike-c520402ad3be05ba7e2755cddd985db8d8526dec.tar.bz2
Merge pull request #485 from chihminchao/custom-ext
Custom ext
Diffstat (limited to 'riscv')
-rw-r--r--riscv/extensions.cc19
-rw-r--r--riscv/processor.cc10
-rw-r--r--riscv/riscv.mk.in2
3 files changed, 23 insertions, 8 deletions
diff --git a/riscv/extensions.cc b/riscv/extensions.cc
index d1690c4..347dc5e 100644
--- a/riscv/extensions.cc
+++ b/riscv/extensions.cc
@@ -21,14 +21,23 @@ std::function<extension_t*()> find_extension(const char* name)
if (!extensions().count(name)) {
// try to find extension xyz by loading libxyz.so
std::string libname = std::string("lib") + name + ".so";
- if (!dlopen(libname.c_str(), RTLD_LAZY)) {
- fprintf(stderr, "couldn't find extension '%s' (or library '%s')\n",
- name, libname.c_str());
- exit(-1);
+ std::string libdefault = "libcustomext.so";
+ bool is_default = false;
+ auto dlh = dlopen(libname.c_str(), RTLD_LAZY);
+ if (!dlh) {
+ dlh = dlopen(libdefault.c_str(), RTLD_LAZY);
+ if (!dlh) {
+ fprintf(stderr, "couldn't find shared library either '%s' or '%s')\n",
+ libname.c_str(), libdefault.c_str());
+ exit(-1);
+ }
+
+ is_default = true;
}
+
if (!extensions().count(name)) {
fprintf(stderr, "couldn't find extension '%s' in shared library '%s'\n",
- name, libname.c_str());
+ name, is_default ? libdefault.c_str() : libname.c_str());
exit(-1);
}
}
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 0b4ca65..deaadae 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -237,7 +237,7 @@ void processor_t::parse_isa_string(const char* str)
p++;
} else if (*p == 'x') {
const char* ext = p + 1, *end = ext;
- while (islower(*end))
+ while (islower(*end) || *end == '_')
end++;
auto ext_str = std::string(ext, end - ext);
@@ -251,6 +251,11 @@ void processor_t::parse_isa_string(const char* str)
}
} else if (*p == '_') {
const char* ext = p + 1, *end = ext;
+ if (*ext == 'x') {
+ p++;
+ continue;
+ }
+
while (islower(*end))
end++;
@@ -1207,8 +1212,7 @@ void processor_t::register_extension(extension_t* x)
for (auto insn : x->get_instructions())
register_insn(insn);
build_opcode_map();
- for (auto disasm_insn : x->get_disasms())
- disassembler->add_insn(disasm_insn);
+
if (ext != NULL)
throw std::logic_error("only one extension may be registered");
ext = x;
diff --git a/riscv/riscv.mk.in b/riscv/riscv.mk.in
index 6f89103..175ab68 100644
--- a/riscv/riscv.mk.in
+++ b/riscv/riscv.mk.in
@@ -7,6 +7,8 @@ riscv_subproject_deps = \
riscv_install_prog_srcs = \
+riscv_CFLAGS = -fPIC
+
riscv_hdrs = \
common.h \
decode.h \