feat: differentiate between signed and unsigned multiplication
- Split `BinaryOp::Mul` into `BinaryOp::SMul` and `BinaryOp::UMul` in the IR. - Implement x86_64 codegen for `UMul` using the `mulq` instruction. - Update `X86Backend` to use `imulq` specifically for `SMul`. - Update constant folding and IR printer to support the new multiplication operations. - Optimize function epilogue by omitting the final `jmp` on fallthrough. - Update `main` test case to use `build_umul`.
This commit is contained in:
+2
-1
@@ -146,7 +146,8 @@ fn evaluate_binary(op: BinaryOp, src1: &Operand, src2: &Operand) -> Option<Opera
|
||||
match op {
|
||||
BinaryOp::Add => Some(Operand::Integer(a.wrapping_add(b))),
|
||||
BinaryOp::Sub => Some(Operand::Integer(a.wrapping_sub(b))),
|
||||
BinaryOp::Mul => Some(Operand::Integer(a.wrapping_mul(b))),
|
||||
BinaryOp::SMul => Some(Operand::Integer((a as i64).wrapping_mul(b as i64) as u64)),
|
||||
BinaryOp::UMul => Some(Operand::Integer(a.wrapping_mul(b))),
|
||||
BinaryOp::UDiv => {
|
||||
if b != 0 {
|
||||
Some(Operand::Integer(a.wrapping_div(b)))
|
||||
|
||||
Reference in New Issue
Block a user