Skip to content

Commit

Permalink
Remove load/store offset when 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rerumu committed Apr 30, 2022
1 parent a40335e commit 0278458
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion codegen-luajit/src/backend/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ impl Driver for LoadAt {
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
write!(w, "load_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.write(mng, w)?;
write!(w, "+ {})", self.offset)

if self.offset != 0 {
write!(w, "+ {}", self.offset)?;
}

write!(w, ")")
}
}

Expand Down
7 changes: 6 additions & 1 deletion codegen-luajit/src/backend/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ impl Driver for StoreAt {
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
write!(w, "store_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.write(mng, w)?;
write!(w, "+ {}, ", self.offset)?;

if self.offset != 0 {
write!(w, "+ {}", self.offset)?;
}

write!(w, ", ")?;
self.value.write(mng, w)?;
write!(w, ")")
}
Expand Down
7 changes: 6 additions & 1 deletion codegen-luau/src/backend/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ impl Driver for LoadAt {
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
write!(w, "load_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.write(mng, w)?;
write!(w, "+ {})", self.offset)

if self.offset != 0 {
write!(w, "+ {}", self.offset)?;
}

write!(w, ")")
}
}

Expand Down
7 changes: 6 additions & 1 deletion codegen-luau/src/backend/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ impl Driver for StoreAt {
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
write!(w, "store_{}(memory_at_0, ", self.what.as_name())?;
self.pointer.write(mng, w)?;
write!(w, "+ {}, ", self.offset)?;

if self.offset != 0 {
write!(w, "+ {}", self.offset)?;
}

write!(w, ", ")?;
self.value.write(mng, w)?;
write!(w, ")")
}
Expand Down

0 comments on commit 0278458

Please sign in to comment.