Skip to content

Commit

Permalink
Remove Ecall and Ebreak from Instr
Browse files Browse the repository at this point in the history
The ECALL and EBREAK instructions have distinct mcause values and are not considered illegal instructions. Since they trigger different types of traps, they do not require decoding in our decoder for illegal instructions. As a result, we can safely remove them from the instruction decoder.
  • Loading branch information
francois141 committed Jan 9, 2025
1 parent 91dba20 commit 7443b45
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const OPCODE_MASK: usize = 0b1111111;
/// A RISC-V instruction.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Instr {
Ecall,
Ebreak,
Wfi,
/// CSR Read/Write
Csrrw {
Expand Down Expand Up @@ -112,8 +110,6 @@ impl MiralisContext {
let func7 = (raw >> 25) & 0b1111111;
if func3 == 0b000 {
return match imm {
0b000000000000 => Instr::Ecall,
0b000000000001 => Instr::Ebreak,
0b000100000101 => Instr::Wfi,
0b001100000010 => Instr::Mret,
0b000100000010 => Instr::Sret,
Expand Down Expand Up @@ -876,10 +872,6 @@ mod tests {
#[test]
fn system_instructions() {
let mctx = MiralisContext::new(unsafe { Arch::detect_hardware() }, 0x100000, 0x2000);
// ECALL: Environment call.
assert_eq!(mctx.decode_system(0x00000073), Instr::Ecall);
// EBREAK: Environment break.
assert_eq!(mctx.decode_system(0x00100073), Instr::Ebreak);
// MRET: Return from machine mode.
assert_eq!(mctx.decode_system(0x30200073), Instr::Mret);
// SRET: Return from supervisor mode.
Expand Down

0 comments on commit 7443b45

Please sign in to comment.