Skip to content

Commit

Permalink
[snippy][model] Update model interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
dybv-sc authored and asi-sc committed Dec 26, 2024
1 parent a5ff3e7 commit de5b30d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
14 changes: 9 additions & 5 deletions llvm/tools/llvm-snippy/Model/RISCVModel/RVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {

#define RVMAPI_ENTRY_POINT_SYMBOL RVMVTable
#define RVMAPI_VERSION_SYMBOL RVMInterfaceVersion
#define RVMAPI_CURRENT_INTERFACE_VERSION 21u
#define RVMAPI_CURRENT_INTERFACE_VERSION 22u

typedef uint64_t RVMRegT;

Expand Down Expand Up @@ -357,11 +357,15 @@ typedef void (*VRegUpdateCallbackTy)(RVMCallbackHandler *, RVMVReg Reg,
const char *Data, size_t Size);
typedef void (*PCUpdateCallbackTy)(RVMCallbackHandler *, uint64_t PC);

struct RVMMemoryRegion {
uint64_t Start;
uint64_t Size;
const char *Name;
};

struct RVMConfig {
uint64_t RomStart;
uint64_t RomSize;
uint64_t RamStart;
uint64_t RamSize;
const struct RVMMemoryRegion *MemoryRegions;
unsigned MemoryRegionCount;
int RV64;
unsigned VLEN;
int EnableMisalignedAccess;
Expand Down
30 changes: 13 additions & 17 deletions llvm/tools/llvm-snippy/Model/RISCVModel/RVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <memory>
#include <sstream>
#include <string>
#include <vector>

namespace rvm {
namespace detail {
Expand Down Expand Up @@ -190,6 +191,8 @@ class State {
RVMConfig Config = {};
const RVM_FunctionPointers *VTable;

std::vector<RVMMemoryRegion> MemoryRegions;
std::vector<std::string> MemoryRegionNames;
std::string LogFilePath;
std::string PluginInfo;

Expand All @@ -204,23 +207,16 @@ class State {
Builder &operator=(Builder &&OldBuild) = default;
~Builder() = default;

Builder &setRomStart(uint64_t Start) {
Config.RomStart = Start;
return *this;
}

Builder &setRomSize(uint64_t Size) {
Config.RomSize = Size;
return *this;
}

Builder &setRamStart(uint64_t Start) {
Config.RamStart = Start;
return *this;
}

Builder &setRamSize(uint64_t Size) {
Config.RamSize = Size;
Builder &addMemoryRegion(uint64_t Start, uint64_t Size, const char *Name) {
RVMMemoryRegion Region{Start, Size, nullptr};
if (Name) {
MemoryRegionNames.emplace_back(Name);
auto &NameStr = MemoryRegionNames.back();
Region.Name = NameStr.c_str();
}
MemoryRegions.push_back(Region);
Config.MemoryRegions = &MemoryRegions.front();
Config.MemoryRegionCount = MemoryRegions.size();
return *this;
}

Expand Down

0 comments on commit de5b30d

Please sign in to comment.