Skip to content

Commit

Permalink
[snippy] removed setting pc before register dump after execution of s…
Browse files Browse the repository at this point in the history
…nippet
  • Loading branch information
vbe-sc authored and asi-sc committed Apr 25, 2024
1 parent 8638f23 commit a2b5932
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
5 changes: 2 additions & 3 deletions llvm/tools/llvm-snippy/include/snippy/Generator/SimRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ class SimRunner {
return *CoInterp.front();
}

// Preform co-simulation run and returns PC before final instruction.
// Preform co-simulation run.
// Each interpreter state will be reset before run.
ProgramCounterType run(StringRef Programm,
const IRegisterState &InitialRegState);
void run(StringRef Programm, const IRegisterState &InitialRegState);

// Adds output section name to the sim config
// in order to load it later to the model before execution.
Expand Down
3 changes: 1 addition & 2 deletions llvm/tools/llvm-snippy/lib/Generator/GeneratorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ void GeneratorContext::runSimulator(StringRef ImageToRun) {

auto &SimRunner = getOrCreateSimRunner();

auto FinalPC = SimRunner.run(ImageToRun, InitRegState);
SimRunner.run(ImageToRun, InitRegState);

I.setPC(FinalPC);
I.dumpCurrentRegState(GenSettings->RegistersConfig.FinalStateOutputYaml);
auto RangesToDump = getMemoryRangesToDump(I, DumpMemorySection);
if (!RangesToDump.empty())
Expand Down
7 changes: 1 addition & 6 deletions llvm/tools/llvm-snippy/lib/Generator/SimRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ SimRunner::SimRunner(LLVMContext &Ctx, const SnippyTarget &TGT,
}
}

ProgramCounterType SimRunner::run(StringRef Program,
const IRegisterState &InitialRegState) {
void SimRunner::run(StringRef Program, const IRegisterState &InitialRegState) {
auto StopPC = getAddressOfSymbolInImage(Program, Linker::GetExitSymbolName());
if (auto E = StopPC.takeError()) {
auto Err = toString(std::move(E));
Expand All @@ -81,10 +80,7 @@ ProgramCounterType SimRunner::run(StringRef Program,
auto &PrimI = getPrimaryInterpreter();
PrimI.logMessage("#===Simulation Start===\n");

ProgramCounterType CurPC = PrimI.getPC();

while (!PrimI.endOfProg()) {
CurPC = PrimI.getPC();
auto ExecRes = PrimI.step();
if (ExecRes == ExecutionResult::FatalError)
PrimI.reportSimulationFatalError("Primary interpreter step failed");
Expand All @@ -106,7 +102,6 @@ ProgramCounterType SimRunner::run(StringRef Program,
checkStates(/* CheckMemory */ false);
}
checkStates(/* CheckMemory */ true);
return CurPC;
}

void SimRunner::checkStates(bool CheckMemory) {
Expand Down

0 comments on commit a2b5932

Please sign in to comment.