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

implementation for set less than immediate #2844

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,14 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: IInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::SetLessThanImmediate => {
unimplemented!("SetLessThanImmediate")
// slti: x[rd] = (x[rs1] < sext(immediate)) ? 1 : 0
let local_rs1 = env.read_register(&rs1);
let local_imm = env.sign_extend(&imm, 12);
let rd_scratch = env.alloc_scratch();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being picky, but it would be nice to follow the convention of scope for the intermediary variables.

let local_rd = unsafe { env.test_less_than_signed(&local_rs1, &local_imm, rd_scratch) };
env.write_register(&rd, local_rd);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::SetLessThanImmediateUnsigned => {
unimplemented!("SetLessThanImmediateUnsigned")
Expand Down
Loading