authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-11 21:21:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
log2be36c5b8d7d22c2ffc20b88e497da7e6612de5c
tree05c9d7f58e82ff51ffa5be439ff75b37abe3b6ba
parent2bef0715c740024c515dce73d267ead5af49d1a9

linker: update references to module


10 files changed, 179 insertions(+), 179 deletions(-)

src/arch/wasm/CodeGen.zig+118-118
...@@ -766,7 +766,7 @@ pub fn deinit(func: *CodeGen) void {...@@ -766,7 +766,7 @@ pub fn deinit(func: *CodeGen) void {
766766
767/// Sets `err_msg` on `CodeGen` and returns `error.CodegenFail` which is caught in link/Wasm.zig767/// Sets `err_msg` on `CodeGen` and returns `error.CodegenFail` which is caught in link/Wasm.zig
768fn fail(func: *CodeGen, comptime fmt: []const u8, args: anytype) InnerError {768fn fail(func: *CodeGen, comptime fmt: []const u8, args: anytype) InnerError {
769 const mod = func.bin_file.base.options.module.?;769 const mod = func.bin_file.base.comp.module.?;
770 const src = LazySrcLoc.nodeOffset(0);770 const src = LazySrcLoc.nodeOffset(0);
771 const src_loc = src.toSrcLoc(func.decl, mod);771 const src_loc = src.toSrcLoc(func.decl, mod);
772 func.err_msg = try Module.ErrorMsg.create(func.gpa, src_loc, fmt, args);772 func.err_msg = try Module.ErrorMsg.create(func.gpa, src_loc, fmt, args);
...@@ -791,7 +791,7 @@ fn resolveInst(func: *CodeGen, ref: Air.Inst.Ref) InnerError!WValue {...@@ -791,7 +791,7 @@ fn resolveInst(func: *CodeGen, ref: Air.Inst.Ref) InnerError!WValue {
791 const gop = try func.branches.items[0].values.getOrPut(func.gpa, ref);791 const gop = try func.branches.items[0].values.getOrPut(func.gpa, ref);
792 assert(!gop.found_existing);792 assert(!gop.found_existing);
793793
794 const mod = func.bin_file.base.options.module.?;794 const mod = func.bin_file.base.comp.module.?;
795 const val = (try func.air.value(ref, mod)).?;795 const val = (try func.air.value(ref, mod)).?;
796 const ty = func.typeOf(ref);796 const ty = func.typeOf(ref);
797 if (!ty.hasRuntimeBitsIgnoreComptime(mod) and !ty.isInt(mod) and !ty.isError(mod)) {797 if (!ty.hasRuntimeBitsIgnoreComptime(mod) and !ty.isInt(mod) and !ty.isError(mod)) {
...@@ -1101,7 +1101,7 @@ fn getResolvedInst(func: *CodeGen, ref: Air.Inst.Ref) *WValue {...@@ -1101,7 +1101,7 @@ fn getResolvedInst(func: *CodeGen, ref: Air.Inst.Ref) *WValue {
1101/// Creates one locals for a given `Type`.1101/// Creates one locals for a given `Type`.
1102/// Returns a corresponding `Wvalue` with `local` as active tag1102/// Returns a corresponding `Wvalue` with `local` as active tag
1103fn allocLocal(func: *CodeGen, ty: Type) InnerError!WValue {1103fn allocLocal(func: *CodeGen, ty: Type) InnerError!WValue {
1104 const mod = func.bin_file.base.options.module.?;1104 const mod = func.bin_file.base.comp.module.?;
1105 const valtype = typeToValtype(ty, mod);1105 const valtype = typeToValtype(ty, mod);
1106 switch (valtype) {1106 switch (valtype) {
1107 .i32 => if (func.free_locals_i32.popOrNull()) |index| {1107 .i32 => if (func.free_locals_i32.popOrNull()) |index| {
...@@ -1133,7 +1133,7 @@ fn allocLocal(func: *CodeGen, ty: Type) InnerError!WValue {...@@ -1133,7 +1133,7 @@ fn allocLocal(func: *CodeGen, ty: Type) InnerError!WValue {
1133/// Ensures a new local will be created. This is useful when it's useful1133/// Ensures a new local will be created. This is useful when it's useful
1134/// to use a zero-initialized local.1134/// to use a zero-initialized local.
1135fn ensureAllocLocal(func: *CodeGen, ty: Type) InnerError!WValue {1135fn ensureAllocLocal(func: *CodeGen, ty: Type) InnerError!WValue {
1136 const mod = func.bin_file.base.options.module.?;1136 const mod = func.bin_file.base.comp.module.?;
1137 try func.locals.append(func.gpa, genValtype(ty, mod));1137 try func.locals.append(func.gpa, genValtype(ty, mod));
1138 const initial_index = func.local_index;1138 const initial_index = func.local_index;
1139 func.local_index += 1;1139 func.local_index += 1;
...@@ -1237,7 +1237,7 @@ pub fn generate(...@@ -1237,7 +1237,7 @@ pub fn generate(
1237}1237}
12381238
1239fn genFunc(func: *CodeGen) InnerError!void {1239fn genFunc(func: *CodeGen) InnerError!void {
1240 const mod = func.bin_file.base.options.module.?;1240 const mod = func.bin_file.base.comp.module.?;
1241 const ip = &mod.intern_pool;1241 const ip = &mod.intern_pool;
1242 const fn_info = mod.typeToFunc(func.decl.ty).?;1242 const fn_info = mod.typeToFunc(func.decl.ty).?;
1243 var func_type = try genFunctype(func.gpa, fn_info.cc, fn_info.param_types.get(ip), Type.fromInterned(fn_info.return_type), mod);1243 var func_type = try genFunctype(func.gpa, fn_info.cc, fn_info.param_types.get(ip), Type.fromInterned(fn_info.return_type), mod);
...@@ -1348,7 +1348,7 @@ const CallWValues = struct {...@@ -1348,7 +1348,7 @@ const CallWValues = struct {
1348};1348};
13491349
1350fn resolveCallingConventionValues(func: *CodeGen, fn_ty: Type) InnerError!CallWValues {1350fn resolveCallingConventionValues(func: *CodeGen, fn_ty: Type) InnerError!CallWValues {
1351 const mod = func.bin_file.base.options.module.?;1351 const mod = func.bin_file.base.comp.module.?;
1352 const ip = &mod.intern_pool;1352 const ip = &mod.intern_pool;
1353 const fn_info = mod.typeToFunc(fn_ty).?;1353 const fn_info = mod.typeToFunc(fn_ty).?;
1354 const cc = fn_info.cc;1354 const cc = fn_info.cc;
...@@ -1417,7 +1417,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:...@@ -1417,7 +1417,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:
1417 return func.lowerToStack(value);1417 return func.lowerToStack(value);
1418 }1418 }
14191419
1420 const mod = func.bin_file.base.options.module.?;1420 const mod = func.bin_file.base.comp.module.?;
1421 const ty_classes = abi.classifyType(ty, mod);1421 const ty_classes = abi.classifyType(ty, mod);
1422 assert(ty_classes[0] != .none);1422 assert(ty_classes[0] != .none);
1423 switch (ty.zigTypeTag(mod)) {1423 switch (ty.zigTypeTag(mod)) {
...@@ -1516,7 +1516,7 @@ fn restoreStackPointer(func: *CodeGen) !void {...@@ -1516,7 +1516,7 @@ fn restoreStackPointer(func: *CodeGen) !void {
1516///1516///
1517/// Asserts Type has codegenbits1517/// Asserts Type has codegenbits
1518fn allocStack(func: *CodeGen, ty: Type) !WValue {1518fn allocStack(func: *CodeGen, ty: Type) !WValue {
1519 const mod = func.bin_file.base.options.module.?;1519 const mod = func.bin_file.base.comp.module.?;
1520 assert(ty.hasRuntimeBitsIgnoreComptime(mod));1520 assert(ty.hasRuntimeBitsIgnoreComptime(mod));
1521 if (func.initial_stack_value == .none) {1521 if (func.initial_stack_value == .none) {
1522 try func.initializeStack();1522 try func.initializeStack();
...@@ -1542,7 +1542,7 @@ fn allocStack(func: *CodeGen, ty: Type) !WValue {...@@ -1542,7 +1542,7 @@ fn allocStack(func: *CodeGen, ty: Type) !WValue {
1542/// This is different from allocStack where this will use the pointer's alignment1542/// This is different from allocStack where this will use the pointer's alignment
1543/// if it is set, to ensure the stack alignment will be set correctly.1543/// if it is set, to ensure the stack alignment will be set correctly.
1544fn allocStackPtr(func: *CodeGen, inst: Air.Inst.Index) !WValue {1544fn allocStackPtr(func: *CodeGen, inst: Air.Inst.Index) !WValue {
1545 const mod = func.bin_file.base.options.module.?;1545 const mod = func.bin_file.base.comp.module.?;
1546 const ptr_ty = func.typeOfIndex(inst);1546 const ptr_ty = func.typeOfIndex(inst);
1547 const pointee_ty = ptr_ty.childType(mod);1547 const pointee_ty = ptr_ty.childType(mod);
15481548
...@@ -2072,7 +2072,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2072,7 +2072,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2072}2072}
20732073
2074fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {2074fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2075 const mod = func.bin_file.base.options.module.?;2075 const mod = func.bin_file.base.comp.module.?;
2076 const ip = &mod.intern_pool;2076 const ip = &mod.intern_pool;
20772077
2078 for (body) |inst| {2078 for (body) |inst| {
...@@ -2093,7 +2093,7 @@ fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -2093,7 +2093,7 @@ fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2093}2093}
20942094
2095fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2095fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2096 const mod = func.bin_file.base.options.module.?;2096 const mod = func.bin_file.base.comp.module.?;
2097 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;2097 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
2098 const operand = try func.resolveInst(un_op);2098 const operand = try func.resolveInst(un_op);
2099 const fn_info = mod.typeToFunc(func.decl.ty).?;2099 const fn_info = mod.typeToFunc(func.decl.ty).?;
...@@ -2136,7 +2136,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2136,7 +2136,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2136}2136}
21372137
2138fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2138fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2139 const mod = func.bin_file.base.options.module.?;2139 const mod = func.bin_file.base.comp.module.?;
2140 const child_type = func.typeOfIndex(inst).childType(mod);2140 const child_type = func.typeOfIndex(inst).childType(mod);
21412141
2142 const result = result: {2142 const result = result: {
...@@ -2156,7 +2156,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2156,7 +2156,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2156}2156}
21572157
2158fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2158fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2159 const mod = func.bin_file.base.options.module.?;2159 const mod = func.bin_file.base.comp.module.?;
2160 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;2160 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
2161 const operand = try func.resolveInst(un_op);2161 const operand = try func.resolveInst(un_op);
2162 const ret_ty = func.typeOf(un_op).childType(mod);2162 const ret_ty = func.typeOf(un_op).childType(mod);
...@@ -2183,7 +2183,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif...@@ -2183,7 +2183,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
2183 const args = @as([]const Air.Inst.Ref, @ptrCast(func.air.extra[extra.end..][0..extra.data.args_len]));2183 const args = @as([]const Air.Inst.Ref, @ptrCast(func.air.extra[extra.end..][0..extra.data.args_len]));
2184 const ty = func.typeOf(pl_op.operand);2184 const ty = func.typeOf(pl_op.operand);
21852185
2186 const mod = func.bin_file.base.options.module.?;2186 const mod = func.bin_file.base.comp.module.?;
2187 const ip = &mod.intern_pool;2187 const ip = &mod.intern_pool;
2188 const fn_ty = switch (ty.zigTypeTag(mod)) {2188 const fn_ty = switch (ty.zigTypeTag(mod)) {
2189 .Fn => ty,2189 .Fn => ty,
...@@ -2295,7 +2295,7 @@ fn airAlloc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2295,7 +2295,7 @@ fn airAlloc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2295}2295}
22962296
2297fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {2297fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
2298 const mod = func.bin_file.base.options.module.?;2298 const mod = func.bin_file.base.comp.module.?;
2299 if (safety) {2299 if (safety) {
2300 // TODO if the value is undef, write 0xaa bytes to dest2300 // TODO if the value is undef, write 0xaa bytes to dest
2301 } else {2301 } else {
...@@ -2349,7 +2349,7 @@ fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void...@@ -2349,7 +2349,7 @@ fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void
23492349
2350fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerError!void {2350fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerError!void {
2351 assert(!(lhs != .stack and rhs == .stack));2351 assert(!(lhs != .stack and rhs == .stack));
2352 const mod = func.bin_file.base.options.module.?;2352 const mod = func.bin_file.base.comp.module.?;
2353 const abi_size = ty.abiSize(mod);2353 const abi_size = ty.abiSize(mod);
2354 switch (ty.zigTypeTag(mod)) {2354 switch (ty.zigTypeTag(mod)) {
2355 .ErrorUnion => {2355 .ErrorUnion => {
...@@ -2428,7 +2428,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2428,7 +2428,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2428 },2428 },
2429 else => if (abi_size > 8) {2429 else => if (abi_size > 8) {
2430 return func.fail("TODO: `store` for type `{}` with abisize `{d}`", .{2430 return func.fail("TODO: `store` for type `{}` with abisize `{d}`", .{
2431 ty.fmt(func.bin_file.base.options.module.?),2431 ty.fmt(func.bin_file.base.comp.module.?),
2432 abi_size,2432 abi_size,
2433 });2433 });
2434 },2434 },
...@@ -2456,7 +2456,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2456,7 +2456,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2456}2456}
24572457
2458fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2458fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2459 const mod = func.bin_file.base.options.module.?;2459 const mod = func.bin_file.base.comp.module.?;
2460 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2460 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2461 const operand = try func.resolveInst(ty_op.operand);2461 const operand = try func.resolveInst(ty_op.operand);
2462 const ty = ty_op.ty.toType();2462 const ty = ty_op.ty.toType();
...@@ -2499,7 +2499,7 @@ fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2499,7 +2499,7 @@ fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2499/// Loads an operand from the linear memory section.2499/// Loads an operand from the linear memory section.
2500/// NOTE: Leaves the value on the stack.2500/// NOTE: Leaves the value on the stack.
2501fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValue {2501fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValue {
2502 const mod = func.bin_file.base.options.module.?;2502 const mod = func.bin_file.base.comp.module.?;
2503 // load local's value from memory by its stack position2503 // load local's value from memory by its stack position
2504 try func.emitWValue(operand);2504 try func.emitWValue(operand);
25052505
...@@ -2536,7 +2536,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu...@@ -2536,7 +2536,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu
2536}2536}
25372537
2538fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2538fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2539 const mod = func.bin_file.base.options.module.?;2539 const mod = func.bin_file.base.comp.module.?;
2540 const arg_index = func.arg_index;2540 const arg_index = func.arg_index;
2541 const arg = func.args[arg_index];2541 const arg = func.args[arg_index];
2542 const cc = mod.typeToFunc(func.decl.ty).?.cc;2542 const cc = mod.typeToFunc(func.decl.ty).?.cc;
...@@ -2555,7 +2555,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2555,7 +2555,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2555 if (arg_ty.zigTypeTag(mod) != .Int and arg_ty.zigTypeTag(mod) != .Float) {2555 if (arg_ty.zigTypeTag(mod) != .Int and arg_ty.zigTypeTag(mod) != .Float) {
2556 return func.fail(2556 return func.fail(
2557 "TODO: Implement C-ABI argument for type '{}'",2557 "TODO: Implement C-ABI argument for type '{}'",
2558 .{arg_ty.fmt(func.bin_file.base.options.module.?)},2558 .{arg_ty.fmt(func.bin_file.base.comp.module.?)},
2559 );2559 );
2560 }2560 }
2561 const result = try func.allocStack(arg_ty);2561 const result = try func.allocStack(arg_ty);
...@@ -2582,7 +2582,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2582,7 +2582,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2582}2582}
25832583
2584fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {2584fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
2585 const mod = func.bin_file.base.options.module.?;2585 const mod = func.bin_file.base.comp.module.?;
2586 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2586 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
2587 const lhs = try func.resolveInst(bin_op.lhs);2587 const lhs = try func.resolveInst(bin_op.lhs);
2588 const rhs = try func.resolveInst(bin_op.rhs);2588 const rhs = try func.resolveInst(bin_op.rhs);
...@@ -2619,7 +2619,7 @@ fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -2619,7 +2619,7 @@ fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
2619/// Performs a binary operation on the given `WValue`'s2619/// Performs a binary operation on the given `WValue`'s
2620/// NOTE: THis leaves the value on top of the stack.2620/// NOTE: THis leaves the value on top of the stack.
2621fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {2621fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {
2622 const mod = func.bin_file.base.options.module.?;2622 const mod = func.bin_file.base.comp.module.?;
2623 assert(!(lhs != .stack and rhs == .stack));2623 assert(!(lhs != .stack and rhs == .stack));
26242624
2625 if (ty.isAnyFloat()) {2625 if (ty.isAnyFloat()) {
...@@ -2633,7 +2633,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!...@@ -2633,7 +2633,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!
2633 } else {2633 } else {
2634 return func.fail(2634 return func.fail(
2635 "TODO: Implement binary operation for type: {}",2635 "TODO: Implement binary operation for type: {}",
2636 .{ty.fmt(func.bin_file.base.options.module.?)},2636 .{ty.fmt(func.bin_file.base.comp.module.?)},
2637 );2637 );
2638 }2638 }
2639 }2639 }
...@@ -2652,7 +2652,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!...@@ -2652,7 +2652,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!
2652}2652}
26532653
2654fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {2654fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {
2655 const mod = func.bin_file.base.options.module.?;2655 const mod = func.bin_file.base.comp.module.?;
2656 const int_info = ty.intInfo(mod);2656 const int_info = ty.intInfo(mod);
2657 if (int_info.bits > 128) {2657 if (int_info.bits > 128) {
2658 return func.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{});2658 return func.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{});
...@@ -2788,7 +2788,7 @@ const FloatOp = enum {...@@ -2788,7 +2788,7 @@ const FloatOp = enum {
2788};2788};
27892789
2790fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {2790fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2791 const mod = func.bin_file.base.options.module.?;2791 const mod = func.bin_file.base.comp.module.?;
2792 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;2792 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2793 const operand = try func.resolveInst(ty_op.operand);2793 const operand = try func.resolveInst(ty_op.operand);
2794 const ty = func.typeOf(ty_op.operand);2794 const ty = func.typeOf(ty_op.operand);
...@@ -2873,7 +2873,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError...@@ -2873,7 +2873,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError
2873}2873}
28742874
2875fn floatOp(func: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {2875fn floatOp(func: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {
2876 const mod = func.bin_file.base.options.module.?;2876 const mod = func.bin_file.base.comp.module.?;
2877 if (ty.zigTypeTag(mod) == .Vector) {2877 if (ty.zigTypeTag(mod) == .Vector) {
2878 return func.fail("TODO: Implement floatOps for vectors", .{});2878 return func.fail("TODO: Implement floatOps for vectors", .{});
2879 }2879 }
...@@ -2979,7 +2979,7 @@ fn floatNeg(func: *CodeGen, ty: Type, arg: WValue) InnerError!WValue {...@@ -2979,7 +2979,7 @@ fn floatNeg(func: *CodeGen, ty: Type, arg: WValue) InnerError!WValue {
2979}2979}
29802980
2981fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {2981fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
2982 const mod = func.bin_file.base.options.module.?;2982 const mod = func.bin_file.base.comp.module.?;
2983 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2983 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
29842984
2985 const lhs = try func.resolveInst(bin_op.lhs);2985 const lhs = try func.resolveInst(bin_op.lhs);
...@@ -3030,7 +3030,7 @@ fn wrapBinOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerEr...@@ -3030,7 +3030,7 @@ fn wrapBinOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerEr
3030/// Asserts `Type` is <= 128 bits.3030/// Asserts `Type` is <= 128 bits.
3031/// NOTE: When the Type is <= 64 bits, leaves the value on top of the stack.3031/// NOTE: When the Type is <= 64 bits, leaves the value on top of the stack.
3032fn wrapOperand(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {3032fn wrapOperand(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {
3033 const mod = func.bin_file.base.options.module.?;3033 const mod = func.bin_file.base.comp.module.?;
3034 assert(ty.abiSize(mod) <= 16);3034 assert(ty.abiSize(mod) <= 16);
3035 const bitsize = @as(u16, @intCast(ty.bitSize(mod)));3035 const bitsize = @as(u16, @intCast(ty.bitSize(mod)));
3036 const wasm_bits = toWasmBits(bitsize) orelse {3036 const wasm_bits = toWasmBits(bitsize) orelse {
...@@ -3069,7 +3069,7 @@ fn wrapOperand(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {...@@ -3069,7 +3069,7 @@ fn wrapOperand(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {
3069}3069}
30703070
3071fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue {3071fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue {
3072 const mod = func.bin_file.base.options.module.?;3072 const mod = func.bin_file.base.comp.module.?;
3073 const ptr = mod.intern_pool.indexToKey(ptr_val.ip_index).ptr;3073 const ptr = mod.intern_pool.indexToKey(ptr_val.ip_index).ptr;
3074 switch (ptr.addr) {3074 switch (ptr.addr) {
3075 .decl => |decl_index| {3075 .decl => |decl_index| {
...@@ -3132,7 +3132,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue...@@ -3132,7 +3132,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue
3132}3132}
31333133
3134fn lowerParentPtrDecl(func: *CodeGen, ptr_val: Value, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue {3134fn lowerParentPtrDecl(func: *CodeGen, ptr_val: Value, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue {
3135 const mod = func.bin_file.base.options.module.?;3135 const mod = func.bin_file.base.comp.module.?;
3136 const decl = mod.declPtr(decl_index);3136 const decl = mod.declPtr(decl_index);
3137 try mod.markDeclAlive(decl);3137 try mod.markDeclAlive(decl);
3138 const ptr_ty = try mod.singleMutPtrType(decl.ty);3138 const ptr_ty = try mod.singleMutPtrType(decl.ty);
...@@ -3144,7 +3144,7 @@ fn lowerAnonDeclRef(...@@ -3144,7 +3144,7 @@ fn lowerAnonDeclRef(
3144 anon_decl: InternPool.Key.Ptr.Addr.AnonDecl,3144 anon_decl: InternPool.Key.Ptr.Addr.AnonDecl,
3145 offset: u32,3145 offset: u32,
3146) InnerError!WValue {3146) InnerError!WValue {
3147 const mod = func.bin_file.base.options.module.?;3147 const mod = func.bin_file.base.comp.module.?;
3148 const decl_val = anon_decl.val;3148 const decl_val = anon_decl.val;
3149 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));3149 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
31503150
...@@ -3172,7 +3172,7 @@ fn lowerAnonDeclRef(...@@ -3172,7 +3172,7 @@ fn lowerAnonDeclRef(
3172}3172}
31733173
3174fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue {3174fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue {
3175 const mod = func.bin_file.base.options.module.?;3175 const mod = func.bin_file.base.comp.module.?;
3176 if (tv.ty.isSlice(mod)) {3176 if (tv.ty.isSlice(mod)) {
3177 return WValue{ .memory = try func.bin_file.lowerUnnamedConst(tv, decl_index) };3177 return WValue{ .memory = try func.bin_file.lowerUnnamedConst(tv, decl_index) };
3178 }3178 }
...@@ -3225,7 +3225,7 @@ fn toTwosComplement(value: anytype, bits: u7) std.meta.Int(.unsigned, @typeInfo(...@@ -3225,7 +3225,7 @@ fn toTwosComplement(value: anytype, bits: u7) std.meta.Int(.unsigned, @typeInfo(
3225/// This function is intended to assert that `isByRef` returns `false` for `ty`.3225/// This function is intended to assert that `isByRef` returns `false` for `ty`.
3226/// However such an assertion fails on the behavior tests currently.3226/// However such an assertion fails on the behavior tests currently.
3227fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {3227fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
3228 const mod = func.bin_file.base.options.module.?;3228 const mod = func.bin_file.base.comp.module.?;
3229 // TODO: enable this assertion3229 // TODO: enable this assertion
3230 //assert(!isByRef(ty, mod));3230 //assert(!isByRef(ty, mod));
3231 const ip = &mod.intern_pool;3231 const ip = &mod.intern_pool;
...@@ -3394,7 +3394,7 @@ fn storeSimdImmd(func: *CodeGen, value: [16]u8) !WValue {...@@ -3394,7 +3394,7 @@ fn storeSimdImmd(func: *CodeGen, value: [16]u8) !WValue {
3394}3394}
33953395
3396fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {3396fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {
3397 const mod = func.bin_file.base.options.module.?;3397 const mod = func.bin_file.base.comp.module.?;
3398 const ip = &mod.intern_pool;3398 const ip = &mod.intern_pool;
3399 switch (ty.zigTypeTag(mod)) {3399 switch (ty.zigTypeTag(mod)) {
3400 .Bool, .ErrorSet => return WValue{ .imm32 = 0xaaaaaaaa },3400 .Bool, .ErrorSet => return WValue{ .imm32 = 0xaaaaaaaa },
...@@ -3436,7 +3436,7 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {...@@ -3436,7 +3436,7 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {
3436/// It's illegal to provide a value with a type that cannot be represented3436/// It's illegal to provide a value with a type that cannot be represented
3437/// as an integer value.3437/// as an integer value.
3438fn valueAsI32(func: *const CodeGen, val: Value, ty: Type) i32 {3438fn valueAsI32(func: *const CodeGen, val: Value, ty: Type) i32 {
3439 const mod = func.bin_file.base.options.module.?;3439 const mod = func.bin_file.base.comp.module.?;
34403440
3441 switch (val.ip_index) {3441 switch (val.ip_index) {
3442 .none => {},3442 .none => {},
...@@ -3472,7 +3472,7 @@ fn intStorageAsI32(storage: InternPool.Key.Int.Storage, mod: *Module) i32 {...@@ -3472,7 +3472,7 @@ fn intStorageAsI32(storage: InternPool.Key.Int.Storage, mod: *Module) i32 {
3472}3472}
34733473
3474fn airBlock(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {3474fn airBlock(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3475 const mod = func.bin_file.base.options.module.?;3475 const mod = func.bin_file.base.comp.module.?;
3476 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3476 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3477 const block_ty = ty_pl.ty.toType();3477 const block_ty = ty_pl.ty.toType();
3478 const wasm_block_ty = genBlockType(block_ty, mod);3478 const wasm_block_ty = genBlockType(block_ty, mod);
...@@ -3593,7 +3593,7 @@ fn airCmp(func: *CodeGen, inst: Air.Inst.Index, op: std.math.CompareOperator) In...@@ -3593,7 +3593,7 @@ fn airCmp(func: *CodeGen, inst: Air.Inst.Index, op: std.math.CompareOperator) In
3593/// NOTE: This leaves the result on top of the stack, rather than a new local.3593/// NOTE: This leaves the result on top of the stack, rather than a new local.
3594fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareOperator) InnerError!WValue {3594fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareOperator) InnerError!WValue {
3595 assert(!(lhs != .stack and rhs == .stack));3595 assert(!(lhs != .stack and rhs == .stack));
3596 const mod = func.bin_file.base.options.module.?;3596 const mod = func.bin_file.base.comp.module.?;
3597 if (ty.zigTypeTag(mod) == .Optional and !ty.optionalReprIsPayload(mod)) {3597 if (ty.zigTypeTag(mod) == .Optional and !ty.optionalReprIsPayload(mod)) {
3598 const payload_ty = ty.optionalChild(mod);3598 const payload_ty = ty.optionalChild(mod);
3599 if (payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {3599 if (payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -3711,7 +3711,7 @@ fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3711,7 +3711,7 @@ fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3711 const errors_len = WValue{ .memory = sym_index };3711 const errors_len = WValue{ .memory = sym_index };
37123712
3713 try func.emitWValue(operand);3713 try func.emitWValue(operand);
3714 const mod = func.bin_file.base.options.module.?;3714 const mod = func.bin_file.base.comp.module.?;
3715 const err_int_ty = try mod.errorIntType();3715 const err_int_ty = try mod.errorIntType();
3716 const errors_len_val = try func.load(errors_len, err_int_ty, 0);3716 const errors_len_val = try func.load(errors_len, err_int_ty, 0);
3717 const result = try func.cmp(.stack, errors_len_val, err_int_ty, .lt);3717 const result = try func.cmp(.stack, errors_len_val, err_int_ty, .lt);
...@@ -3720,7 +3720,7 @@ fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3720,7 +3720,7 @@ fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3720}3720}
37213721
3722fn airBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {3722fn airBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3723 const mod = func.bin_file.base.options.module.?;3723 const mod = func.bin_file.base.comp.module.?;
3724 const br = func.air.instructions.items(.data)[@intFromEnum(inst)].br;3724 const br = func.air.instructions.items(.data)[@intFromEnum(inst)].br;
3725 const block = func.blocks.get(br.block_inst).?;3725 const block = func.blocks.get(br.block_inst).?;
37263726
...@@ -3747,7 +3747,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3747,7 +3747,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
37473747
3748 const operand = try func.resolveInst(ty_op.operand);3748 const operand = try func.resolveInst(ty_op.operand);
3749 const operand_ty = func.typeOf(ty_op.operand);3749 const operand_ty = func.typeOf(ty_op.operand);
3750 const mod = func.bin_file.base.options.module.?;3750 const mod = func.bin_file.base.comp.module.?;
37513751
3752 const result = result: {3752 const result = result: {
3753 if (operand_ty.zigTypeTag(mod) == .Bool) {3753 if (operand_ty.zigTypeTag(mod) == .Bool) {
...@@ -3818,7 +3818,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3818,7 +3818,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3818 const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand);3818 const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand);
3819 break :result try bitcast_result.toLocal(func, wanted_ty);3819 break :result try bitcast_result.toLocal(func, wanted_ty);
3820 }3820 }
3821 const mod = func.bin_file.base.options.module.?;3821 const mod = func.bin_file.base.comp.module.?;
3822 if (isByRef(given_ty, mod) and !isByRef(wanted_ty, mod)) {3822 if (isByRef(given_ty, mod) and !isByRef(wanted_ty, mod)) {
3823 const loaded_memory = try func.load(operand, wanted_ty, 0);3823 const loaded_memory = try func.load(operand, wanted_ty, 0);
3824 break :result try loaded_memory.toLocal(func, wanted_ty);3824 break :result try loaded_memory.toLocal(func, wanted_ty);
...@@ -3834,7 +3834,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3834,7 +3834,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3834}3834}
38353835
3836fn bitcast(func: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) InnerError!WValue {3836fn bitcast(func: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) InnerError!WValue {
3837 const mod = func.bin_file.base.options.module.?;3837 const mod = func.bin_file.base.comp.module.?;
3838 // if we bitcast a float to or from an integer we must use the 'reinterpret' instruction3838 // if we bitcast a float to or from an integer we must use the 'reinterpret' instruction
3839 if (!(wanted_ty.isAnyFloat() or given_ty.isAnyFloat())) return operand;3839 if (!(wanted_ty.isAnyFloat() or given_ty.isAnyFloat())) return operand;
3840 if (wanted_ty.ip_index == .f16_type or given_ty.ip_index == .f16_type) return operand;3840 if (wanted_ty.ip_index == .f16_type or given_ty.ip_index == .f16_type) return operand;
...@@ -3852,7 +3852,7 @@ fn bitcast(func: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) Inn...@@ -3852,7 +3852,7 @@ fn bitcast(func: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) Inn
3852}3852}
38533853
3854fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {3854fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3855 const mod = func.bin_file.base.options.module.?;3855 const mod = func.bin_file.base.comp.module.?;
3856 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3856 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3857 const extra = func.air.extraData(Air.StructField, ty_pl.payload);3857 const extra = func.air.extraData(Air.StructField, ty_pl.payload);
38583858
...@@ -3864,7 +3864,7 @@ fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3864,7 +3864,7 @@ fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3864}3864}
38653865
3866fn airStructFieldPtrIndex(func: *CodeGen, inst: Air.Inst.Index, index: u32) InnerError!void {3866fn airStructFieldPtrIndex(func: *CodeGen, inst: Air.Inst.Index, index: u32) InnerError!void {
3867 const mod = func.bin_file.base.options.module.?;3867 const mod = func.bin_file.base.comp.module.?;
3868 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3868 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3869 const struct_ptr = try func.resolveInst(ty_op.operand);3869 const struct_ptr = try func.resolveInst(ty_op.operand);
3870 const struct_ptr_ty = func.typeOf(ty_op.operand);3870 const struct_ptr_ty = func.typeOf(ty_op.operand);
...@@ -3883,7 +3883,7 @@ fn structFieldPtr(...@@ -3883,7 +3883,7 @@ fn structFieldPtr(
3883 struct_ty: Type,3883 struct_ty: Type,
3884 index: u32,3884 index: u32,
3885) InnerError!WValue {3885) InnerError!WValue {
3886 const mod = func.bin_file.base.options.module.?;3886 const mod = func.bin_file.base.comp.module.?;
3887 const result_ty = func.typeOfIndex(inst);3887 const result_ty = func.typeOfIndex(inst);
3888 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);3888 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
38893889
...@@ -3914,7 +3914,7 @@ fn structFieldPtr(...@@ -3914,7 +3914,7 @@ fn structFieldPtr(
3914}3914}
39153915
3916fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {3916fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3917 const mod = func.bin_file.base.options.module.?;3917 const mod = func.bin_file.base.comp.module.?;
3918 const ip = &mod.intern_pool;3918 const ip = &mod.intern_pool;
3919 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3919 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3920 const struct_field = func.air.extraData(Air.StructField, ty_pl.payload).data;3920 const struct_field = func.air.extraData(Air.StructField, ty_pl.payload).data;
...@@ -4013,7 +4013,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4013,7 +4013,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4013}4013}
40144014
4015fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4015fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4016 const mod = func.bin_file.base.options.module.?;4016 const mod = func.bin_file.base.comp.module.?;
4017 // result type is always 'noreturn'4017 // result type is always 'noreturn'
4018 const blocktype = wasm.block_empty;4018 const blocktype = wasm.block_empty;
4019 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;4019 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
...@@ -4193,7 +4193,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4193,7 +4193,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4193}4193}
41944194
4195fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerError!void {4195fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerError!void {
4196 const mod = func.bin_file.base.options.module.?;4196 const mod = func.bin_file.base.comp.module.?;
4197 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4197 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4198 const operand = try func.resolveInst(un_op);4198 const operand = try func.resolveInst(un_op);
4199 const err_union_ty = func.typeOf(un_op);4199 const err_union_ty = func.typeOf(un_op);
...@@ -4228,7 +4228,7 @@ fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerErro...@@ -4228,7 +4228,7 @@ fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerErro
4228}4228}
42294229
4230fn airUnwrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {4230fn airUnwrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {
4231 const mod = func.bin_file.base.options.module.?;4231 const mod = func.bin_file.base.comp.module.?;
4232 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4232 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
42334233
4234 const operand = try func.resolveInst(ty_op.operand);4234 const operand = try func.resolveInst(ty_op.operand);
...@@ -4256,7 +4256,7 @@ fn airUnwrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: boo...@@ -4256,7 +4256,7 @@ fn airUnwrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: boo
4256}4256}
42574257
4258fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {4258fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {
4259 const mod = func.bin_file.base.options.module.?;4259 const mod = func.bin_file.base.comp.module.?;
4260 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4260 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
42614261
4262 const operand = try func.resolveInst(ty_op.operand);4262 const operand = try func.resolveInst(ty_op.operand);
...@@ -4280,7 +4280,7 @@ fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)...@@ -4280,7 +4280,7 @@ fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)
4280}4280}
42814281
4282fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4282fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4283 const mod = func.bin_file.base.options.module.?;4283 const mod = func.bin_file.base.comp.module.?;
4284 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4284 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
42854285
4286 const operand = try func.resolveInst(ty_op.operand);4286 const operand = try func.resolveInst(ty_op.operand);
...@@ -4310,7 +4310,7 @@ fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void...@@ -4310,7 +4310,7 @@ fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void
4310}4310}
43114311
4312fn airWrapErrUnionErr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4312fn airWrapErrUnionErr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4313 const mod = func.bin_file.base.options.module.?;4313 const mod = func.bin_file.base.comp.module.?;
4314 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4314 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
43154315
4316 const operand = try func.resolveInst(ty_op.operand);4316 const operand = try func.resolveInst(ty_op.operand);
...@@ -4342,7 +4342,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4342,7 +4342,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4342 const ty = ty_op.ty.toType();4342 const ty = ty_op.ty.toType();
4343 const operand = try func.resolveInst(ty_op.operand);4343 const operand = try func.resolveInst(ty_op.operand);
4344 const operand_ty = func.typeOf(ty_op.operand);4344 const operand_ty = func.typeOf(ty_op.operand);
4345 const mod = func.bin_file.base.options.module.?;4345 const mod = func.bin_file.base.comp.module.?;
4346 if (ty.zigTypeTag(mod) == .Vector or operand_ty.zigTypeTag(mod) == .Vector) {4346 if (ty.zigTypeTag(mod) == .Vector or operand_ty.zigTypeTag(mod) == .Vector) {
4347 return func.fail("todo Wasm intcast for vectors", .{});4347 return func.fail("todo Wasm intcast for vectors", .{});
4348 }4348 }
...@@ -4365,7 +4365,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4365,7 +4365,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4365/// Asserts type's bitsize <= 1284365/// Asserts type's bitsize <= 128
4366/// NOTE: May leave the result on the top of the stack.4366/// NOTE: May leave the result on the top of the stack.
4367fn intcast(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!WValue {4367fn intcast(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!WValue {
4368 const mod = func.bin_file.base.options.module.?;4368 const mod = func.bin_file.base.comp.module.?;
4369 const given_bitsize = @as(u16, @intCast(given.bitSize(mod)));4369 const given_bitsize = @as(u16, @intCast(given.bitSize(mod)));
4370 const wanted_bitsize = @as(u16, @intCast(wanted.bitSize(mod)));4370 const wanted_bitsize = @as(u16, @intCast(wanted.bitSize(mod)));
4371 assert(given_bitsize <= 128);4371 assert(given_bitsize <= 128);
...@@ -4433,7 +4433,7 @@ fn intcast(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerErro...@@ -4433,7 +4433,7 @@ fn intcast(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerErro
4433}4433}
44344434
4435fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind: enum { value, ptr }) InnerError!void {4435fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind: enum { value, ptr }) InnerError!void {
4436 const mod = func.bin_file.base.options.module.?;4436 const mod = func.bin_file.base.comp.module.?;
4437 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4437 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4438 const operand = try func.resolveInst(un_op);4438 const operand = try func.resolveInst(un_op);
44394439
...@@ -4447,7 +4447,7 @@ fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind:...@@ -4447,7 +4447,7 @@ fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind:
4447/// For a given type and operand, checks if it's considered `null`.4447/// For a given type and operand, checks if it's considered `null`.
4448/// NOTE: Leaves the result on the stack4448/// NOTE: Leaves the result on the stack
4449fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcode) InnerError!WValue {4449fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcode) InnerError!WValue {
4450 const mod = func.bin_file.base.options.module.?;4450 const mod = func.bin_file.base.comp.module.?;
4451 try func.emitWValue(operand);4451 try func.emitWValue(operand);
4452 const payload_ty = optional_ty.optionalChild(mod);4452 const payload_ty = optional_ty.optionalChild(mod);
4453 if (!optional_ty.optionalReprIsPayload(mod)) {4453 if (!optional_ty.optionalReprIsPayload(mod)) {
...@@ -4475,7 +4475,7 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcod...@@ -4475,7 +4475,7 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcod
4475}4475}
44764476
4477fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4477fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4478 const mod = func.bin_file.base.options.module.?;4478 const mod = func.bin_file.base.comp.module.?;
4479 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4479 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4480 const opt_ty = func.typeOf(ty_op.operand);4480 const opt_ty = func.typeOf(ty_op.operand);
4481 const payload_ty = func.typeOfIndex(inst);4481 const payload_ty = func.typeOfIndex(inst);
...@@ -4498,7 +4498,7 @@ fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4498,7 +4498,7 @@ fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4498}4498}
44994499
4500fn airOptionalPayloadPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4500fn airOptionalPayloadPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4501 const mod = func.bin_file.base.options.module.?;4501 const mod = func.bin_file.base.comp.module.?;
4502 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4502 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4503 const operand = try func.resolveInst(ty_op.operand);4503 const operand = try func.resolveInst(ty_op.operand);
4504 const opt_ty = func.typeOf(ty_op.operand).childType(mod);4504 const opt_ty = func.typeOf(ty_op.operand).childType(mod);
...@@ -4515,7 +4515,7 @@ fn airOptionalPayloadPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4515,7 +4515,7 @@ fn airOptionalPayloadPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4515}4515}
45164516
4517fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4517fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4518 const mod = func.bin_file.base.options.module.?;4518 const mod = func.bin_file.base.comp.module.?;
4519 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4519 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4520 const operand = try func.resolveInst(ty_op.operand);4520 const operand = try func.resolveInst(ty_op.operand);
4521 const opt_ty = func.typeOf(ty_op.operand).childType(mod);4521 const opt_ty = func.typeOf(ty_op.operand).childType(mod);
...@@ -4543,7 +4543,7 @@ fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi...@@ -4543,7 +4543,7 @@ fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi
4543fn airWrapOptional(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4543fn airWrapOptional(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4544 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4544 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4545 const payload_ty = func.typeOf(ty_op.operand);4545 const payload_ty = func.typeOf(ty_op.operand);
4546 const mod = func.bin_file.base.options.module.?;4546 const mod = func.bin_file.base.comp.module.?;
45474547
4548 const result = result: {4548 const result = result: {
4549 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {4549 if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
...@@ -4600,7 +4600,7 @@ fn airSliceLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4600,7 +4600,7 @@ fn airSliceLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4600}4600}
46014601
4602fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4602fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4603 const mod = func.bin_file.base.options.module.?;4603 const mod = func.bin_file.base.comp.module.?;
4604 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4604 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
46054605
4606 const slice_ty = func.typeOf(bin_op.lhs);4606 const slice_ty = func.typeOf(bin_op.lhs);
...@@ -4630,7 +4630,7 @@ fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4630,7 +4630,7 @@ fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4630}4630}
46314631
4632fn airSliceElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4632fn airSliceElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4633 const mod = func.bin_file.base.options.module.?;4633 const mod = func.bin_file.base.comp.module.?;
4634 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4634 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4635 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;4635 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;
46364636
...@@ -4683,7 +4683,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4683,7 +4683,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4683/// Truncates a given operand to a given type, discarding any overflown bits.4683/// Truncates a given operand to a given type, discarding any overflown bits.
4684/// NOTE: Resulting value is left on the stack.4684/// NOTE: Resulting value is left on the stack.
4685fn trunc(func: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) InnerError!WValue {4685fn trunc(func: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) InnerError!WValue {
4686 const mod = func.bin_file.base.options.module.?;4686 const mod = func.bin_file.base.comp.module.?;
4687 const given_bits = @as(u16, @intCast(given_ty.bitSize(mod)));4687 const given_bits = @as(u16, @intCast(given_ty.bitSize(mod)));
4688 if (toWasmBits(given_bits) == null) {4688 if (toWasmBits(given_bits) == null) {
4689 return func.fail("TODO: Implement wasm integer truncation for integer bitsize: {d}", .{given_bits});4689 return func.fail("TODO: Implement wasm integer truncation for integer bitsize: {d}", .{given_bits});
...@@ -4707,7 +4707,7 @@ fn airIntFromBool(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4707,7 +4707,7 @@ fn airIntFromBool(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4707}4707}
47084708
4709fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4709fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4710 const mod = func.bin_file.base.options.module.?;4710 const mod = func.bin_file.base.comp.module.?;
4711 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4711 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
47124712
4713 const operand = try func.resolveInst(ty_op.operand);4713 const operand = try func.resolveInst(ty_op.operand);
...@@ -4730,7 +4730,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4730,7 +4730,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4730}4730}
47314731
4732fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4732fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4733 const mod = func.bin_file.base.options.module.?;4733 const mod = func.bin_file.base.comp.module.?;
4734 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4734 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4735 const operand = try func.resolveInst(un_op);4735 const operand = try func.resolveInst(un_op);
4736 const ptr_ty = func.typeOf(un_op);4736 const ptr_ty = func.typeOf(un_op);
...@@ -4745,7 +4745,7 @@ fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4745,7 +4745,7 @@ fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4745}4745}
47464746
4747fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4747fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4748 const mod = func.bin_file.base.options.module.?;4748 const mod = func.bin_file.base.comp.module.?;
4749 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4749 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
47504750
4751 const ptr_ty = func.typeOf(bin_op.lhs);4751 const ptr_ty = func.typeOf(bin_op.lhs);
...@@ -4782,7 +4782,7 @@ fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4782,7 +4782,7 @@ fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4782}4782}
47834783
4784fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4784fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4785 const mod = func.bin_file.base.options.module.?;4785 const mod = func.bin_file.base.comp.module.?;
4786 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4786 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4787 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;4787 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;
47884788
...@@ -4812,7 +4812,7 @@ fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4812,7 +4812,7 @@ fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4812}4812}
48134813
4814fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {4814fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
4815 const mod = func.bin_file.base.options.module.?;4815 const mod = func.bin_file.base.comp.module.?;
4816 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4816 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4817 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;4817 const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;
48184818
...@@ -4840,7 +4840,7 @@ fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -4840,7 +4840,7 @@ fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
4840}4840}
48414841
4842fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {4842fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
4843 const mod = func.bin_file.base.options.module.?;4843 const mod = func.bin_file.base.comp.module.?;
4844 if (safety) {4844 if (safety) {
4845 // TODO if the value is undef, write 0xaa bytes to dest4845 // TODO if the value is undef, write 0xaa bytes to dest
4846 } else {4846 } else {
...@@ -4873,7 +4873,7 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void...@@ -4873,7 +4873,7 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void
4873/// this to wasm's memset instruction. When the feature is not present,4873/// this to wasm's memset instruction. When the feature is not present,
4874/// we implement it manually.4874/// we implement it manually.
4875fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue) InnerError!void {4875fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue) InnerError!void {
4876 const mod = func.bin_file.base.options.module.?;4876 const mod = func.bin_file.base.comp.module.?;
4877 const abi_size = @as(u32, @intCast(elem_ty.abiSize(mod)));4877 const abi_size = @as(u32, @intCast(elem_ty.abiSize(mod)));
48784878
4879 // When bulk_memory is enabled, we lower it to wasm's memset instruction.4879 // When bulk_memory is enabled, we lower it to wasm's memset instruction.
...@@ -4962,7 +4962,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue...@@ -4962,7 +4962,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
4962}4962}
49634963
4964fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {4964fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4965 const mod = func.bin_file.base.options.module.?;4965 const mod = func.bin_file.base.comp.module.?;
4966 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4966 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
49674967
4968 const array_ty = func.typeOf(bin_op.lhs);4968 const array_ty = func.typeOf(bin_op.lhs);
...@@ -5031,7 +5031,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5031,7 +5031,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5031}5031}
50325032
5033fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5033fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5034 const mod = func.bin_file.base.options.module.?;5034 const mod = func.bin_file.base.comp.module.?;
5035 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5035 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
50365036
5037 const operand = try func.resolveInst(ty_op.operand);5037 const operand = try func.resolveInst(ty_op.operand);
...@@ -5076,7 +5076,7 @@ fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5076,7 +5076,7 @@ fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5076}5076}
50775077
5078fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5078fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5079 const mod = func.bin_file.base.options.module.?;5079 const mod = func.bin_file.base.comp.module.?;
5080 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5080 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
50815081
5082 const operand = try func.resolveInst(ty_op.operand);5082 const operand = try func.resolveInst(ty_op.operand);
...@@ -5122,7 +5122,7 @@ fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5122,7 +5122,7 @@ fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5122}5122}
51235123
5124fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5124fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5125 const mod = func.bin_file.base.options.module.?;5125 const mod = func.bin_file.base.comp.module.?;
5126 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5126 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5127 const operand = try func.resolveInst(ty_op.operand);5127 const operand = try func.resolveInst(ty_op.operand);
5128 const ty = func.typeOfIndex(inst);5128 const ty = func.typeOfIndex(inst);
...@@ -5201,7 +5201,7 @@ fn airSelect(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5201,7 +5201,7 @@ fn airSelect(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5201}5201}
52025202
5203fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5203fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5204 const mod = func.bin_file.base.options.module.?;5204 const mod = func.bin_file.base.comp.module.?;
5205 const inst_ty = func.typeOfIndex(inst);5205 const inst_ty = func.typeOfIndex(inst);
5206 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5206 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5207 const extra = func.air.extraData(Air.Shuffle, ty_pl.payload).data;5207 const extra = func.air.extraData(Air.Shuffle, ty_pl.payload).data;
...@@ -5270,7 +5270,7 @@ fn airReduce(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5270,7 +5270,7 @@ fn airReduce(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5270}5270}
52715271
5272fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5272fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5273 const mod = func.bin_file.base.options.module.?;5273 const mod = func.bin_file.base.comp.module.?;
5274 const ip = &mod.intern_pool;5274 const ip = &mod.intern_pool;
5275 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5275 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5276 const result_ty = func.typeOfIndex(inst);5276 const result_ty = func.typeOfIndex(inst);
...@@ -5400,7 +5400,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5400,7 +5400,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5400}5400}
54015401
5402fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5402fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5403 const mod = func.bin_file.base.options.module.?;5403 const mod = func.bin_file.base.comp.module.?;
5404 const ip = &mod.intern_pool;5404 const ip = &mod.intern_pool;
5405 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5405 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5406 const extra = func.air.extraData(Air.UnionInit, ty_pl.payload).data;5406 const extra = func.air.extraData(Air.UnionInit, ty_pl.payload).data;
...@@ -5499,7 +5499,7 @@ fn airWasmMemoryGrow(func: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5499,7 +5499,7 @@ fn airWasmMemoryGrow(func: *CodeGen, inst: Air.Inst.Index) !void {
5499}5499}
55005500
5501fn cmpOptionals(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {5501fn cmpOptionals(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {
5502 const mod = func.bin_file.base.options.module.?;5502 const mod = func.bin_file.base.comp.module.?;
5503 assert(operand_ty.hasRuntimeBitsIgnoreComptime(mod));5503 assert(operand_ty.hasRuntimeBitsIgnoreComptime(mod));
5504 assert(op == .eq or op == .neq);5504 assert(op == .eq or op == .neq);
5505 const payload_ty = operand_ty.optionalChild(mod);5505 const payload_ty = operand_ty.optionalChild(mod);
...@@ -5535,7 +5535,7 @@ fn cmpOptionals(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op:...@@ -5535,7 +5535,7 @@ fn cmpOptionals(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op:
5535/// NOTE: Leaves the result of the comparison on top of the stack.5535/// NOTE: Leaves the result of the comparison on top of the stack.
5536/// TODO: Lower this to compiler_rt call when bitsize > 1285536/// TODO: Lower this to compiler_rt call when bitsize > 128
5537fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {5537fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {
5538 const mod = func.bin_file.base.options.module.?;5538 const mod = func.bin_file.base.comp.module.?;
5539 assert(operand_ty.abiSize(mod) >= 16);5539 assert(operand_ty.abiSize(mod) >= 16);
5540 assert(!(lhs != .stack and rhs == .stack));5540 assert(!(lhs != .stack and rhs == .stack));
5541 if (operand_ty.bitSize(mod) > 128) {5541 if (operand_ty.bitSize(mod) > 128) {
...@@ -5577,7 +5577,7 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std...@@ -5577,7 +5577,7 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std
5577}5577}
55785578
5579fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5579fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5580 const mod = func.bin_file.base.options.module.?;5580 const mod = func.bin_file.base.comp.module.?;
5581 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5581 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
5582 const un_ty = func.typeOf(bin_op.lhs).childType(mod);5582 const un_ty = func.typeOf(bin_op.lhs).childType(mod);
5583 const tag_ty = func.typeOf(bin_op.rhs);5583 const tag_ty = func.typeOf(bin_op.rhs);
...@@ -5601,7 +5601,7 @@ fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5601,7 +5601,7 @@ fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5601}5601}
56025602
5603fn airGetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5603fn airGetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5604 const mod = func.bin_file.base.options.module.?;5604 const mod = func.bin_file.base.comp.module.?;
5605 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5605 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
56065606
5607 const un_ty = func.typeOf(ty_op.operand);5607 const un_ty = func.typeOf(ty_op.operand);
...@@ -5706,7 +5706,7 @@ fn fptrunc(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerErro...@@ -5706,7 +5706,7 @@ fn fptrunc(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerErro
5706}5706}
57075707
5708fn airErrUnionPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5708fn airErrUnionPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5709 const mod = func.bin_file.base.options.module.?;5709 const mod = func.bin_file.base.comp.module.?;
5710 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5710 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
57115711
5712 const err_set_ty = func.typeOf(ty_op.operand).childType(mod);5712 const err_set_ty = func.typeOf(ty_op.operand).childType(mod);
...@@ -5732,7 +5732,7 @@ fn airErrUnionPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi...@@ -5732,7 +5732,7 @@ fn airErrUnionPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi
5732}5732}
57335733
5734fn airFieldParentPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5734fn airFieldParentPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5735 const mod = func.bin_file.base.options.module.?;5735 const mod = func.bin_file.base.comp.module.?;
5736 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5736 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5737 const extra = func.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;5737 const extra = func.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
57385738
...@@ -5753,7 +5753,7 @@ fn airFieldParentPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5753,7 +5753,7 @@ fn airFieldParentPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5753}5753}
57545754
5755fn sliceOrArrayPtr(func: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {5755fn sliceOrArrayPtr(func: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {
5756 const mod = func.bin_file.base.options.module.?;5756 const mod = func.bin_file.base.comp.module.?;
5757 if (ptr_ty.isSlice(mod)) {5757 if (ptr_ty.isSlice(mod)) {
5758 return func.slicePtr(ptr);5758 return func.slicePtr(ptr);
5759 } else {5759 } else {
...@@ -5762,7 +5762,7 @@ fn sliceOrArrayPtr(func: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue...@@ -5762,7 +5762,7 @@ fn sliceOrArrayPtr(func: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue
5762}5762}
57635763
5764fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5764fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5765 const mod = func.bin_file.base.options.module.?;5765 const mod = func.bin_file.base.comp.module.?;
5766 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5766 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
5767 const dst = try func.resolveInst(bin_op.lhs);5767 const dst = try func.resolveInst(bin_op.lhs);
5768 const dst_ty = func.typeOf(bin_op.lhs);5768 const dst_ty = func.typeOf(bin_op.lhs);
...@@ -5802,7 +5802,7 @@ fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5802,7 +5802,7 @@ fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5802}5802}
58035803
5804fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {5804fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5805 const mod = func.bin_file.base.options.module.?;5805 const mod = func.bin_file.base.comp.module.?;
5806 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5806 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
58075807
5808 const operand = try func.resolveInst(ty_op.operand);5808 const operand = try func.resolveInst(ty_op.operand);
...@@ -5863,7 +5863,7 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5863,7 +5863,7 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5863 // to make a copy of the ptr+value but can point towards them directly.5863 // to make a copy of the ptr+value but can point towards them directly.
5864 const error_table_symbol = try func.bin_file.getErrorTableSymbol();5864 const error_table_symbol = try func.bin_file.getErrorTableSymbol();
5865 const name_ty = Type.slice_const_u8_sentinel_0;5865 const name_ty = Type.slice_const_u8_sentinel_0;
5866 const mod = func.bin_file.base.options.module.?;5866 const mod = func.bin_file.base.comp.module.?;
5867 const abi_size = name_ty.abiSize(mod);5867 const abi_size = name_ty.abiSize(mod);
58685868
5869 const error_name_value: WValue = .{ .memory = error_table_symbol }; // emitting this will create a relocation5869 const error_name_value: WValue = .{ .memory = error_table_symbol }; // emitting this will create a relocation
...@@ -5903,7 +5903,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro...@@ -5903,7 +5903,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
5903 const lhs_op = try func.resolveInst(extra.lhs);5903 const lhs_op = try func.resolveInst(extra.lhs);
5904 const rhs_op = try func.resolveInst(extra.rhs);5904 const rhs_op = try func.resolveInst(extra.rhs);
5905 const lhs_ty = func.typeOf(extra.lhs);5905 const lhs_ty = func.typeOf(extra.lhs);
5906 const mod = func.bin_file.base.options.module.?;5906 const mod = func.bin_file.base.comp.module.?;
59075907
5908 if (lhs_ty.zigTypeTag(mod) == .Vector) {5908 if (lhs_ty.zigTypeTag(mod) == .Vector) {
5909 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});5909 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
...@@ -5975,7 +5975,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro...@@ -5975,7 +5975,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
5975}5975}
59765976
5977fn addSubWithOverflowBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, result_ty: Type, op: Op) InnerError!WValue {5977fn addSubWithOverflowBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, result_ty: Type, op: Op) InnerError!WValue {
5978 const mod = func.bin_file.base.options.module.?;5978 const mod = func.bin_file.base.comp.module.?;
5979 assert(op == .add or op == .sub);5979 assert(op == .add or op == .sub);
5980 const int_info = ty.intInfo(mod);5980 const int_info = ty.intInfo(mod);
5981 const is_signed = int_info.signedness == .signed;5981 const is_signed = int_info.signedness == .signed;
...@@ -6040,7 +6040,7 @@ fn addSubWithOverflowBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type,...@@ -6040,7 +6040,7 @@ fn addSubWithOverflowBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type,
6040}6040}
60416041
6042fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6042fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6043 const mod = func.bin_file.base.options.module.?;6043 const mod = func.bin_file.base.comp.module.?;
6044 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6044 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
6045 const extra = func.air.extraData(Air.Bin, ty_pl.payload).data;6045 const extra = func.air.extraData(Air.Bin, ty_pl.payload).data;
60466046
...@@ -6103,7 +6103,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6103,7 +6103,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6103 const lhs = try func.resolveInst(extra.lhs);6103 const lhs = try func.resolveInst(extra.lhs);
6104 const rhs = try func.resolveInst(extra.rhs);6104 const rhs = try func.resolveInst(extra.rhs);
6105 const lhs_ty = func.typeOf(extra.lhs);6105 const lhs_ty = func.typeOf(extra.lhs);
6106 const mod = func.bin_file.base.options.module.?;6106 const mod = func.bin_file.base.comp.module.?;
61076107
6108 if (lhs_ty.zigTypeTag(mod) == .Vector) {6108 if (lhs_ty.zigTypeTag(mod) == .Vector) {
6109 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});6109 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
...@@ -6273,7 +6273,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6273,7 +6273,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
62736273
6274fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {6274fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6275 assert(op == .max or op == .min);6275 assert(op == .max or op == .min);
6276 const mod = func.bin_file.base.options.module.?;6276 const mod = func.bin_file.base.comp.module.?;
6277 const target = mod.getTarget();6277 const target = mod.getTarget();
6278 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6278 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
62796279
...@@ -6317,7 +6317,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6317,7 +6317,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6317}6317}
63186318
6319fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6319fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6320 const mod = func.bin_file.base.options.module.?;6320 const mod = func.bin_file.base.comp.module.?;
6321 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6321 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6322 const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;6322 const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;
63236323
...@@ -6351,7 +6351,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6351,7 +6351,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6351}6351}
63526352
6353fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6353fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6354 const mod = func.bin_file.base.options.module.?;6354 const mod = func.bin_file.base.comp.module.?;
6355 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6355 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
63566356
6357 const ty = func.typeOf(ty_op.operand);6357 const ty = func.typeOf(ty_op.operand);
...@@ -6404,7 +6404,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6404,7 +6404,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6404}6404}
64056405
6406fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6406fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6407 const mod = func.bin_file.base.options.module.?;6407 const mod = func.bin_file.base.comp.module.?;
6408 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6408 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
64096409
6410 const ty = func.typeOf(ty_op.operand);6410 const ty = func.typeOf(ty_op.operand);
...@@ -6471,7 +6471,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6471,7 +6471,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6471fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void {6471fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void {
6472 if (func.debug_output != .dwarf) return func.finishAir(inst, .none, &.{});6472 if (func.debug_output != .dwarf) return func.finishAir(inst, .none, &.{});
64736473
6474 const mod = func.bin_file.base.options.module.?;6474 const mod = func.bin_file.base.comp.module.?;
6475 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6475 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6476 const ty = func.typeOf(pl_op.operand);6476 const ty = func.typeOf(pl_op.operand);
6477 const operand = try func.resolveInst(pl_op.operand);6477 const operand = try func.resolveInst(pl_op.operand);
...@@ -6517,7 +6517,7 @@ fn airTry(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6517,7 +6517,7 @@ fn airTry(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6517}6517}
65186518
6519fn airTryPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6519fn airTryPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6520 const mod = func.bin_file.base.options.module.?;6520 const mod = func.bin_file.base.comp.module.?;
6521 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6521 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
6522 const extra = func.air.extraData(Air.TryPtr, ty_pl.payload);6522 const extra = func.air.extraData(Air.TryPtr, ty_pl.payload);
6523 const err_union_ptr = try func.resolveInst(extra.data.ptr);6523 const err_union_ptr = try func.resolveInst(extra.data.ptr);
...@@ -6535,7 +6535,7 @@ fn lowerTry(...@@ -6535,7 +6535,7 @@ fn lowerTry(
6535 err_union_ty: Type,6535 err_union_ty: Type,
6536 operand_is_ptr: bool,6536 operand_is_ptr: bool,
6537) InnerError!WValue {6537) InnerError!WValue {
6538 const mod = func.bin_file.base.options.module.?;6538 const mod = func.bin_file.base.comp.module.?;
6539 if (operand_is_ptr) {6539 if (operand_is_ptr) {
6540 return func.fail("TODO: lowerTry for pointers", .{});6540 return func.fail("TODO: lowerTry for pointers", .{});
6541 }6541 }
...@@ -6584,7 +6584,7 @@ fn lowerTry(...@@ -6584,7 +6584,7 @@ fn lowerTry(
6584}6584}
65856585
6586fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6586fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6587 const mod = func.bin_file.base.options.module.?;6587 const mod = func.bin_file.base.comp.module.?;
6588 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6588 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
65896589
6590 const ty = func.typeOfIndex(inst);6590 const ty = func.typeOfIndex(inst);
...@@ -6655,7 +6655,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6655,7 +6655,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6655}6655}
66566656
6657fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6657fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6658 const mod = func.bin_file.base.options.module.?;6658 const mod = func.bin_file.base.comp.module.?;
6659 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6659 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
66606660
6661 const ty = func.typeOfIndex(inst);6661 const ty = func.typeOfIndex(inst);
...@@ -6670,7 +6670,7 @@ fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6670,7 +6670,7 @@ fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6670}6670}
66716671
6672fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6672fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6673 const mod = func.bin_file.base.options.module.?;6673 const mod = func.bin_file.base.comp.module.?;
6674 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6674 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
66756675
6676 const ty = func.typeOfIndex(inst);6676 const ty = func.typeOfIndex(inst);
...@@ -6693,7 +6693,7 @@ fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6693,7 +6693,7 @@ fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6693fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6693fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6694 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6694 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
66956695
6696 const mod = func.bin_file.base.options.module.?;6696 const mod = func.bin_file.base.comp.module.?;
6697 const ty = func.typeOfIndex(inst);6697 const ty = func.typeOfIndex(inst);
6698 const lhs = try func.resolveInst(bin_op.lhs);6698 const lhs = try func.resolveInst(bin_op.lhs);
6699 const rhs = try func.resolveInst(bin_op.rhs);6699 const rhs = try func.resolveInst(bin_op.rhs);
...@@ -6806,7 +6806,7 @@ fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6806,7 +6806,7 @@ fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6806}6806}
68076807
6808fn divSigned(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type) InnerError!WValue {6808fn divSigned(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type) InnerError!WValue {
6809 const mod = func.bin_file.base.options.module.?;6809 const mod = func.bin_file.base.comp.module.?;
6810 const int_bits = ty.intInfo(mod).bits;6810 const int_bits = ty.intInfo(mod).bits;
6811 const wasm_bits = toWasmBits(int_bits) orelse {6811 const wasm_bits = toWasmBits(int_bits) orelse {
6812 return func.fail("TODO: Implement signed division for integers with bitsize '{d}'", .{int_bits});6812 return func.fail("TODO: Implement signed division for integers with bitsize '{d}'", .{int_bits});
...@@ -6836,7 +6836,7 @@ fn divSigned(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type) InnerError!WVal...@@ -6836,7 +6836,7 @@ fn divSigned(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type) InnerError!WVal
6836fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {6836fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6837 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6837 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
68386838
6839 const mod = func.bin_file.base.options.module.?;6839 const mod = func.bin_file.base.comp.module.?;
6840 const ty = func.typeOfIndex(inst);6840 const ty = func.typeOfIndex(inst);
6841 const lhs = try func.resolveInst(bin_op.lhs);6841 const lhs = try func.resolveInst(bin_op.lhs);
6842 const rhs = try func.resolveInst(bin_op.rhs);6842 const rhs = try func.resolveInst(bin_op.rhs);
...@@ -6883,7 +6883,7 @@ fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6883,7 +6883,7 @@ fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6883/// The result will be sign extended to 32 bits if N <= 32 or 64 bits if N <= 64.6883/// The result will be sign extended to 32 bits if N <= 32 or 64 bits if N <= 64.
6884/// Support for integers wider than 64 bits has not yet been implemented.6884/// Support for integers wider than 64 bits has not yet been implemented.
6885fn signExtendInt(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {6885fn signExtendInt(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {
6886 const mod = func.bin_file.base.options.module.?;6886 const mod = func.bin_file.base.comp.module.?;
6887 const int_bits = ty.intInfo(mod).bits;6887 const int_bits = ty.intInfo(mod).bits;
6888 const wasm_bits = toWasmBits(int_bits) orelse {6888 const wasm_bits = toWasmBits(int_bits) orelse {
6889 return func.fail("TODO: signExtendInt for signed integers larger than '{d}' bits", .{int_bits});6889 return func.fail("TODO: signExtendInt for signed integers larger than '{d}' bits", .{int_bits});
...@@ -6919,7 +6919,7 @@ fn airSatBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6919,7 +6919,7 @@ fn airSatBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6919 assert(op == .add or op == .sub);6919 assert(op == .add or op == .sub);
6920 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6920 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
69216921
6922 const mod = func.bin_file.base.options.module.?;6922 const mod = func.bin_file.base.comp.module.?;
6923 const ty = func.typeOfIndex(inst);6923 const ty = func.typeOfIndex(inst);
6924 const lhs = try func.resolveInst(bin_op.lhs);6924 const lhs = try func.resolveInst(bin_op.lhs);
6925 const rhs = try func.resolveInst(bin_op.rhs);6925 const rhs = try func.resolveInst(bin_op.rhs);
...@@ -6967,7 +6967,7 @@ fn airSatBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6967,7 +6967,7 @@ fn airSatBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6967}6967}
69686968
6969fn signedSat(func: *CodeGen, lhs_operand: WValue, rhs_operand: WValue, ty: Type, op: Op) InnerError!WValue {6969fn signedSat(func: *CodeGen, lhs_operand: WValue, rhs_operand: WValue, ty: Type, op: Op) InnerError!WValue {
6970 const mod = func.bin_file.base.options.module.?;6970 const mod = func.bin_file.base.comp.module.?;
6971 const int_info = ty.intInfo(mod);6971 const int_info = ty.intInfo(mod);
6972 const wasm_bits = toWasmBits(int_info.bits).?;6972 const wasm_bits = toWasmBits(int_info.bits).?;
6973 const is_wasm_bits = wasm_bits == int_info.bits;6973 const is_wasm_bits = wasm_bits == int_info.bits;
...@@ -7034,7 +7034,7 @@ fn signedSat(func: *CodeGen, lhs_operand: WValue, rhs_operand: WValue, ty: Type,...@@ -7034,7 +7034,7 @@ fn signedSat(func: *CodeGen, lhs_operand: WValue, rhs_operand: WValue, ty: Type,
7034fn airShlSat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7034fn airShlSat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7035 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;7035 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
70367036
7037 const mod = func.bin_file.base.options.module.?;7037 const mod = func.bin_file.base.comp.module.?;
7038 const ty = func.typeOfIndex(inst);7038 const ty = func.typeOfIndex(inst);
7039 const int_info = ty.intInfo(mod);7039 const int_info = ty.intInfo(mod);
7040 const is_signed = int_info.signedness == .signed;7040 const is_signed = int_info.signedness == .signed;
...@@ -7155,7 +7155,7 @@ fn callIntrinsic(...@@ -7155,7 +7155,7 @@ fn callIntrinsic(
7155 };7155 };
71567156
7157 // Always pass over C-ABI7157 // Always pass over C-ABI
7158 const mod = func.bin_file.base.options.module.?;7158 const mod = func.bin_file.base.comp.module.?;
7159 var func_type = try genFunctype(func.gpa, .C, param_types, return_type, mod);7159 var func_type = try genFunctype(func.gpa, .C, param_types, return_type, mod);
7160 defer func_type.deinit(func.gpa);7160 defer func_type.deinit(func.gpa);
7161 const func_type_index = try func.bin_file.putOrGetFuncType(func_type);7161 const func_type_index = try func.bin_file.putOrGetFuncType(func_type);
...@@ -7208,7 +7208,7 @@ fn airTagName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7208,7 +7208,7 @@ fn airTagName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7208}7208}
72097209
7210fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {7210fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
7211 const mod = func.bin_file.base.options.module.?;7211 const mod = func.bin_file.base.comp.module.?;
7212 const enum_decl_index = enum_ty.getOwnerDecl(mod);7212 const enum_decl_index = enum_ty.getOwnerDecl(mod);
72137213
7214 var arena_allocator = std.heap.ArenaAllocator.init(func.gpa);7214 var arena_allocator = std.heap.ArenaAllocator.init(func.gpa);
...@@ -7364,7 +7364,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {...@@ -7364,7 +7364,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
7364}7364}
73657365
7366fn airErrorSetHasValue(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7366fn airErrorSetHasValue(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7367 const mod = func.bin_file.base.options.module.?;7367 const mod = func.bin_file.base.comp.module.?;
7368 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;7368 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
73697369
7370 const operand = try func.resolveInst(ty_op.operand);7370 const operand = try func.resolveInst(ty_op.operand);
...@@ -7449,7 +7449,7 @@ inline fn useAtomicFeature(func: *const CodeGen) bool {...@@ -7449,7 +7449,7 @@ inline fn useAtomicFeature(func: *const CodeGen) bool {
7449}7449}
74507450
7451fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7451fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7452 const mod = func.bin_file.base.options.module.?;7452 const mod = func.bin_file.base.comp.module.?;
7453 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;7453 const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
7454 const extra = func.air.extraData(Air.Cmpxchg, ty_pl.payload).data;7454 const extra = func.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
74557455
...@@ -7522,7 +7522,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7522,7 +7522,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7522}7522}
75237523
7524fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7524fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7525 const mod = func.bin_file.base.options.module.?;7525 const mod = func.bin_file.base.comp.module.?;
7526 const atomic_load = func.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load;7526 const atomic_load = func.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load;
7527 const ptr = try func.resolveInst(atomic_load.ptr);7527 const ptr = try func.resolveInst(atomic_load.ptr);
7528 const ty = func.typeOfIndex(inst);7528 const ty = func.typeOfIndex(inst);
...@@ -7549,7 +7549,7 @@ fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7549,7 +7549,7 @@ fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7549}7549}
75507550
7551fn airAtomicRmw(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7551fn airAtomicRmw(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7552 const mod = func.bin_file.base.options.module.?;7552 const mod = func.bin_file.base.comp.module.?;
7553 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;7553 const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
7554 const extra = func.air.extraData(Air.AtomicRmw, pl_op.payload).data;7554 const extra = func.air.extraData(Air.AtomicRmw, pl_op.payload).data;
75557555
...@@ -7735,7 +7735,7 @@ fn airFence(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7735,7 +7735,7 @@ fn airFence(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7735}7735}
77367736
7737fn airAtomicStore(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {7737fn airAtomicStore(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7738 const mod = func.bin_file.base.options.module.?;7738 const mod = func.bin_file.base.comp.module.?;
7739 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;7739 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
77407740
7741 const ptr = try func.resolveInst(bin_op.lhs);7741 const ptr = try func.resolveInst(bin_op.lhs);
...@@ -7774,11 +7774,11 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7774,11 +7774,11 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7774}7774}
77757775
7776fn typeOf(func: *CodeGen, inst: Air.Inst.Ref) Type {7776fn typeOf(func: *CodeGen, inst: Air.Inst.Ref) Type {
7777 const mod = func.bin_file.base.options.module.?;7777 const mod = func.bin_file.base.comp.module.?;
7778 return func.air.typeOf(inst, &mod.intern_pool);7778 return func.air.typeOf(inst, &mod.intern_pool);
7779}7779}
77807780
7781fn typeOfIndex(func: *CodeGen, inst: Air.Inst.Index) Type {7781fn typeOfIndex(func: *CodeGen, inst: Air.Inst.Index) Type {
7782 const mod = func.bin_file.base.options.module.?;7782 const mod = func.bin_file.base.comp.module.?;
7783 return func.air.typeOfIndex(inst, &mod.intern_pool);7783 return func.air.typeOfIndex(inst, &mod.intern_pool);
7784}7784}
src/arch/wasm/Emit.zig+1-1
...@@ -254,7 +254,7 @@ fn offset(self: Emit) u32 {...@@ -254,7 +254,7 @@ fn offset(self: Emit) u32 {
254fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {254fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
255 @setCold(true);255 @setCold(true);
256 std.debug.assert(emit.error_msg == null);256 std.debug.assert(emit.error_msg == null);
257 const mod = emit.bin_file.base.options.module.?;257 const mod = emit.bin_file.base.comp.module.?;
258 emit.error_msg = try Module.ErrorMsg.create(emit.bin_file.base.allocator, mod.declPtr(emit.decl_index).srcLoc(mod), format, args);258 emit.error_msg = try Module.ErrorMsg.create(emit.bin_file.base.allocator, mod.declPtr(emit.decl_index).srcLoc(mod), format, args);
259 return error.EmitFail;259 return error.EmitFail;
260}260}
src/link/C.zig+4-4
...@@ -386,7 +386,7 @@ pub fn flushModule(self: *C, _: *Compilation, prog_node: *std.Progress.Node) !vo...@@ -386,7 +386,7 @@ pub fn flushModule(self: *C, _: *Compilation, prog_node: *std.Progress.Node) !vo
386 defer sub_prog_node.end();386 defer sub_prog_node.end();
387387
388 const gpa = self.base.comp.gpa;388 const gpa = self.base.comp.gpa;
389 const module = self.base.options.module.?;389 const module = self.base.comp.module.?;
390390
391 {391 {
392 var i: usize = 0;392 var i: usize = 0;
...@@ -535,7 +535,7 @@ fn flushCTypes(...@@ -535,7 +535,7 @@ fn flushCTypes(
535 decl_ctypes: codegen.CType.Store,535 decl_ctypes: codegen.CType.Store,
536) FlushDeclError!void {536) FlushDeclError!void {
537 const gpa = self.base.comp.gpa;537 const gpa = self.base.comp.gpa;
538 const mod = self.base.options.module.?;538 const mod = self.base.comp.module.?;
539539
540 const decl_ctypes_len = decl_ctypes.count();540 const decl_ctypes_len = decl_ctypes.count();
541 f.ctypes_map.clearRetainingCapacity();541 f.ctypes_map.clearRetainingCapacity();
...@@ -623,7 +623,7 @@ fn flushErrDecls(self: *C, ctypes: *codegen.CType.Store) FlushDeclError!void {...@@ -623,7 +623,7 @@ fn flushErrDecls(self: *C, ctypes: *codegen.CType.Store) FlushDeclError!void {
623 var object = codegen.Object{623 var object = codegen.Object{
624 .dg = .{624 .dg = .{
625 .gpa = gpa,625 .gpa = gpa,
626 .module = self.base.options.module.?,626 .module = self.base.comp.module.?,
627 .error_msg = null,627 .error_msg = null,
628 .pass = .flush,628 .pass = .flush,
629 .is_naked_fn = false,629 .is_naked_fn = false,
...@@ -665,7 +665,7 @@ fn flushLazyFn(...@@ -665,7 +665,7 @@ fn flushLazyFn(
665 var object = codegen.Object{665 var object = codegen.Object{
666 .dg = .{666 .dg = .{
667 .gpa = gpa,667 .gpa = gpa,
668 .module = self.base.options.module.?,668 .module = self.base.comp.module.?,
669 .error_msg = null,669 .error_msg = null,
670 .pass = .flush,670 .pass = .flush,
671 .is_naked_fn = false,671 .is_naked_fn = false,
src/link/Coff.zig+10-10
...@@ -1118,7 +1118,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:...@@ -1118,7 +1118,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:
11181118
1119pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {1119pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
1120 const gpa = self.base.comp.gpa;1120 const gpa = self.base.comp.gpa;
1121 const mod = self.base.options.module.?;1121 const mod = self.base.comp.module.?;
1122 const decl = mod.declPtr(decl_index);1122 const decl = mod.declPtr(decl_index);
1123 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);1123 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);
1124 if (!gop.found_existing) {1124 if (!gop.found_existing) {
...@@ -1249,7 +1249,7 @@ fn updateLazySymbolAtom(...@@ -1249,7 +1249,7 @@ fn updateLazySymbolAtom(
1249 section_index: u16,1249 section_index: u16,
1250) !void {1250) !void {
1251 const gpa = self.base.comp.gpa;1251 const gpa = self.base.comp.gpa;
1252 const mod = self.base.options.module.?;1252 const mod = self.base.comp.module.?;
12531253
1254 var required_alignment: InternPool.Alignment = .none;1254 var required_alignment: InternPool.Alignment = .none;
1255 var code_buffer = std.ArrayList(u8).init(gpa);1255 var code_buffer = std.ArrayList(u8).init(gpa);
...@@ -1310,7 +1310,7 @@ fn updateLazySymbolAtom(...@@ -1310,7 +1310,7 @@ fn updateLazySymbolAtom(
13101310
1311pub fn getOrCreateAtomForLazySymbol(self: *Coff, sym: link.File.LazySymbol) !Atom.Index {1311pub fn getOrCreateAtomForLazySymbol(self: *Coff, sym: link.File.LazySymbol) !Atom.Index {
1312 const gpa = self.base.comp.gpa;1312 const gpa = self.base.comp.gpa;
1313 const mod = self.base.options.module.?;1313 const mod = self.base.comp.module.?;
1314 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(mod));1314 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(mod));
1315 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();1315 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();
1316 if (!gop.found_existing) gop.value_ptr.* = .{};1316 if (!gop.found_existing) gop.value_ptr.* = .{};
...@@ -1347,9 +1347,9 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: InternPool.DeclIndex) !At...@@ -1347,9 +1347,9 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: InternPool.DeclIndex) !At
1347}1347}
13481348
1349fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 {1349fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 {
1350 const decl = self.base.options.module.?.declPtr(decl_index);1350 const decl = self.base.comp.module.?.declPtr(decl_index);
1351 const ty = decl.ty;1351 const ty = decl.ty;
1352 const mod = self.base.options.module.?;1352 const mod = self.base.comp.module.?;
1353 const zig_ty = ty.zigTypeTag(mod);1353 const zig_ty = ty.zigTypeTag(mod);
1354 const val = decl.val;1354 const val = decl.val;
1355 const index: u16 = blk: {1355 const index: u16 = blk: {
...@@ -1373,7 +1373,7 @@ fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 {...@@ -1373,7 +1373,7 @@ fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 {
1373}1373}
13741374
1375fn updateDeclCode(self: *Coff, decl_index: InternPool.DeclIndex, code: []u8, complex_type: coff.ComplexType) !void {1375fn updateDeclCode(self: *Coff, decl_index: InternPool.DeclIndex, code: []u8, complex_type: coff.ComplexType) !void {
1376 const mod = self.base.options.module.?;1376 const mod = self.base.comp.module.?;
1377 const decl = mod.declPtr(decl_index);1377 const decl = mod.declPtr(decl_index);
13781378
1379 const decl_name = mod.intern_pool.stringToSlice(try decl.getFullyQualifiedName(mod));1379 const decl_name = mod.intern_pool.stringToSlice(try decl.getFullyQualifiedName(mod));
...@@ -1443,7 +1443,7 @@ pub fn freeDecl(self: *Coff, decl_index: InternPool.DeclIndex) void {...@@ -1443,7 +1443,7 @@ pub fn freeDecl(self: *Coff, decl_index: InternPool.DeclIndex) void {
1443 if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);1443 if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
14441444
1445 const gpa = self.base.comp.gpa;1445 const gpa = self.base.comp.gpa;
1446 const mod = self.base.options.module.?;1446 const mod = self.base.comp.module.?;
1447 const decl = mod.declPtr(decl_index);1447 const decl = mod.declPtr(decl_index);
14481448
1449 log.debug("freeDecl {*}", .{decl});1449 log.debug("freeDecl {*}", .{decl});
...@@ -1599,7 +1599,7 @@ pub fn deleteDeclExport(...@@ -1599,7 +1599,7 @@ pub fn deleteDeclExport(
1599) void {1599) void {
1600 if (self.llvm_object) |_| return;1600 if (self.llvm_object) |_| return;
1601 const metadata = self.decls.getPtr(decl_index) orelse return;1601 const metadata = self.decls.getPtr(decl_index) orelse return;
1602 const mod = self.base.options.module.?;1602 const mod = self.base.comp.module.?;
1603 const name = mod.intern_pool.stringToSlice(name_ip);1603 const name = mod.intern_pool.stringToSlice(name_ip);
1604 const sym_index = metadata.getExportPtr(self, name) orelse return;1604 const sym_index = metadata.getExportPtr(self, name) orelse return;
16051605
...@@ -1678,7 +1678,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -1678,7 +1678,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
16781678
1679 const gpa = self.base.comp.gpa;1679 const gpa = self.base.comp.gpa;
16801680
1681 const module = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented;1681 const module = self.base.comp.module orelse return error.LinkingWithoutZigSourceUnimplemented;
16821682
1683 if (self.lazy_syms.getPtr(.none)) |metadata| {1683 if (self.lazy_syms.getPtr(.none)) |metadata| {
1684 // Most lazy symbols can be updated on first use, but1684 // Most lazy symbols can be updated on first use, but
...@@ -1818,7 +1818,7 @@ pub fn lowerAnonDecl(...@@ -1818,7 +1818,7 @@ pub fn lowerAnonDecl(
1818 src_loc: Module.SrcLoc,1818 src_loc: Module.SrcLoc,
1819) !codegen.Result {1819) !codegen.Result {
1820 const gpa = self.base.comp.gpa;1820 const gpa = self.base.comp.gpa;
1821 const mod = self.base.options.module.?;1821 const mod = self.base.comp.module.?;
1822 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));1822 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
1823 const decl_alignment = switch (explicit_alignment) {1823 const decl_alignment = switch (explicit_alignment) {
1824 .none => ty.abiAlignment(mod),1824 .none => ty.abiAlignment(mod),
src/link/Coff/lld.zig+3-3
...@@ -30,7 +30,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -30,7 +30,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
3030
31 // If there is no Zig code to compile, then we should skip flushing the output file because it31 // If there is no Zig code to compile, then we should skip flushing the output file because it
32 // will not be part of the linker line anyway.32 // will not be part of the linker line anyway.
33 const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: {33 const module_obj_path: ?[]const u8 = if (self.base.comp.module != null) blk: {
34 try self.flushModule(comp, prog_node);34 try self.flushModule(comp, prog_node);
3535
36 if (fs.path.dirname(full_out_path)) |dirname| {36 if (fs.path.dirname(full_out_path)) |dirname| {
...@@ -289,7 +289,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -289,7 +289,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
289 if (self.base.options.subsystem) |explicit| break :blk explicit;289 if (self.base.options.subsystem) |explicit| break :blk explicit;
290 switch (target.os.tag) {290 switch (target.os.tag) {
291 .windows => {291 .windows => {
292 if (self.base.options.module) |module| {292 if (self.base.comp.module) |module| {
293 if (module.stage1_flags.have_dllmain_crt_startup or is_dyn_lib)293 if (module.stage1_flags.have_dllmain_crt_startup or is_dyn_lib)
294 break :blk null;294 break :blk null;
295 if (module.stage1_flags.have_c_main or self.base.options.is_test or295 if (module.stage1_flags.have_c_main or self.base.options.is_test or
...@@ -450,7 +450,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -450,7 +450,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
450 } else {450 } else {
451 try argv.append("-NODEFAULTLIB");451 try argv.append("-NODEFAULTLIB");
452 if (!is_lib and self.base.options.entry == null) {452 if (!is_lib and self.base.options.entry == null) {
453 if (self.base.options.module) |module| {453 if (self.base.comp.module) |module| {
454 if (module.stage1_flags.have_winmain_crt_startup) {454 if (module.stage1_flags.have_winmain_crt_startup) {
455 try argv.append("-ENTRY:WinMainCRTStartup");455 try argv.append("-ENTRY:WinMainCRTStartup");
456 } else {456 } else {
src/link/Elf.zig+1-1
...@@ -2309,7 +2309,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v...@@ -2309,7 +2309,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
23092309
2310 // If there is no Zig code to compile, then we should skip flushing the output file because it2310 // If there is no Zig code to compile, then we should skip flushing the output file because it
2311 // will not be part of the linker line anyway.2311 // will not be part of the linker line anyway.
2312 const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: {2312 const module_obj_path: ?[]const u8 = if (self.base.comp.module != null) blk: {
2313 try self.flushModule(comp, prog_node);2313 try self.flushModule(comp, prog_node);
23142314
2315 if (fs.path.dirname(full_out_path)) |dirname| {2315 if (fs.path.dirname(full_out_path)) |dirname| {
src/link/MachO.zig+11-11
...@@ -356,7 +356,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No...@@ -356,7 +356,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
356 defer sub_prog_node.end();356 defer sub_prog_node.end();
357357
358 const output_mode = self.base.comp.config.output_mode;358 const output_mode = self.base.comp.config.output_mode;
359 const module = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented;359 const module = self.base.comp.module orelse return error.LinkingWithoutZigSourceUnimplemented;
360360
361 if (self.lazy_syms.getPtr(.none)) |metadata| {361 if (self.lazy_syms.getPtr(.none)) |metadata| {
362 // Most lazy symbols can be updated on first use, but362 // Most lazy symbols can be updated on first use, but
...@@ -2333,7 +2333,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:...@@ -2333,7 +2333,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:
23332333
2334pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 {2334pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
2335 const gpa = self.base.comp.gpa;2335 const gpa = self.base.comp.gpa;
2336 const mod = self.base.options.module.?;2336 const mod = self.base.comp.module.?;
2337 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);2337 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);
2338 if (!gop.found_existing) {2338 if (!gop.found_existing) {
2339 gop.value_ptr.* = .{};2339 gop.value_ptr.* = .{};
...@@ -2504,7 +2504,7 @@ fn updateLazySymbolAtom(...@@ -2504,7 +2504,7 @@ fn updateLazySymbolAtom(
2504 section_index: u8,2504 section_index: u8,
2505) !void {2505) !void {
2506 const gpa = self.base.comp.gpa;2506 const gpa = self.base.comp.gpa;
2507 const mod = self.base.options.module.?;2507 const mod = self.base.comp.module.?;
25082508
2509 var required_alignment: Alignment = .none;2509 var required_alignment: Alignment = .none;
2510 var code_buffer = std.ArrayList(u8).init(gpa);2510 var code_buffer = std.ArrayList(u8).init(gpa);
...@@ -2568,7 +2568,7 @@ fn updateLazySymbolAtom(...@@ -2568,7 +2568,7 @@ fn updateLazySymbolAtom(
2568}2568}
25692569
2570pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.Index {2570pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.Index {
2571 const mod = self.base.options.module.?;2571 const mod = self.base.comp.module.?;
2572 const gpa = self.base.comp.gpa;2572 const gpa = self.base.comp.gpa;
2573 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(mod));2573 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(mod));
2574 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();2574 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();
...@@ -2600,7 +2600,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.In...@@ -2600,7 +2600,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.In
2600}2600}
26012601
2602fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {2602fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
2603 const mod = self.base.options.module.?;2603 const mod = self.base.comp.module.?;
2604 // Lowering a TLV on macOS involves two stages:2604 // Lowering a TLV on macOS involves two stages:
2605 // 1. first we lower the initializer into appopriate section (__thread_data or __thread_bss)2605 // 1. first we lower the initializer into appopriate section (__thread_data or __thread_bss)
2606 // 2. next, we create a corresponding threadlocal variable descriptor in __thread_vars2606 // 2. next, we create a corresponding threadlocal variable descriptor in __thread_vars
...@@ -2711,10 +2711,10 @@ pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: InternPool.DeclIndex) !A...@@ -2711,10 +2711,10 @@ pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: InternPool.DeclIndex) !A
2711}2711}
27122712
2713fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {2713fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {
2714 const decl = self.base.options.module.?.declPtr(decl_index);2714 const decl = self.base.comp.module.?.declPtr(decl_index);
2715 const ty = decl.ty;2715 const ty = decl.ty;
2716 const val = decl.val;2716 const val = decl.val;
2717 const mod = self.base.options.module.?;2717 const mod = self.base.comp.module.?;
2718 const zig_ty = ty.zigTypeTag(mod);2718 const zig_ty = ty.zigTypeTag(mod);
2719 const any_non_single_threaded = self.base.comp.config.any_non_single_threaded;2719 const any_non_single_threaded = self.base.comp.config.any_non_single_threaded;
2720 const optimize_mode = self.base.comp.root_mod.optimize_mode;2720 const optimize_mode = self.base.comp.root_mod.optimize_mode;
...@@ -2751,7 +2751,7 @@ fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {...@@ -2751,7 +2751,7 @@ fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {
27512751
2752fn updateDeclCode(self: *MachO, decl_index: InternPool.DeclIndex, code: []u8) !u64 {2752fn updateDeclCode(self: *MachO, decl_index: InternPool.DeclIndex, code: []u8) !u64 {
2753 const gpa = self.base.comp.gpa;2753 const gpa = self.base.comp.gpa;
2754 const mod = self.base.options.module.?;2754 const mod = self.base.comp.module.?;
2755 const decl = mod.declPtr(decl_index);2755 const decl = mod.declPtr(decl_index);
27562756
2757 const required_alignment = decl.getAlignment(mod);2757 const required_alignment = decl.getAlignment(mod);
...@@ -2967,7 +2967,7 @@ pub fn deleteDeclExport(...@@ -2967,7 +2967,7 @@ pub fn deleteDeclExport(
2967 const metadata = self.decls.getPtr(decl_index) orelse return;2967 const metadata = self.decls.getPtr(decl_index) orelse return;
29682968
2969 const gpa = self.base.comp.gpa;2969 const gpa = self.base.comp.gpa;
2970 const mod = self.base.options.module.?;2970 const mod = self.base.comp.module.?;
2971 const exp_name = try std.fmt.allocPrint(gpa, "_{s}", .{mod.intern_pool.stringToSlice(name)});2971 const exp_name = try std.fmt.allocPrint(gpa, "_{s}", .{mod.intern_pool.stringToSlice(name)});
2972 defer gpa.free(exp_name);2972 defer gpa.free(exp_name);
2973 const sym_index = metadata.getExportPtr(self, exp_name) orelse return;2973 const sym_index = metadata.getExportPtr(self, exp_name) orelse return;
...@@ -3006,7 +3006,7 @@ fn freeUnnamedConsts(self: *MachO, decl_index: InternPool.DeclIndex) void {...@@ -3006,7 +3006,7 @@ fn freeUnnamedConsts(self: *MachO, decl_index: InternPool.DeclIndex) void {
3006pub fn freeDecl(self: *MachO, decl_index: InternPool.DeclIndex) void {3006pub fn freeDecl(self: *MachO, decl_index: InternPool.DeclIndex) void {
3007 if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);3007 if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
3008 const gpa = self.base.comp.gpa;3008 const gpa = self.base.comp.gpa;
3009 const mod = self.base.options.module.?;3009 const mod = self.base.comp.module.?;
3010 const decl = mod.declPtr(decl_index);3010 const decl = mod.declPtr(decl_index);
30113011
3012 log.debug("freeDecl {*}", .{decl});3012 log.debug("freeDecl {*}", .{decl});
...@@ -3049,7 +3049,7 @@ pub fn lowerAnonDecl(...@@ -3049,7 +3049,7 @@ pub fn lowerAnonDecl(
3049 src_loc: Module.SrcLoc,3049 src_loc: Module.SrcLoc,
3050) !codegen.Result {3050) !codegen.Result {
3051 const gpa = self.base.comp.gpa;3051 const gpa = self.base.comp.gpa;
3052 const mod = self.base.options.module.?;3052 const mod = self.base.comp.module.?;
3053 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));3053 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
3054 const decl_alignment = switch (explicit_alignment) {3054 const decl_alignment = switch (explicit_alignment) {
3055 .none => ty.abiAlignment(mod),3055 .none => ty.abiAlignment(mod),
src/link/Plan9.zig+15-15
...@@ -174,7 +174,7 @@ pub const Atom = struct {...@@ -174,7 +174,7 @@ pub const Atom = struct {
174 return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } };174 return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } };
175 }175 }
176 fn getCode(self: CodePtr, plan9: *const Plan9) []u8 {176 fn getCode(self: CodePtr, plan9: *const Plan9) []u8 {
177 const mod = plan9.base.options.module.?;177 const mod = plan9.base.comp.module.?;
178 return if (self.code_ptr) |p| p[0..self.other.code_len] else blk: {178 return if (self.code_ptr) |p| p[0..self.other.code_len] else blk: {
179 const decl_index = self.other.decl_index;179 const decl_index = self.other.decl_index;
180 const decl = mod.declPtr(decl_index);180 const decl = mod.declPtr(decl_index);
...@@ -324,7 +324,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {...@@ -324,7 +324,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {
324324
325fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !void {325fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !void {
326 const gpa = self.base.comp.gpa;326 const gpa = self.base.comp.gpa;
327 const mod = self.base.options.module.?;327 const mod = self.base.comp.module.?;
328 const decl = mod.declPtr(decl_index);328 const decl = mod.declPtr(decl_index);
329 const fn_map_res = try self.fn_decl_table.getOrPut(gpa, decl.getFileScope(mod));329 const fn_map_res = try self.fn_decl_table.getOrPut(gpa, decl.getFileScope(mod));
330 if (fn_map_res.found_existing) {330 if (fn_map_res.found_existing) {
...@@ -455,7 +455,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: InternPool.De...@@ -455,7 +455,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: InternPool.De
455 var code_buffer = std.ArrayList(u8).init(gpa);455 var code_buffer = std.ArrayList(u8).init(gpa);
456 defer code_buffer.deinit();456 defer code_buffer.deinit();
457457
458 const mod = self.base.options.module.?;458 const mod = self.base.comp.module.?;
459 const decl = mod.declPtr(decl_index);459 const decl = mod.declPtr(decl_index);
460460
461 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);461 const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index);
...@@ -550,7 +550,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex)...@@ -550,7 +550,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex)
550/// called at the end of update{Decl,Func}550/// called at the end of update{Decl,Func}
551fn updateFinish(self: *Plan9, decl_index: InternPool.DeclIndex) !void {551fn updateFinish(self: *Plan9, decl_index: InternPool.DeclIndex) !void {
552 const gpa = self.base.comp.gpa;552 const gpa = self.base.comp.gpa;
553 const mod = self.base.options.module.?;553 const mod = self.base.comp.module.?;
554 const decl = mod.declPtr(decl_index);554 const decl = mod.declPtr(decl_index);
555 const is_fn = (decl.ty.zigTypeTag(mod) == .Fn);555 const is_fn = (decl.ty.zigTypeTag(mod) == .Fn);
556 const sym_t: aout.Sym.Type = if (is_fn) .t else .d;556 const sym_t: aout.Sym.Type = if (is_fn) .t else .d;
...@@ -670,7 +670,7 @@ pub fn flushModule(self: *Plan9, comp: *Compilation, prog_node: *std.Progress.No...@@ -670,7 +670,7 @@ pub fn flushModule(self: *Plan9, comp: *Compilation, prog_node: *std.Progress.No
670670
671 defer assert(self.hdr.entry != 0x0);671 defer assert(self.hdr.entry != 0x0);
672672
673 const mod = self.base.options.module orelse return error.LinkingWithoutZigSourceUnimplemented;673 const mod = self.base.comp.module orelse return error.LinkingWithoutZigSourceUnimplemented;
674674
675 // finish up the lazy syms675 // finish up the lazy syms
676 if (self.lazy_syms.getPtr(.none)) |metadata| {676 if (self.lazy_syms.getPtr(.none)) |metadata| {
...@@ -1032,7 +1032,7 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void {...@@ -1032,7 +1032,7 @@ pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void {
1032 // freeDecl without any updateDecl in between.1032 // freeDecl without any updateDecl in between.
1033 // However that is planned to change, see the TODO comment in Module.zig1033 // However that is planned to change, see the TODO comment in Module.zig
1034 // in the deleteUnusedDecl function.1034 // in the deleteUnusedDecl function.
1035 const mod = self.base.options.module.?;1035 const mod = self.base.comp.module.?;
1036 const decl = mod.declPtr(decl_index);1036 const decl = mod.declPtr(decl_index);
1037 const is_fn = decl.val.isFuncBody(mod);1037 const is_fn = decl.val.isFuncBody(mod);
1038 if (is_fn) {1038 if (is_fn) {
...@@ -1112,7 +1112,7 @@ pub fn seeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) !Atom.Index {...@@ -1112,7 +1112,7 @@ pub fn seeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) !Atom.Index {
1112 }1112 }
1113 const atom_idx = gop.value_ptr.index;1113 const atom_idx = gop.value_ptr.index;
1114 // handle externs here because they might not get updateDecl called on them1114 // handle externs here because they might not get updateDecl called on them
1115 const mod = self.base.options.module.?;1115 const mod = self.base.comp.module.?;
1116 const decl = mod.declPtr(decl_index);1116 const decl = mod.declPtr(decl_index);
1117 const name = mod.intern_pool.stringToSlice(decl.name);1117 const name = mod.intern_pool.stringToSlice(decl.name);
1118 if (decl.isExtern(mod)) {1118 if (decl.isExtern(mod)) {
...@@ -1147,7 +1147,7 @@ pub fn updateExports(...@@ -1147,7 +1147,7 @@ pub fn updateExports(
11471147
1148pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.Index {1148pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.Index {
1149 const gpa = self.base.comp.gpa;1149 const gpa = self.base.comp.gpa;
1150 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(self.base.options.module.?));1150 const gop = try self.lazy_syms.getOrPut(gpa, sym.getDecl(self.base.comp.module.?));
1151 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();1151 errdefer _ = if (!gop.found_existing) self.lazy_syms.pop();
11521152
1153 if (!gop.found_existing) gop.value_ptr.* = .{};1153 if (!gop.found_existing) gop.value_ptr.* = .{};
...@@ -1166,7 +1166,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.In...@@ -1166,7 +1166,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.In
1166 _ = try self.getAtomPtr(atom).getOrCreateSymbolTableEntry(self);1166 _ = try self.getAtomPtr(atom).getOrCreateSymbolTableEntry(self);
1167 _ = self.getAtomPtr(atom).getOrCreateOffsetTableEntry(self);1167 _ = self.getAtomPtr(atom).getOrCreateOffsetTableEntry(self);
1168 // anyerror needs to be deferred until flushModule1168 // anyerror needs to be deferred until flushModule
1169 if (sym.getDecl(self.base.options.module.?) != .none) {1169 if (sym.getDecl(self.base.comp.module.?) != .none) {
1170 try self.updateLazySymbolAtom(sym, atom);1170 try self.updateLazySymbolAtom(sym, atom);
1171 }1171 }
1172 return atom;1172 return atom;
...@@ -1174,7 +1174,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.In...@@ -1174,7 +1174,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Plan9, sym: File.LazySymbol) !Atom.In
11741174
1175fn updateLazySymbolAtom(self: *Plan9, sym: File.LazySymbol, atom_index: Atom.Index) !void {1175fn updateLazySymbolAtom(self: *Plan9, sym: File.LazySymbol, atom_index: Atom.Index) !void {
1176 const gpa = self.base.comp.gpa;1176 const gpa = self.base.comp.gpa;
1177 const mod = self.base.options.module.?;1177 const mod = self.base.comp.module.?;
11781178
1179 var required_alignment: InternPool.Alignment = .none;1179 var required_alignment: InternPool.Alignment = .none;
1180 var code_buffer = std.ArrayList(u8).init(gpa);1180 var code_buffer = std.ArrayList(u8).init(gpa);
...@@ -1348,7 +1348,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {...@@ -1348,7 +1348,7 @@ pub fn writeSym(self: *Plan9, w: anytype, sym: aout.Sym) !void {
1348}1348}
13491349
1350pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {1350pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
1351 const mod = self.base.options.module.?;1351 const mod = self.base.comp.module.?;
1352 const ip = &mod.intern_pool;1352 const ip = &mod.intern_pool;
1353 const writer = buf.writer();1353 const writer = buf.writer();
1354 // write __GOT1354 // write __GOT
...@@ -1374,7 +1374,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {...@@ -1374,7 +1374,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
1374 const atom = self.getAtom(decl_metadata.index);1374 const atom = self.getAtom(decl_metadata.index);
1375 const sym = self.syms.items[atom.sym_index.?];1375 const sym = self.syms.items[atom.sym_index.?];
1376 try self.writeSym(writer, sym);1376 try self.writeSym(writer, sym);
1377 if (self.base.options.module.?.decl_exports.get(decl_index)) |exports| {1377 if (self.base.comp.module.?.decl_exports.get(decl_index)) |exports| {
1378 for (exports.items) |e| if (decl_metadata.getExport(self, ip.stringToSlice(e.opts.name))) |exp_i| {1378 for (exports.items) |e| if (decl_metadata.getExport(self, ip.stringToSlice(e.opts.name))) |exp_i| {
1379 try self.writeSym(writer, self.syms.items[exp_i]);1379 try self.writeSym(writer, self.syms.items[exp_i]);
1380 };1380 };
...@@ -1421,7 +1421,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {...@@ -1421,7 +1421,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
1421 const atom = self.getAtom(decl_metadata.index);1421 const atom = self.getAtom(decl_metadata.index);
1422 const sym = self.syms.items[atom.sym_index.?];1422 const sym = self.syms.items[atom.sym_index.?];
1423 try self.writeSym(writer, sym);1423 try self.writeSym(writer, sym);
1424 if (self.base.options.module.?.decl_exports.get(decl_index)) |exports| {1424 if (self.base.comp.module.?.decl_exports.get(decl_index)) |exports| {
1425 for (exports.items) |e| if (decl_metadata.getExport(self, ip.stringToSlice(e.opts.name))) |exp_i| {1425 for (exports.items) |e| if (decl_metadata.getExport(self, ip.stringToSlice(e.opts.name))) |exp_i| {
1426 const s = self.syms.items[exp_i];1426 const s = self.syms.items[exp_i];
1427 if (mem.eql(u8, s.name, "_start"))1427 if (mem.eql(u8, s.name, "_start"))
...@@ -1464,7 +1464,7 @@ pub fn getDeclVAddr(...@@ -1464,7 +1464,7 @@ pub fn getDeclVAddr(
1464 decl_index: InternPool.DeclIndex,1464 decl_index: InternPool.DeclIndex,
1465 reloc_info: link.File.RelocInfo,1465 reloc_info: link.File.RelocInfo,
1466) !u64 {1466) !u64 {
1467 const mod = self.base.options.module.?;1467 const mod = self.base.comp.module.?;
1468 const decl = mod.declPtr(decl_index);1468 const decl = mod.declPtr(decl_index);
1469 log.debug("getDeclVAddr for {s}", .{mod.intern_pool.stringToSlice(decl.name)});1469 log.debug("getDeclVAddr for {s}", .{mod.intern_pool.stringToSlice(decl.name)});
1470 if (decl.isExtern(mod)) {1470 if (decl.isExtern(mod)) {
...@@ -1517,7 +1517,7 @@ pub fn lowerAnonDecl(self: *Plan9, decl_val: InternPool.Index, src_loc: Module.S...@@ -1517,7 +1517,7 @@ pub fn lowerAnonDecl(self: *Plan9, decl_val: InternPool.Index, src_loc: Module.S
1517 // ...1517 // ...
1518 const gpa = self.base.comp.gpa;1518 const gpa = self.base.comp.gpa;
1519 const gop = try self.anon_decls.getOrPut(gpa, decl_val);1519 const gop = try self.anon_decls.getOrPut(gpa, decl_val);
1520 const mod = self.base.options.module.?;1520 const mod = self.base.comp.module.?;
1521 if (!gop.found_existing) {1521 if (!gop.found_existing) {
1522 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));1522 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
1523 const val = Value.fromInterned(decl_val);1523 const val = Value.fromInterned(decl_val);
src/link/SpirV.zig+1-1
...@@ -196,7 +196,7 @@ pub fn flushModule(self: *SpirV, comp: *Compilation, prog_node: *std.Progress.No...@@ -196,7 +196,7 @@ pub fn flushModule(self: *SpirV, comp: *Compilation, prog_node: *std.Progress.No
196 defer error_info.deinit();196 defer error_info.deinit();
197197
198 try error_info.appendSlice("zig_errors");198 try error_info.appendSlice("zig_errors");
199 const module = self.base.options.module.?;199 const module = self.base.comp.module.?;
200 for (module.global_error_set.keys()) |name_nts| {200 for (module.global_error_set.keys()) |name_nts| {
201 const name = module.intern_pool.stringToSlice(name_nts);201 const name = module.intern_pool.stringToSlice(name_nts);
202 // Errors can contain pretty much any character - to encode them in a string we must escape202 // Errors can contain pretty much any character - to encode them in a string we must escape
src/link/Wasm.zig+15-15
...@@ -632,7 +632,7 @@ pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) !At...@@ -632,7 +632,7 @@ pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) !At
632 gop.value_ptr.* = atom_index;632 gop.value_ptr.* = atom_index;
633 const atom = wasm.getAtom(atom_index);633 const atom = wasm.getAtom(atom_index);
634 const symbol = atom.symbolLoc().getSymbol(wasm);634 const symbol = atom.symbolLoc().getSymbol(wasm);
635 const mod = wasm.base.options.module.?;635 const mod = wasm.base.comp.module.?;
636 const decl = mod.declPtr(decl_index);636 const decl = mod.declPtr(decl_index);
637 const full_name = mod.intern_pool.stringToSlice(try decl.getFullyQualifiedName(mod));637 const full_name = mod.intern_pool.stringToSlice(try decl.getFullyQualifiedName(mod));
638 symbol.name = try wasm.string_table.put(gpa, full_name);638 symbol.name = try wasm.string_table.put(gpa, full_name);
...@@ -1568,7 +1568,7 @@ pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: InternPool.De...@@ -1568,7 +1568,7 @@ pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: InternPool.De
15681568
1569fn finishUpdateDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex, code: []const u8, symbol_tag: Symbol.Tag) !void {1569fn finishUpdateDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex, code: []const u8, symbol_tag: Symbol.Tag) !void {
1570 const gpa = wasm.base.comp.gpa;1570 const gpa = wasm.base.comp.gpa;
1571 const mod = wasm.base.options.module.?;1571 const mod = wasm.base.comp.module.?;
1572 const decl = mod.declPtr(decl_index);1572 const decl = mod.declPtr(decl_index);
1573 const atom_index = wasm.decls.get(decl_index).?;1573 const atom_index = wasm.decls.get(decl_index).?;
1574 const atom = wasm.getAtomPtr(atom_index);1574 const atom = wasm.getAtomPtr(atom_index);
...@@ -1632,7 +1632,7 @@ fn getFunctionSignature(wasm: *const Wasm, loc: SymbolLoc) std.wasm.Type {...@@ -1632,7 +1632,7 @@ fn getFunctionSignature(wasm: *const Wasm, loc: SymbolLoc) std.wasm.Type {
1632/// The given `decl` is the parent decl whom owns the constant.1632/// The given `decl` is the parent decl whom owns the constant.
1633pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {1633pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
1634 const gpa = wasm.base.comp.gpa;1634 const gpa = wasm.base.comp.gpa;
1635 const mod = wasm.base.options.module.?;1635 const mod = wasm.base.comp.module.?;
1636 assert(tv.ty.zigTypeTag(mod) != .Fn); // cannot create local symbols for functions1636 assert(tv.ty.zigTypeTag(mod) != .Fn); // cannot create local symbols for functions
1637 const decl = mod.declPtr(decl_index);1637 const decl = mod.declPtr(decl_index);
16381638
...@@ -1665,7 +1665,7 @@ const LowerConstResult = union(enum) {...@@ -1665,7 +1665,7 @@ const LowerConstResult = union(enum) {
16651665
1666fn lowerConst(wasm: *Wasm, name: []const u8, tv: TypedValue, src_loc: Module.SrcLoc) !LowerConstResult {1666fn lowerConst(wasm: *Wasm, name: []const u8, tv: TypedValue, src_loc: Module.SrcLoc) !LowerConstResult {
1667 const gpa = wasm.base.comp.gpa;1667 const gpa = wasm.base.comp.gpa;
1668 const mod = wasm.base.options.module.?;1668 const mod = wasm.base.comp.module.?;
16691669
1670 // Create and initialize a new local symbol and atom1670 // Create and initialize a new local symbol and atom
1671 const atom_index = try wasm.createAtom();1671 const atom_index = try wasm.createAtom();
...@@ -1753,7 +1753,7 @@ pub fn getDeclVAddr(...@@ -1753,7 +1753,7 @@ pub fn getDeclVAddr(
1753 reloc_info: link.File.RelocInfo,1753 reloc_info: link.File.RelocInfo,
1754) !u64 {1754) !u64 {
1755 const gpa = wasm.base.comp.gpa;1755 const gpa = wasm.base.comp.gpa;
1756 const mod = wasm.base.options.module.?;1756 const mod = wasm.base.comp.module.?;
1757 const decl = mod.declPtr(decl_index);1757 const decl = mod.declPtr(decl_index);
17581758
1759 const target_atom_index = try wasm.getOrCreateAtomForDecl(decl_index);1759 const target_atom_index = try wasm.getOrCreateAtomForDecl(decl_index);
...@@ -1798,7 +1798,7 @@ pub fn lowerAnonDecl(...@@ -1798,7 +1798,7 @@ pub fn lowerAnonDecl(
1798 const gpa = wasm.base.comp.gpa;1798 const gpa = wasm.base.comp.gpa;
1799 const gop = try wasm.anon_decls.getOrPut(gpa, decl_val);1799 const gop = try wasm.anon_decls.getOrPut(gpa, decl_val);
1800 if (!gop.found_existing) {1800 if (!gop.found_existing) {
1801 const mod = wasm.base.options.module.?;1801 const mod = wasm.base.comp.module.?;
1802 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));1802 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
1803 const tv: TypedValue = .{ .ty = ty, .val = Value.fromInterned(decl_val) };1803 const tv: TypedValue = .{ .ty = ty, .val = Value.fromInterned(decl_val) };
1804 var name_buf: [32]u8 = undefined;1804 var name_buf: [32]u8 = undefined;
...@@ -1831,7 +1831,7 @@ pub fn getAnonDeclVAddr(wasm: *Wasm, decl_val: InternPool.Index, reloc_info: lin...@@ -1831,7 +1831,7 @@ pub fn getAnonDeclVAddr(wasm: *Wasm, decl_val: InternPool.Index, reloc_info: lin
1831 const parent_atom_index = wasm.symbol_atom.get(.{ .file = null, .index = reloc_info.parent_atom_index }).?;1831 const parent_atom_index = wasm.symbol_atom.get(.{ .file = null, .index = reloc_info.parent_atom_index }).?;
1832 const parent_atom = wasm.getAtomPtr(parent_atom_index);1832 const parent_atom = wasm.getAtomPtr(parent_atom_index);
1833 const is_wasm32 = wasm.base.options.target.cpu.arch == .wasm32;1833 const is_wasm32 = wasm.base.options.target.cpu.arch == .wasm32;
1834 const mod = wasm.base.options.module.?;1834 const mod = wasm.base.comp.module.?;
1835 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));1835 const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val));
1836 if (ty.zigTypeTag(mod) == .Fn) {1836 if (ty.zigTypeTag(mod) == .Fn) {
1837 assert(reloc_info.addend == 0); // addend not allowed for function relocations1837 assert(reloc_info.addend == 0); // addend not allowed for function relocations
...@@ -2004,7 +2004,7 @@ pub fn updateExports(...@@ -2004,7 +2004,7 @@ pub fn updateExports(
2004pub fn freeDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) void {2004pub fn freeDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) void {
2005 if (wasm.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);2005 if (wasm.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
2006 const gpa = wasm.base.comp.gpa;2006 const gpa = wasm.base.comp.gpa;
2007 const mod = wasm.base.options.module.?;2007 const mod = wasm.base.comp.module.?;
2008 const decl = mod.declPtr(decl_index);2008 const decl = mod.declPtr(decl_index);
2009 const atom_index = wasm.decls.get(decl_index).?;2009 const atom_index = wasm.decls.get(decl_index).?;
2010 const atom = wasm.getAtomPtr(atom_index);2010 const atom = wasm.getAtomPtr(atom_index);
...@@ -2492,7 +2492,7 @@ fn setupErrorsLen(wasm: *Wasm) !void {...@@ -2492,7 +2492,7 @@ fn setupErrorsLen(wasm: *Wasm) !void {
2492 const gpa = wasm.base.comp.gpa;2492 const gpa = wasm.base.comp.gpa;
2493 const loc = wasm.findGlobalSymbol("__zig_errors_len") orelse return;2493 const loc = wasm.findGlobalSymbol("__zig_errors_len") orelse return;
24942494
2495 const errors_len = wasm.base.options.module.?.global_error_set.count();2495 const errors_len = wasm.base.comp.module.?.global_error_set.count();
2496 // overwrite existing atom if it already exists (maybe the error set has increased)2496 // overwrite existing atom if it already exists (maybe the error set has increased)
2497 // if not, allcoate a new atom.2497 // if not, allcoate a new atom.
2498 const atom_index = if (wasm.symbol_atom.get(loc)) |index| blk: {2498 const atom_index = if (wasm.symbol_atom.get(loc)) |index| blk: {
...@@ -3268,7 +3268,7 @@ pub fn getErrorTableSymbol(wasm: *Wasm) !u32 {...@@ -3268,7 +3268,7 @@ pub fn getErrorTableSymbol(wasm: *Wasm) !u32 {
3268 const atom_index = try wasm.createAtom();3268 const atom_index = try wasm.createAtom();
3269 const atom = wasm.getAtomPtr(atom_index);3269 const atom = wasm.getAtomPtr(atom_index);
3270 const slice_ty = Type.slice_const_u8_sentinel_0;3270 const slice_ty = Type.slice_const_u8_sentinel_0;
3271 const mod = wasm.base.options.module.?;3271 const mod = wasm.base.comp.module.?;
3272 atom.alignment = slice_ty.abiAlignment(mod);3272 atom.alignment = slice_ty.abiAlignment(mod);
3273 const sym_index = atom.sym_index;3273 const sym_index = atom.sym_index;
32743274
...@@ -3322,7 +3322,7 @@ fn populateErrorNameTable(wasm: *Wasm) !void {...@@ -3322,7 +3322,7 @@ fn populateErrorNameTable(wasm: *Wasm) !void {
33223322
3323 // Addend for each relocation to the table3323 // Addend for each relocation to the table
3324 var addend: u32 = 0;3324 var addend: u32 = 0;
3325 const mod = wasm.base.options.module.?;3325 const mod = wasm.base.comp.module.?;
3326 for (mod.global_error_set.keys()) |error_name_nts| {3326 for (mod.global_error_set.keys()) |error_name_nts| {
3327 const atom = wasm.getAtomPtr(atom_index);3327 const atom = wasm.getAtomPtr(atom_index);
33283328
...@@ -3708,7 +3708,7 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -3708,7 +3708,7 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
3708 try wasm.markReferences();3708 try wasm.markReferences();
3709 try wasm.setupErrorsLen();3709 try wasm.setupErrorsLen();
3710 try wasm.setupImports();3710 try wasm.setupImports();
3711 if (wasm.base.options.module) |mod| {3711 if (wasm.base.comp.module) |mod| {
3712 var decl_it = wasm.decls.iterator();3712 var decl_it = wasm.decls.iterator();
3713 while (decl_it.next()) |entry| {3713 while (decl_it.next()) |entry| {
3714 const decl = mod.declPtr(entry.key_ptr.*);3714 const decl = mod.declPtr(entry.key_ptr.*);
...@@ -3759,7 +3759,7 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -3759,7 +3759,7 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
3759 }3759 }
37603760
3761 if (wasm.dwarf) |*dwarf| {3761 if (wasm.dwarf) |*dwarf| {
3762 try dwarf.flushModule(wasm.base.options.module.?);3762 try dwarf.flushModule(wasm.base.comp.module.?);
3763 }3763 }
3764 }3764 }
37653765
...@@ -4190,7 +4190,7 @@ fn writeToFile(...@@ -4190,7 +4190,7 @@ fn writeToFile(
4190 }4190 }
41914191
4192 // if (wasm.dwarf) |*dwarf| {4192 // if (wasm.dwarf) |*dwarf| {
4193 // const mod = wasm.base.options.module.?;4193 // const mod = wasm.base.comp.module.?;
4194 // try dwarf.writeDbgAbbrev();4194 // try dwarf.writeDbgAbbrev();
4195 // // for debug info and ranges, the address is always 0,4195 // // for debug info and ranges, the address is always 0,
4196 // // as locations are always offsets relative to 'code' section.4196 // // as locations are always offsets relative to 'code' section.
...@@ -4535,7 +4535,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -4535,7 +4535,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
45354535
4536 // If there is no Zig code to compile, then we should skip flushing the output file because it4536 // If there is no Zig code to compile, then we should skip flushing the output file because it
4537 // will not be part of the linker line anyway.4537 // will not be part of the linker line anyway.
4538 const module_obj_path: ?[]const u8 = if (wasm.base.options.module != null) blk: {4538 const module_obj_path: ?[]const u8 = if (wasm.base.comp.module != null) blk: {
4539 try wasm.flushModule(comp, prog_node);4539 try wasm.flushModule(comp, prog_node);
45404540
4541 if (fs.path.dirname(full_out_path)) |dirname| {4541 if (fs.path.dirname(full_out_path)) |dirname| {