Skip to content

Commit

Permalink
[fix] remove String and format macro for no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
Alignof committed Aug 16, 2024
1 parent b702868 commit e306216
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,15 @@ impl Display for Instruction {
InstFormat::CsrCntrFormat => {
write!(f, "{} {}", self.opc, reg2str(self.rd.unwrap()),)
}
InstFormat::Uncategorized => {
write!(
f,
"{}{}{}{}{}",
self.opc,
match self.rd {
Some(rd) => format!(" {}", reg2str(rd)),
None => String::new(),
},
match self.rs1 {
Some(rs1) => format!(" {rs1}"),
None => String::new(),
},
match self.rs2 {
Some(rs2) => format!(" {rs2}"),
None => String::new(),
},
match self.imm {
Some(imm) => format!(" {imm}"),
None => String::new(),
},
)
}
InstFormat::Uncategorized => match self.opc {
OpcodeKind::BaseI(BaseIOpcode::ECALL | BaseIOpcode::EBREAK)
| OpcodeKind::Zifencei(ZifenceiOpcode::FENCE)
| OpcodeKind::C(COpcode::NOP | COpcode::EBREAK)
| OpcodeKind::Priv(
PrivOpcode::MRET | PrivOpcode::SRET | PrivOpcode::WFI | PrivOpcode::SFENCE_VMA,
) => write!(f, "{}", self.opc),
_ => unreachable!(),
},
}
}
}
Expand Down

0 comments on commit e306216

Please sign in to comment.