Skip to content

Commit

Permalink
Change how the branches are printed in the disassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Nov 3, 2023
1 parent 62d278d commit c7dda6b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/polkavm-common/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,27 +506,27 @@ impl<'a> InstructionVisitor for core::fmt::Formatter<'a> {
}

fn branch_less_unsigned(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} <u {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} <u {}: jump @{:x}", s1, s2, imm * 4)
}

fn branch_less_signed(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} <s {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} <s {}: jump @{:x}", s1, s2, imm * 4)
}

fn branch_greater_or_equal_unsigned(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} >=u {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} >=u {}: jump @{:x}", s1, s2, imm * 4)
}

fn branch_greater_or_equal_signed(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} >=s {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} >=s {}: jump @{:x}", s1, s2, imm * 4)
}

fn branch_eq(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} == {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} == {}: jump @{:x}", s1, s2, imm * 4)
}

fn branch_not_eq(&mut self, s1: Reg, s2: Reg, imm: u32) -> Self::ReturnTy {
write!(self, "if {} != {} -> jump @{:x}", s1, s2, imm * 4)
write!(self, "if {} != {}: jump @{:x}", s1, s2, imm * 4)
}

fn jump_and_link_register(&mut self, ra: Reg, base: Reg, offset: u32) -> Self::ReturnTy {
Expand Down

0 comments on commit c7dda6b

Please sign in to comment.