mirror of
https://github.com/ziglang/zig.git
synced 2026-02-07 15:07:12 +00:00
wasm/codegen: add "and" + "or" impl for big ints
This commit is contained in:
parent
da4acf9a48
commit
bb1fe112f1
@ -2658,19 +2658,19 @@ fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) Inner
|
||||
.rem => return func.callIntrinsic("__umodti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }),
|
||||
.shr => return func.callIntrinsic("__lshrti3", &.{ ty.toIntern(), .i32_type }, ty, &.{ lhs, rhs }),
|
||||
.shl => return func.callIntrinsic("__ashlti3", &.{ ty.toIntern(), .i32_type }, ty, &.{ lhs, rhs }),
|
||||
.xor => {
|
||||
.@"and", .@"or", .xor => {
|
||||
const result = try func.allocStack(ty);
|
||||
try func.emitWValue(result);
|
||||
const lhs_high_bit = try func.load(lhs, Type.u64, 0);
|
||||
const rhs_high_bit = try func.load(rhs, Type.u64, 0);
|
||||
const xor_high_bit = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, .xor);
|
||||
try func.store(.stack, xor_high_bit, Type.u64, result.offset());
|
||||
const op_high_bit = try func.binOp(lhs_high_bit, rhs_high_bit, Type.u64, op);
|
||||
try func.store(.stack, op_high_bit, Type.u64, result.offset());
|
||||
|
||||
try func.emitWValue(result);
|
||||
const lhs_low_bit = try func.load(lhs, Type.u64, 8);
|
||||
const rhs_low_bit = try func.load(rhs, Type.u64, 8);
|
||||
const xor_low_bit = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, .xor);
|
||||
try func.store(.stack, xor_low_bit, Type.u64, result.offset() + 8);
|
||||
const op_low_bit = try func.binOp(lhs_low_bit, rhs_low_bit, Type.u64, op);
|
||||
try func.store(.stack, op_low_bit, Type.u64, result.offset() + 8);
|
||||
return result;
|
||||
},
|
||||
.add, .sub => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user