authorgravatar for paul.verigo@gmail.comPavel Verigo <paul.verigo@gmail.com> 2024-06-14 20:28:50+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2024-06-15 11:28:16+02:00
log7829be6ee07aba6574fa5035c3d33023b3e23de7
tree5ed05356ba74f0fe2ac6e07de7d9199a0f71a154
parent82a934bb912241809ac8029e1fa5843092a7fdf6

stage2-wasm: enum bigint <= 128 bits


2 files changed, 4 insertions(+), 7 deletions(-)

src/arch/wasm/CodeGen.zig+4-6
......@@ -1727,7 +1727,6 @@ fn isByRef(ty: Type, mod: *Module) bool {
17271727 .Bool,
17281728 .ErrorSet,
17291729 .Fn,
1730 .Enum,
17311730 .AnyFrame,
17321731 => return false,
17331732
......@@ -1750,6 +1749,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
17501749 },
17511750 .Vector => return determineSimdStoreStrategy(ty, mod) == .unrolled,
17521751 .Int => return ty.intInfo(mod).bits > 64,
1752 .Enum => return ty.intInfo(mod).bits > 64,
17531753 .Float => return ty.floatBits(target) > 64,
17541754 .ErrorUnion => {
17551755 const pl_ty = ty.errorUnionPayload(mod);
......@@ -2404,7 +2404,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
24042404 return;
24052405 }
24062406 },
2407 .Int, .Float => if (abi_size > 8 and abi_size <= 16) {
2407 .Int, .Enum, .Float => if (abi_size > 8 and abi_size <= 16) {
24082408 try func.emitWValue(lhs);
24092409 const lsb = try func.load(rhs, Type.u64, 0);
24102410 try func.store(.{ .stack = {} }, lsb, Type.u64, 0 + lhs.offset());
......@@ -3187,12 +3187,10 @@ fn toTwosComplement(value: anytype, bits: u7) std.meta.Int(.unsigned, @typeInfo(
31873187 return @as(WantedT, @intCast(result));
31883188}
31893189
3190/// This function is intended to assert that `isByRef` returns `false` for `ty`.
3191/// However such an assertion fails on the behavior tests currently.
3190/// Asserts that `isByRef` returns `false` for `ty`.
31923191fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
31933192 const mod = func.bin_file.base.comp.module.?;
3194 // TODO: enable this assertion
3195 //assert(!isByRef(ty, mod));
3193 assert(!isByRef(ty, mod));
31963194 const ip = &mod.intern_pool;
31973195 if (val.isUndefDeep(mod)) return func.emitUndefined(ty);
31983196
test/behavior/enum.zig-1
......@@ -1284,7 +1284,6 @@ test "matching captures causes enum equivalence" {
12841284}
12851285
12861286test "large enum field values" {
1287 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
12881287 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
12891288 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
12901289