| ... | @@ -2675,41 +2675,41 @@ fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) Inner | ... | @@ -2675,41 +2675,41 @@ fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) Inner |
| 2675 | .@"and", .@"or", .xor => { | 2675 | .@"and", .@"or", .xor => { |
| 2676 | const result = try func.allocStack(ty); | 2676 | const result = try func.allocStack(ty); |
| 2677 | try func.emitWValue(result); | 2677 | try func.emitWValue(result); |
| 2678 | const lhs_high_bit = try func.load(lhs, Type.u64, 0); | 2678 | const lhs_low_bit = try func.load(lhs, Type.u64, 0); |
| 2679 | const rhs_high_bit = try func.load(rhs, Type.u64, 0); | 2679 | const rhs_low_bit = try func.load(rhs, Type.u64, 0); |
| 2680 | const op_high_bit = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, op); | 2680 | const op_low_bit = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, op); |
| 2681 | try func.store(.stack, op_high_bit, Type.u64, result.offset()); | 2681 | try func.store(.stack, op_low_bit, Type.u64, result.offset()); |
| 2682 | | 2682 | |
| 2683 | try func.emitWValue(result); | 2683 | try func.emitWValue(result); |
| 2684 | const lhs_low_bit = try func.load(lhs, Type.u64, 8); | 2684 | const lhs_high_bit = try func.load(lhs, Type.u64, 8); |
| 2685 | const rhs_low_bit = try func.load(rhs, Type.u64, 8); | 2685 | const rhs_high_bit = try func.load(rhs, Type.u64, 8); |
| 2686 | const op_low_bit = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, op); | 2686 | const op_high_bit = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, op); |
| 2687 | try func.store(.stack, op_low_bit, Type.u64, result.offset() + 8); | 2687 | try func.store(.stack, op_high_bit, Type.u64, result.offset() + 8); |
| 2688 | return result; | 2688 | return result; |
| 2689 | }, | 2689 | }, |
| 2690 | .add, .sub => { | 2690 | .add, .sub => { |
| 2691 | const result = try func.allocStack(ty); | 2691 | const result = try func.allocStack(ty); |
| 2692 | var lhs_high_bit = try (try func.load(lhs, Type.u64, 0)).toLocal(func, Type.u64); | 2692 | var lhs_low_bit = try (try func.load(lhs, Type.u64, 0)).toLocal(func, Type.u64); |
| 2693 | defer lhs_high_bit.free(func); | 2693 | defer lhs_low_bit.free(func); |
| 2694 | var rhs_high_bit = try (try func.load(rhs, Type.u64, 0)).toLocal(func, Type.u64); | 2694 | var rhs_low_bit = try (try func.load(rhs, Type.u64, 0)).toLocal(func, Type.u64); |
| 2695 | defer rhs_high_bit.free(func); | 2695 | defer rhs_low_bit.free(func); |
| 2696 | var high_op_res = try (try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, op)).toLocal(func, Type.u64); | 2696 | var low_op_res = try (try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, op)).toLocal(func, Type.u64); |
| 2697 | defer high_op_res.free(func); | 2697 | defer low_op_res.free(func); |
| 2698 | | 2698 | |
| 2699 | const lhs_low_bit = try func.load(lhs, Type.u64, 8); | 2699 | const lhs_high_bit = try func.load(lhs, Type.u64, 8); |
| 2700 | const rhs_low_bit = try func.load(rhs, Type.u64, 8); | 2700 | const rhs_high_bit = try func.load(rhs, Type.u64, 8); |
| 2701 | const low_op_res = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, op); | 2701 | const high_op_res = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, op); |
| 2702 | | 2702 | |
| 2703 | const lt = if (op == .add) blk: { | 2703 | const lt = if (op == .add) blk: { |
| 2704 | break :blk try func.cmp(high_op_res, rhs_high_bit, Type.u64, .lt); | 2704 | break :blk try func.cmp(low_op_res, rhs_low_bit, Type.u64, .lt); |
| 2705 | } else if (op == .sub) blk: { | 2705 | } else if (op == .sub) blk: { |
| 2706 | break :blk try func.cmp(lhs_high_bit, rhs_high_bit, Type.u64, .lt); | 2706 | break :blk try func.cmp(lhs_low_bit, rhs_low_bit, Type.u64, .lt); |
| 2707 | } else unreachable; | 2707 | } else unreachable; |
| 2708 | const tmp = try func.intcast(lt, Type.u32, Type.u64); | 2708 | const tmp = try func.intcast(lt, Type.u32, Type.u64); |
| 2709 | var tmp_op = try (try func.binOp(low_op_res, tmp, Type.u64, op)).toLocal(func, Type.u64); | 2709 | var tmp_op = try (try func.binOp(high_op_res, tmp, Type.u64, op)).toLocal(func, Type.u64); |
| 2710 | defer tmp_op.free(func); | 2710 | defer tmp_op.free(func); |
| 2711 | | 2711 | |
| 2712 | try func.store(result, high_op_res, Type.u64, 0); | 2712 | try func.store(result, low_op_res, Type.u64, 0); |
| 2713 | try func.store(result, tmp_op, Type.u64, 8); | 2713 | try func.store(result, tmp_op, Type.u64, 8); |
| 2714 | return result; | 2714 | return result; |
| 2715 | }, | 2715 | }, |
| ... | @@ -5523,16 +5523,16 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std | ... | @@ -5523,16 +5523,16 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std |
| 5523 | return func.fail("TODO: Support cmpBigInt for integer bitsize: '{d}'", .{operand_ty.bitSize(pt)}); | 5523 | return func.fail("TODO: Support cmpBigInt for integer bitsize: '{d}'", .{operand_ty.bitSize(pt)}); |
| 5524 | } | 5524 | } |
| 5525 | | 5525 | |
| 5526 | var lhs_high_bit = try (try func.load(lhs, Type.u64, 0)).toLocal(func, Type.u64); | 5526 | var lhs_high_bit = try (try func.load(lhs, Type.u64, 8)).toLocal(func, Type.u64); |
| 5527 | defer lhs_high_bit.free(func); | 5527 | defer lhs_high_bit.free(func); |
| 5528 | var rhs_high_bit = try (try func.load(rhs, Type.u64, 0)).toLocal(func, Type.u64); | 5528 | var rhs_high_bit = try (try func.load(rhs, Type.u64, 8)).toLocal(func, Type.u64); |
| 5529 | defer rhs_high_bit.free(func); | 5529 | defer rhs_high_bit.free(func); |
| 5530 | | 5530 | |
| 5531 | switch (op) { | 5531 | switch (op) { |
| 5532 | .eq, .neq => { | 5532 | .eq, .neq => { |
| 5533 | const xor_high = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, .xor); | 5533 | const xor_high = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, .xor); |
| 5534 | const lhs_low_bit = try func.load(lhs, Type.u64, 8); | 5534 | const lhs_low_bit = try func.load(lhs, Type.u64, 0); |
| 5535 | const rhs_low_bit = try func.load(rhs, Type.u64, 8); | 5535 | const rhs_low_bit = try func.load(rhs, Type.u64, 0); |
| 5536 | const xor_low = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, .xor); | 5536 | const xor_low = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, .xor); |
| 5537 | const or_result = try func.binOp(xor_high, xor_low, Type.u64, .@"or"); | 5537 | const or_result = try func.binOp(xor_high, xor_low, Type.u64, .@"or"); |
| 5538 | | 5538 | |
| ... | @@ -5545,9 +5545,9 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std | ... | @@ -5545,9 +5545,9 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std |
| 5545 | else => { | 5545 | else => { |
| 5546 | const ty = if (operand_ty.isSignedInt(mod)) Type.i64 else Type.u64; | 5546 | const ty = if (operand_ty.isSignedInt(mod)) Type.i64 else Type.u64; |
| 5547 | // leave those value on top of the stack for '.select' | 5547 | // leave those value on top of the stack for '.select' |
| 5548 | const lhs_low_bit = try func.load(lhs, Type.u64, 8); | 5548 | const lhs_low_bit = try func.load(lhs, Type.u64, 0); |
| 5549 | const rhs_low_bit = try func.load(rhs, Type.u64, 8); | 5549 | const rhs_low_bit = try func.load(rhs, Type.u64, 0); |
| 5550 | _ = try func.cmp(lhs_low_bit, rhs_low_bit, ty, op); | 5550 | _ = try func.cmp(lhs_low_bit, rhs_low_bit, Type.u64, op); |
| 5551 | _ = try func.cmp(lhs_high_bit, rhs_high_bit, ty, op); | 5551 | _ = try func.cmp(lhs_high_bit, rhs_high_bit, ty, op); |
| 5552 | _ = try func.cmp(lhs_high_bit, rhs_high_bit, ty, .eq); | 5552 | _ = try func.cmp(lhs_high_bit, rhs_high_bit, ty, .eq); |
| 5553 | try func.addTag(.select); | 5553 | try func.addTag(.select); |