Skip to content

Commit

Permalink
Merge pull request #1409 from riscv-software-src/ext-symbols
Browse files Browse the repository at this point in the history
Add all symbols from extension.o to spike main
  • Loading branch information
jerryz123 authored Jul 13, 2023
2 parents ed5dccb + 3b0d3c2 commit e85d292
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ $$($(2)_test_objs) : %.o : %.cc
$(COMPILE) -c $$<

$$($(2)_test_exes) : %-utst : %.t.o $$($(2)_test_libnames)
$(LINK) -o $$@ $$< $$($(2)_test_libnames) $(LIBS)
$(LINK) $$($(2)_LDFLAGS) -o $$@ $$< $$($(2)_test_libnames) $(LIBS)

$(2)_deps += $$($(2)_test_deps)
$(2)_junk += \
Expand Down Expand Up @@ -292,7 +292,7 @@ $$($(2)_prog_objs) : %.o : %.cc
$(COMPILE) -c $$<

$$($(2)_prog_exes) : % : %.o $$($(2)_prog_libnames)
$(LINK) -o $$@ $$< $$($(2)_prog_libnames) $(LIBS)
$(LINK) $$($(2)_LDFLAGS) -o $$@ $$< $$($(2)_prog_libnames) $(LIBS)

$(2)_deps += $$($(2)_prog_deps)
$(2)_junk += $$($(2)_prog_objs) $$($(2)_prog_deps) $$($(2)_prog_exes)
Expand All @@ -307,7 +307,7 @@ $$($(2)_install_prog_objs) : %.o : %.cc $$($(2)_gen_hdrs)
$(COMPILE) -c $$<

$$($(2)_install_prog_exes) : % : %.o $$($(2)_prog_libnames)
$(LINK) -o $$@ $$< $$($(2)_prog_libnames) $(LIBS)
$(LINK) $$($(2)_LDFLAGS) -o $$@ $$< $$($(2)_prog_libnames) $(LIBS)

$(2)_deps += $$($(2)_install_prog_deps)
$(2)_junk += \
Expand Down
1 change: 1 addition & 0 deletions disasm/disasm.mk.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
disasm_srcs = \
disasm.cc \
isa_parser.cc \
regnames.cc \

disasm_install_lib = yes
Expand Down
7 changes: 1 addition & 6 deletions riscv/isa_parser.cc → disasm/isa_parser.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "isa_parser.h"
#include "extension.h"

static std::string strtolower(const char* str)
{
Expand Down Expand Up @@ -292,11 +291,7 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
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 (!extensions.insert(std::make_pair(x->name(), x)).second) {
fprintf(stderr, "extensions must have unique names (got two named \"%s\"!)\n", x->name());
abort();
}
extensions.insert(ext_str.substr(1));
}
} else {
bad_isa_string(str, ("unsupported extension: " + ext_str).c_str());
Expand Down
9 changes: 3 additions & 6 deletions riscv/isa_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

#include <bitset>
#include <string>
#include <unordered_map>

class extension_t;
#include <set>

typedef enum {
// 65('A') ~ 90('Z') is reserved for standard isa in misa
Expand Down Expand Up @@ -109,15 +107,14 @@ class isa_parser_t {

std::bitset<NUM_ISA_EXTENSIONS> get_extension_table() const { return extension_table; }

const std::unordered_map<std::string, extension_t*> &
get_extensions() const { return extensions; }
const std::set<std::string> &get_extensions() const { return extensions; }

protected:
unsigned max_xlen;
reg_t max_isa;
std::bitset<NUM_ISA_EXTENSIONS> extension_table;
std::string isa_string;
std::unordered_map<std::string, extension_t*> extensions;
std::set<std::string> extensions;
};

#endif
2 changes: 1 addition & 1 deletion riscv/processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ processor_t::processor_t(const isa_parser_t *isa, const cfg_t *cfg,

disassembler = new disassembler_t(isa);
for (auto e : isa->get_extensions())
register_extension(e.second);
register_extension(find_extension(e.c_str())());

set_pmp_granularity(1 << PMP_SHIFT);
set_pmp_num(cfg->pmpregions);
Expand Down
1 change: 0 additions & 1 deletion riscv/riscv.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ riscv_precompiled_hdrs = \
insn_template.h \

riscv_srcs = \
isa_parser.cc \
processor.cc \
execute.cc \
dts.cc \
Expand Down
4 changes: 4 additions & 0 deletions spike_main/spike_main.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ spike_main_install_prog_srcs = \
spike_main_srcs = \

spike_main_CFLAGS = -fPIC

# This hack adds all symbols from extension.o to spike's dynamic symbol
# table, which is required for dynamically loaded --extension libraries
spike_main_LDFLAGS = extension.o

0 comments on commit e85d292

Please sign in to comment.