Skip to content

Commit

Permalink
Rename unimp() to unimpl() (#118)
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Co-authored-by: duc-nx <>
  • Loading branch information
duc-nx authored and sjudson committed Feb 12, 2025
1 parent 60b4e83 commit f68ef93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion common/src/riscv/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ impl Instruction {
}

/// Creates a new unimplemented instruction.
pub fn unimp() -> Self {
/// When processing an unimplemented instruction, only the opcode is checked,
/// and the fields op_a, op_b, and op_c are ignored.
pub fn unimpl() -> Self {
Self::new(
Opcode::from(BuiltinOpcode::UNIMPL),
0,
Expand Down
4 changes: 4 additions & 0 deletions common/src/riscv/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ pub enum BuiltinOpcode {
NOP,

// Placeholder for unimplemented instructions
// UNIMPL instruction is used to represent instructions that are not yet implemented
// or are intentionally left unimplemented in the current implementation.
// In the RISC-V specification, this is similar to the UNIMP (unimplemented instruction) concept.
// Note: This may be updated or replaced if CSR (Control and Status Register) instruction support is added in the future.
UNIMPL,
}

Expand Down
6 changes: 3 additions & 3 deletions vm/src/riscv/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ pub fn decode_instructions(u32_instructions: &[u32]) -> BasicBlockProgram {
let mut start_new_block = true;

for &u32_instruction in u32_instructions.iter() {
// Decode the instruction
// Decode the instruction, if the instruction is unrecognizable, it will be marked as unimplemented.
let decoded_instruction =
process_instruction(&mut decoder, u32_instruction).unwrap_or_else(Instruction::unimp);
process_instruction(&mut decoder, u32_instruction).unwrap_or_else(Instruction::unimpl);

// Start a new basic block if necessary
if start_new_block && !current_block.0.is_empty() {
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn decode_until_end_of_a_block(u32_instructions: &[u32]) -> BasicBlock {

// Right now, we only support the single dynamic R-type opcode.
if opcode != DYNAMIC_RTYPE_OPCODE {
return Instruction::unimp();
return Instruction::unimpl();
}

let fn3 = extract_fn3(u32_instruction);
Expand Down
2 changes: 1 addition & 1 deletion vm/src/riscv/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ macro_rules! unimplemented_instructions {
($($name:ident($($arg:ident: $type:ty)?)),+ $(,)?) => {
$(
fn $name(&mut self$(, _: $type)?) -> Self::InstructionResult {
Instruction::unimp()
Instruction::unimpl()
}
)+
};
Expand Down

0 comments on commit f68ef93

Please sign in to comment.