stage2-wasm: enum bigint <= 128 bits

This commit is contained in:
Pavel Verigo 2024-06-14 20:28:50 +02:00 committed by Luuk de Gram
parent 82a934bb91
commit 7829be6ee0
2 changed files with 4 additions and 7 deletions

View File

@ -1727,7 +1727,6 @@ fn isByRef(ty: Type, mod: *Module) bool {
.Bool, .Bool,
.ErrorSet, .ErrorSet,
.Fn, .Fn,
.Enum,
.AnyFrame, .AnyFrame,
=> return false, => return false,
@ -1750,6 +1749,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
}, },
.Vector => return determineSimdStoreStrategy(ty, mod) == .unrolled, .Vector => return determineSimdStoreStrategy(ty, mod) == .unrolled,
.Int => return ty.intInfo(mod).bits > 64, .Int => return ty.intInfo(mod).bits > 64,
.Enum => return ty.intInfo(mod).bits > 64,
.Float => return ty.floatBits(target) > 64, .Float => return ty.floatBits(target) > 64,
.ErrorUnion => { .ErrorUnion => {
const pl_ty = ty.errorUnionPayload(mod); const pl_ty = ty.errorUnionPayload(mod);
@ -2404,7 +2404,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
return; return;
} }
}, },
.Int, .Float => if (abi_size > 8 and abi_size <= 16) { .Int, .Enum, .Float => if (abi_size > 8 and abi_size <= 16) {
try func.emitWValue(lhs); try func.emitWValue(lhs);
const lsb = try func.load(rhs, Type.u64, 0); const lsb = try func.load(rhs, Type.u64, 0);
try func.store(.{ .stack = {} }, lsb, Type.u64, 0 + lhs.offset()); 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(
return @as(WantedT, @intCast(result)); return @as(WantedT, @intCast(result));
} }
/// This function is intended to assert that `isByRef` returns `false` for `ty`. /// Asserts that `isByRef` returns `false` for `ty`.
/// However such an assertion fails on the behavior tests currently.
fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue { fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
const mod = func.bin_file.base.comp.module.?; const mod = func.bin_file.base.comp.module.?;
// TODO: enable this assertion assert(!isByRef(ty, mod));
//assert(!isByRef(ty, mod));
const ip = &mod.intern_pool; const ip = &mod.intern_pool;
if (val.isUndefDeep(mod)) return func.emitUndefined(ty); if (val.isUndefDeep(mod)) return func.emitUndefined(ty);

View File

@ -1284,7 +1284,6 @@ test "matching captures causes enum equivalence" {
} }
test "large enum field values" { test "large enum field values" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;