Skip to content

Commit

Permalink
refactor(archs/amd64): use existing functions to generate not
Browse files Browse the repository at this point in the history
  • Loading branch information
MilkeeyCat committed Oct 20, 2024
1 parent 0062cb3 commit 34ed08f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
9 changes: 0 additions & 9 deletions src/archs/amd64/amd64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,6 @@ impl Architecture for Amd64 {
));
}

fn not(&mut self, dest: &Destination, dest2: &Destination) {
self.buf.push_str(&formatdoc!(
"
\tcmp {dest}, 0
\tsete {dest2}
",
));
}

fn add(
&mut self,
lhs: &Source,
Expand Down
1 change: 0 additions & 1 deletion src/archs/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub trait Architecture: ArchitectureClone {
fn declare(&mut self, name: &str, size: usize);
fn mov(&mut self, src: &Source, dest: &Destination, signed: bool) -> Result<(), ArchError>;
fn negate(&mut self, dest: &Destination);
fn not(&mut self, dest: &Destination, dest2: &Destination);
fn add(
&mut self,
lhs: &Source,
Expand Down
7 changes: 5 additions & 2 deletions src/codegen/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,11 @@ impl CodeGen {
Some(&r.dest(self.arch.size(&type_, &self.scope))),
state,
)?;
self.arch
.not(&r.dest(self.arch.size(&type_, &self.scope)), dest);
self.arch.cmp(
&r.dest(self.arch.size(&type_, &self.scope)),
&Source::Immediate(Immediate::UInt(0)),
);
self.arch.setcc(dest, CmpOp::Equal);
self.arch.free(r)?;
}
UnOp::Address => {
Expand Down

0 comments on commit 34ed08f

Please sign in to comment.