Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backends/cpp_hart_gen/templates/hart.hxx.erb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,20 @@ namespace udb {
bool _decode(const XReg& pc, const Bits<<%= cfg_arch.largest_encoding %>>& encoding, InstBase* obj);

uint64_t fetch() override { return _fetch().get(); }

void execute_instruction(const Bits<32>& encoding) {
InstBase* inst = reinterpret_cast<InstBase*>(m_execute_instruction_storage.data());
if (!_decode(m_pc, encoding, inst)) {
try {
raise(ExceptionCode{ExceptionCode::IllegalInstruction}, mode(), encoding);
} catch (const AbortInstruction&) {
throw; // propagate to outer instruction handler
}
return;
}
inst->execute();
// Note: PC is NOT advanced here; the calling instruction manages PC.
}
PossiblyUnknownBits<INSTR_ENC_SIZE.get()> _fetch();
void ifence() override {
m_bb_cache.invalidate();
Expand Down Expand Up @@ -501,6 +515,7 @@ namespace udb {
std::map<std::string, CsrBase*> m_csr_name_map;

std::array<uint8_t, __MAX_INST_CPP_SIZE> m_run_one_inst_storage;
std::array<uint8_t, __MAX_INST_CPP_SIZE> m_execute_instruction_storage;
BasicBlockCache<__MAX_INST_CPP_SIZE> m_bb_cache;
};
}
Expand Down
17 changes: 17 additions & 0 deletions spec/std/isa/isa/builtin_functions.idl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ builtin function ebreak {
}
}

builtin function execute_instruction {
arguments
Bits<32> encoding
description {
Fetch and execute the instruction with the given 32-bit encoding in the current hart
context. The instruction executes as if it were a normal instruction, with the
following differences:

* The PC is not advanced after execution (the calling instruction is responsible
for PC management).
* If the instruction raises an exception, the exception propagates normally.

This builtin is intended for use by instructions that dynamically dispatch
sub-instructions fetched from memory (e.g., instruction lookup table instructions).
}
}

builtin function prefetch_instruction {
arguments
XReg virtual_address # virtual cache block address
Expand Down
Loading