Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv/program: Removed dead code for save/restore of registers #1012

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
16 changes: 0 additions & 16 deletions src/target/riscv/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ int riscv_program_init(struct riscv_program *p, struct target *target)
memset(p, 0, sizeof(*p));
p->target = target;
p->instruction_count = 0;
p->target_xlen = riscv_xlen(target);
for (size_t i = 0; i < RISCV_REGISTER_COUNT; ++i)
p->writes_xreg[i] = 0;

for (size_t i = 0; i < RISCV_MAX_PROGBUF_SIZE; ++i)
p->progbuf[i] = -1;
Expand All @@ -48,15 +45,6 @@ int riscv_program_exec(struct riscv_program *p, struct target *t)
keep_alive();

p->execution_result = RISCV_PROGBUF_EXEC_RESULT_UNKNOWN;
riscv_reg_t saved_registers[GDB_REGNO_XPR31 + 1];
for (size_t i = GDB_REGNO_ZERO + 1; i <= GDB_REGNO_XPR31; ++i) {
if (p->writes_xreg[i]) {
LOG_TARGET_DEBUG(t, "Saving register %d as used by program", (int)i);
int result = riscv_get_register(t, &saved_registers[i], i);
if (result != ERROR_OK)
return result;
}
}

if (riscv_program_ebreak(p) != ERROR_OK) {
LOG_TARGET_ERROR(t, "Unable to insert ebreak into program buffer");
Expand All @@ -80,10 +68,6 @@ int riscv_program_exec(struct riscv_program *p, struct target *t)
}
p->execution_result = RISCV_PROGBUF_EXEC_RESULT_SUCCESS;

for (size_t i = GDB_REGNO_ZERO; i <= GDB_REGNO_XPR31; ++i)
if (p->writes_xreg[i])
riscv_set_register(t, i, saved_registers[i]);

return ERROR_OK;
}

Expand Down
7 changes: 0 additions & 7 deletions src/target/riscv/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ struct riscv_program {
/* Number of 32-bit instructions in the program. */
size_t instruction_count;

/* Side effects of executing this program. These must be accounted for
* in order to maintain correct executing of the target system. */
bool writes_xreg[RISCV_REGISTER_COUNT];

/* XLEN on the target. */
int target_xlen;

/* execution result of the program */
/* TODO: remove this field. We should make it a parameter to riscv_program_exec */
riscv_progbuf_exec_result_t execution_result;
Expand Down
Loading