diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2022-08-10 13:21:47 +0200 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2022-08-10 14:48:27 +0200 |
| commit | bb1c3e8b7e2be201221e14719d2d39e6298cc66c (patch) | |
| tree | d4d5800c280beea171fdb4028553a7107aa21891 /src/value.zig | |
| parent | 49a270b2038709a6a0c1f4de604696278769257b (diff) | |
| download | zig-bb1c3e8b7e2be201221e14719d2d39e6298cc66c.tar.gz zig-bb1c3e8b7e2be201221e14719d2d39e6298cc66c.zip | |
stage2: Handle lazy values for the % operator
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/value.zig b/src/value.zig index 3994040ba6..f156651eaa 100644 --- a/src/value.zig +++ b/src/value.zig @@ -3472,44 +3472,6 @@ pub const Value = extern union { return fromBigInt(allocator, result_q.toConst()); } - pub fn intRem(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { - if (ty.zigTypeTag() == .Vector) { - const result_data = try allocator.alloc(Value, ty.vectorLen()); - for (result_data) |*scalar, i| { - scalar.* = try intRemScalar(lhs.indexVectorlike(i), rhs.indexVectorlike(i), allocator, target); - } - return Value.Tag.aggregate.create(allocator, result_data); - } - return intRemScalar(lhs, rhs, allocator, target); - } - - pub fn intRemScalar(lhs: Value, rhs: Value, allocator: Allocator, target: Target) !Value { - // TODO is this a performance issue? maybe we should try the operation without - // resorting to BigInt first. - var lhs_space: Value.BigIntSpace = undefined; - var rhs_space: Value.BigIntSpace = undefined; - const lhs_bigint = lhs.toBigInt(&lhs_space, target); - const rhs_bigint = rhs.toBigInt(&rhs_space, target); - const limbs_q = try allocator.alloc( - std.math.big.Limb, - lhs_bigint.limbs.len, - ); - const limbs_r = try allocator.alloc( - std.math.big.Limb, - // TODO: consider reworking Sema to re-use Values rather than - // always producing new Value objects. - rhs_bigint.limbs.len, - ); - const limbs_buffer = try allocator.alloc( - std.math.big.Limb, - std.math.big.int.calcDivLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len), - ); - var result_q = BigIntMutable{ .limbs = limbs_q, .positive = undefined, .len = undefined }; - var result_r = BigIntMutable{ .limbs = limbs_r, .positive = undefined, .len = undefined }; - result_q.divTrunc(&result_r, lhs_bigint, rhs_bigint, limbs_buffer); - return fromBigInt(allocator, result_r.toConst()); - } - pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, target: Target) !Value { if (ty.zigTypeTag() == .Vector) { const result_data = try allocator.alloc(Value, ty.vectorLen()); |
