diff --git a/src/archs/arch.rs b/src/archs/arch.rs index 7b7e055..f0c51a6 100644 --- a/src/archs/arch.rs +++ b/src/archs/arch.rs @@ -50,12 +50,12 @@ pub trait Architecture { fn declare(&mut self, var: StmtVarDecl); fn mov(&mut self, src: MoveSource, dest: MoveDestination, scope: &Scope); fn negate(&mut self, r: &Register); - fn not(&mut self, r1: &Register, r2: &Register); - fn add(&mut self, r1: &Register, r2: &Register); - fn sub(&mut self, r1: &Register, r2: &Register); - fn mul(&mut self, r1: &Register, r2: &Register); - fn div(&mut self, r1: &Register, r2: &Register); - fn cmp(&mut self, r1: &Register, r2: &Register, cmp: CmpOp); + fn not(&mut self, dest: &Register, src: &Register); + fn add(&mut self, dest: &Register, src: &Register); + fn sub(&mut self, dest: &Register, src: &Register); + fn mul(&mut self, dest: &Register, src: &Register); + fn div(&mut self, dest: &Register, src: &Register); + fn cmp(&mut self, dest: &Register, src: &Register, cmp: CmpOp); fn fn_preamble(&mut self, name: &str, stackframe: usize); fn fn_postamble(&mut self, name: &str, stackframe: usize); fn ret(&mut self, r: Register, type_: Type); diff --git a/src/codegen/codegen.rs b/src/codegen/codegen.rs index adfb70d..aadf4a4 100644 --- a/src/codegen/codegen.rs +++ b/src/codegen/codegen.rs @@ -206,7 +206,7 @@ impl CodeGen { let r = self.arch.alloc()?; self.expr(*expr.right, (&r).into())?; - self.arch.add(&r, dest.register().unwrap()); + self.arch.add(dest.register().unwrap(), &r); self.arch.free(r)?; } BinOp::Sub => { @@ -215,7 +215,7 @@ impl CodeGen { let r = self.arch.alloc()?; self.expr(*expr.right, (&r).into())?; - self.arch.sub(&r, dest.register().unwrap()); + self.arch.sub(dest.register().unwrap(), &r); self.arch.free(r)?; } BinOp::Mul => { @@ -224,7 +224,7 @@ impl CodeGen { let r = self.arch.alloc()?; self.expr(*expr.right, (&r).into())?; - self.arch.mul(&r, dest.register().unwrap()); + self.arch.mul(dest.register().unwrap(), &r); self.arch.free(r)?; } BinOp::Div => { @@ -233,7 +233,7 @@ impl CodeGen { let r = self.arch.alloc()?; self.expr(*expr.right, (&r).into())?; - self.arch.div(&r, dest.register().unwrap()); + self.arch.div(dest.register().unwrap(), &r); self.arch.free(r)?; } BinOp::LessThan @@ -248,7 +248,7 @@ impl CodeGen { self.expr(*expr.right, (&r).into())?; self.arch - .cmp(&r, dest.register().unwrap(), CmpOp::try_from(&expr.op)?); + .cmp(dest.register().unwrap(), &r, CmpOp::try_from(&expr.op)?); self.arch.free(r)?; } };