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 shift left logical immediate riscv32im #2836

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Changes from 3 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: 15 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,21 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: IInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::ShiftLeftLogicalImmediate => {
unimplemented!("ShiftLeftLogicalImmediate")
// slli: x[rd] = x[rs1] << shamt
let local_rs1 = env.read_register(&rs1);
let shamt = {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some FIXME reg. this comment please? Can be done later.

Copy link
Member

Choose a reason for hiding this comment

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

Note that a test is ready in master reg. sll, see assembly code. Only lui should be implemented.

let pos = env.alloc_scratch();
unsafe { env.bitmask(&imm, 5, 0, pos) }
};
// parse shamt from imm as 20-24 of instruction and 0-4 wrt to imm
Copy link
Member

Choose a reason for hiding this comment

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

what is this comment for?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was removed, but it was explaining where in the instruction and immediate the shamt was parsed from.

let local_rd = {
let pos = env.alloc_scratch();
unsafe { env.shift_left(&local_rs1, &shamt, pos) }
};

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::ShiftRightLogicalImmediate => {
unimplemented!("ShiftRightLogicalImmediate")
Expand Down
Loading