authorgravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2023-09-06 22:56:53+02:00
committergravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2023-09-10 15:59:02+02:00
logec7f88945b84db07ff6e8fd02f09e24713994f76
tree08f211147be0fd061ecb0b8ac968ad5a0c6ae1fe
parent9d6b6bddb60e5a970b1c849c2a0b7a66451f8bc3

wasm: implement more math operations on 128 bit integers

these operations are required to be able to print floats

1 files changed, 7 insertions(+), 1 deletions(-)

src/arch/wasm/CodeGen.zig+7-1
......@@ -2650,12 +2650,18 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!
26502650
26512651fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {
26522652 const mod = func.bin_file.base.options.module.?;
2653 if (ty.intInfo(mod).bits > 128) {
2653 const int_info = ty.intInfo(mod);
2654 if (int_info.bits > 128) {
26542655 return func.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{});
26552656 }
26562657
26572658 switch (op) {
26582659 .mul => return func.callIntrinsic("__multi3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }),
2660 .div => switch (int_info.signedness) {
2661 .signed => return func.callIntrinsic("__udivti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }),
2662 .unsigned => return func.callIntrinsic("__divti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }),
2663 },
2664 .rem => return func.callIntrinsic("__umodti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }),
26592665 .shr => return func.callIntrinsic("__lshrti3", &.{ ty.toIntern(), .i32_type }, ty, &.{ lhs, rhs }),
26602666 .shl => return func.callIntrinsic("__ashlti3", &.{ ty.toIntern(), .i32_type }, ty, &.{ lhs, rhs }),
26612667 .xor => {