Skip to content

Commit

Permalink
Swap the order of store_imm_{u8, u16, u32}'s arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed May 10, 2024
1 parent 5da4eb0 commit 469c565
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions crates/polkavm-common/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,15 +1445,15 @@ impl<'a> InstructionVisitor for core::fmt::Formatter<'a> {
}
}

fn store_imm_u8(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u8(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
write!(self, "u8 [0x{offset:x}] = {value}")
}

fn store_imm_u16(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u16(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
write!(self, "u16 [0x{offset:x}] = {value}")
}

fn store_imm_u32(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u32(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
write!(self, "u32 [0x{offset:x}] = {value}")
}

Expand Down
2 changes: 1 addition & 1 deletion crates/polkavm-linker/src/program_from_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5217,7 +5217,7 @@ fn emit_code(
}
RegImm::Imm(value) => {
codegen! {
args = (value, target),
args = (target, value),
kind = kind,
{
StoreKind::U32 => store_imm_u32,
Expand Down
6 changes: 3 additions & 3 deletions crates/polkavm/src/compiler/amd64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,17 +1261,17 @@ impl<'r, 'a, S> InstructionVisitor for ArchVisitor<'r, 'a, S> where S: Sandbox {
}

#[inline(always)]
fn store_imm_u8(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u8(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store(value, None, offset, Size::U8);
}

#[inline(always)]
fn store_imm_u16(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u16(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store(value, None, offset, Size::U16);
}

#[inline(always)]
fn store_imm_u32(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u32(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store(value, None, offset, Size::U32);
}

Expand Down
6 changes: 3 additions & 3 deletions crates/polkavm/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ impl polkavm_common::program::InstructionVisitor for GasVisitor {
}

#[inline(always)]
fn store_imm_u8(&mut self, _value: u32, _offset: u32) -> Self::ReturnTy {
fn store_imm_u8(&mut self, _offset: u32, _value: u32) -> Self::ReturnTy {
self.cost += 1;
}

#[inline(always)]
fn store_imm_u16(&mut self, _value: u32, _offset: u32) -> Self::ReturnTy {
fn store_imm_u16(&mut self, _offset: u32, _value: u32) -> Self::ReturnTy {
self.cost += 1;
}

#[inline(always)]
fn store_imm_u32(&mut self, _value: u32, _offset: u32) -> Self::ReturnTy {
fn store_imm_u32(&mut self, _offset: u32, _value: u32) -> Self::ReturnTy {
self.cost += 1;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/polkavm/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,15 +1056,15 @@ impl<'a, 'b, const DEBUG: bool> InstructionVisitor for Visitor<'a, 'b, DEBUG> {
self.set3(d, s1, s2, u32::wrapping_add)
}

fn store_imm_u8(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u8(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store::<u8>(value, None, offset)
}

fn store_imm_u16(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u16(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store::<u16>(value, None, offset)
}

fn store_imm_u32(&mut self, value: u32, offset: u32) -> Self::ReturnTy {
fn store_imm_u32(&mut self, offset: u32, value: u32) -> Self::ReturnTy {
self.store::<u32>(value, None, offset)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/polkavm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn basic_test_blob() -> ProgramBlob<'static> {
builder.add_import("hostcall".into());
builder.set_code(
&[
asm::store_imm_u32(0x12345678, memory_map.rw_data_address()),
asm::store_imm_u32(memory_map.rw_data_address(), 0x12345678),
asm::add(S0, A0, A1),
asm::ecalli(0),
asm::add(A0, A0, S0),
Expand Down

0 comments on commit 469c565

Please sign in to comment.