| ... | ... | @@ -766,7 +766,7 @@ pub fn deinit(func: *CodeGen) void { |
| 766 | 766 | |
| 767 | 767 | /// Sets `err_msg` on `CodeGen` and returns `error.CodegenFail` which is caught in link/Wasm.zig |
| 768 | 768 | fn 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 | 770 | const src = LazySrcLoc.nodeOffset(0); |
| 771 | 771 | const src_loc = src.toSrcLoc(func.decl, mod); |
| 772 | 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 | 791 | const gop = try func.branches.items[0].values.getOrPut(func.gpa, ref); |
| 792 | 792 | assert(!gop.found_existing); |
| 793 | 793 | |
| 794 | | const mod = func.bin_file.base.options.module.?; |
| 794 | const mod = func.bin_file.base.comp.module.?; |
| 795 | 795 | const val = (try func.air.value(ref, mod)).?; |
| 796 | 796 | const ty = func.typeOf(ref); |
| 797 | 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 | 1101 | /// Creates one locals for a given `Type`. |
| 1102 | 1102 | /// Returns a corresponding `Wvalue` with `local` as active tag |
| 1103 | 1103 | fn 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 | 1105 | const valtype = typeToValtype(ty, mod); |
| 1106 | 1106 | switch (valtype) { |
| 1107 | 1107 | .i32 => if (func.free_locals_i32.popOrNull()) |index| { |
| ... | ... | @@ -1133,7 +1133,7 @@ fn allocLocal(func: *CodeGen, ty: Type) InnerError!WValue { |
| 1133 | 1133 | /// Ensures a new local will be created. This is useful when it's useful |
| 1134 | 1134 | /// to use a zero-initialized local. |
| 1135 | 1135 | fn 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 | 1137 | try func.locals.append(func.gpa, genValtype(ty, mod)); |
| 1138 | 1138 | const initial_index = func.local_index; |
| 1139 | 1139 | func.local_index += 1; |
| ... | ... | @@ -1237,7 +1237,7 @@ pub fn generate( |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | fn genFunc(func: *CodeGen) InnerError!void { |
| 1240 | | const mod = func.bin_file.base.options.module.?; |
| 1240 | const mod = func.bin_file.base.comp.module.?; |
| 1241 | 1241 | const ip = &mod.intern_pool; |
| 1242 | 1242 | const fn_info = mod.typeToFunc(func.decl.ty).?; |
| 1243 | 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 | 1348 | }; |
| 1349 | 1349 | |
| 1350 | 1350 | fn 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 | 1352 | const ip = &mod.intern_pool; |
| 1353 | 1353 | const fn_info = mod.typeToFunc(fn_ty).?; |
| 1354 | 1354 | const cc = fn_info.cc; |
| ... | ... | @@ -1417,7 +1417,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: |
| 1417 | 1417 | return func.lowerToStack(value); |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | | const mod = func.bin_file.base.options.module.?; |
| 1420 | const mod = func.bin_file.base.comp.module.?; |
| 1421 | 1421 | const ty_classes = abi.classifyType(ty, mod); |
| 1422 | 1422 | assert(ty_classes[0] != .none); |
| 1423 | 1423 | switch (ty.zigTypeTag(mod)) { |
| ... | ... | @@ -1516,7 +1516,7 @@ fn restoreStackPointer(func: *CodeGen) !void { |
| 1516 | 1516 | /// |
| 1517 | 1517 | /// Asserts Type has codegenbits |
| 1518 | 1518 | fn 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 | 1520 | assert(ty.hasRuntimeBitsIgnoreComptime(mod)); |
| 1521 | 1521 | if (func.initial_stack_value == .none) { |
| 1522 | 1522 | try func.initializeStack(); |
| ... | ... | @@ -1542,7 +1542,7 @@ fn allocStack(func: *CodeGen, ty: Type) !WValue { |
| 1542 | 1542 | /// This is different from allocStack where this will use the pointer's alignment |
| 1543 | 1543 | /// if it is set, to ensure the stack alignment will be set correctly. |
| 1544 | 1544 | fn 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 | 1546 | const ptr_ty = func.typeOfIndex(inst); |
| 1547 | 1547 | const pointee_ty = ptr_ty.childType(mod); |
| 1548 | 1548 | |
| ... | ... | @@ -2072,7 +2072,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | 2074 | fn 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 | 2076 | const ip = &mod.intern_pool; |
| 2077 | 2077 | |
| 2078 | 2078 | for (body) |inst| { |
| ... | ... | @@ -2093,7 +2093,7 @@ fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2093 | 2093 | } |
| 2094 | 2094 | |
| 2095 | 2095 | fn 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 | 2097 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 2098 | 2098 | const operand = try func.resolveInst(un_op); |
| 2099 | 2099 | const fn_info = mod.typeToFunc(func.decl.ty).?; |
| ... | ... | @@ -2136,7 +2136,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | fn 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 | 2140 | const child_type = func.typeOfIndex(inst).childType(mod); |
| 2141 | 2141 | |
| 2142 | 2142 | const result = result: { |
| ... | ... | @@ -2156,7 +2156,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2156 | 2156 | } |
| 2157 | 2157 | |
| 2158 | 2158 | fn 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 | 2160 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 2161 | 2161 | const operand = try func.resolveInst(un_op); |
| 2162 | 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 | 2183 | const args = @as([]const Air.Inst.Ref, @ptrCast(func.air.extra[extra.end..][0..extra.data.args_len])); |
| 2184 | 2184 | const ty = func.typeOf(pl_op.operand); |
| 2185 | 2185 | |
| 2186 | | const mod = func.bin_file.base.options.module.?; |
| 2186 | const mod = func.bin_file.base.comp.module.?; |
| 2187 | 2187 | const ip = &mod.intern_pool; |
| 2188 | 2188 | const fn_ty = switch (ty.zigTypeTag(mod)) { |
| 2189 | 2189 | .Fn => ty, |
| ... | ... | @@ -2295,7 +2295,7 @@ fn airAlloc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | fn 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 | 2299 | if (safety) { |
| 2300 | 2300 | // TODO if the value is undef, write 0xaa bytes to dest |
| 2301 | 2301 | } else { |
| ... | ... | @@ -2349,7 +2349,7 @@ fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void |
| 2349 | 2349 | |
| 2350 | 2350 | fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerError!void { |
| 2351 | 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 | 2353 | const abi_size = ty.abiSize(mod); |
| 2354 | 2354 | switch (ty.zigTypeTag(mod)) { |
| 2355 | 2355 | .ErrorUnion => { |
| ... | ... | @@ -2428,7 +2428,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE |
| 2428 | 2428 | }, |
| 2429 | 2429 | else => if (abi_size > 8) { |
| 2430 | 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 | 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 | 2456 | } |
| 2457 | 2457 | |
| 2458 | 2458 | fn 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 | 2460 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 2461 | 2461 | const operand = try func.resolveInst(ty_op.operand); |
| 2462 | 2462 | const ty = ty_op.ty.toType(); |
| ... | ... | @@ -2499,7 +2499,7 @@ fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2499 | 2499 | /// Loads an operand from the linear memory section. |
| 2500 | 2500 | /// NOTE: Leaves the value on the stack. |
| 2501 | 2501 | fn 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 | 2503 | // load local's value from memory by its stack position |
| 2504 | 2504 | try func.emitWValue(operand); |
| 2505 | 2505 | |
| ... | ... | @@ -2536,7 +2536,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu |
| 2536 | 2536 | } |
| 2537 | 2537 | |
| 2538 | 2538 | fn 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 | 2540 | const arg_index = func.arg_index; |
| 2541 | 2541 | const arg = func.args[arg_index]; |
| 2542 | 2542 | const cc = mod.typeToFunc(func.decl.ty).?.cc; |
| ... | ... | @@ -2555,7 +2555,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2555 | 2555 | if (arg_ty.zigTypeTag(mod) != .Int and arg_ty.zigTypeTag(mod) != .Float) { |
| 2556 | 2556 | return func.fail( |
| 2557 | 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 | 2561 | const result = try func.allocStack(arg_ty); |
| ... | ... | @@ -2582,7 +2582,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2582 | 2582 | } |
| 2583 | 2583 | |
| 2584 | 2584 | fn 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 | 2586 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 2587 | 2587 | const lhs = try func.resolveInst(bin_op.lhs); |
| 2588 | 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 | 2619 | /// Performs a binary operation on the given `WValue`'s |
| 2620 | 2620 | /// NOTE: THis leaves the value on top of the stack. |
| 2621 | 2621 | fn 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 | 2623 | assert(!(lhs != .stack and rhs == .stack)); |
| 2624 | 2624 | |
| 2625 | 2625 | if (ty.isAnyFloat()) { |
| ... | ... | @@ -2633,7 +2633,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError! |
| 2633 | 2633 | } else { |
| 2634 | 2634 | return func.fail( |
| 2635 | 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 | 2652 | } |
| 2653 | 2653 | |
| 2654 | 2654 | fn 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 | 2656 | const int_info = ty.intInfo(mod); |
| 2657 | 2657 | if (int_info.bits > 128) { |
| 2658 | 2658 | return func.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{}); |
| ... | ... | @@ -2788,7 +2788,7 @@ const FloatOp = enum { |
| 2788 | 2788 | }; |
| 2789 | 2789 | |
| 2790 | 2790 | fn 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 | 2792 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 2793 | 2793 | const operand = try func.resolveInst(ty_op.operand); |
| 2794 | 2794 | const ty = func.typeOf(ty_op.operand); |
| ... | ... | @@ -2873,7 +2873,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError |
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | fn 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 | 2877 | if (ty.zigTypeTag(mod) == .Vector) { |
| 2878 | 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 | 2979 | } |
| 2980 | 2980 | |
| 2981 | 2981 | fn 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 | 2983 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 2984 | 2984 | |
| 2985 | 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 | 3030 | /// Asserts `Type` is <= 128 bits. |
| 3031 | 3031 | /// NOTE: When the Type is <= 64 bits, leaves the value on top of the stack. |
| 3032 | 3032 | fn 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 | 3034 | assert(ty.abiSize(mod) <= 16); |
| 3035 | 3035 | const bitsize = @as(u16, @intCast(ty.bitSize(mod))); |
| 3036 | 3036 | const wasm_bits = toWasmBits(bitsize) orelse { |
| ... | ... | @@ -3069,7 +3069,7 @@ fn wrapOperand(func: *CodeGen, operand: WValue, ty: Type) InnerError!WValue { |
| 3069 | 3069 | } |
| 3070 | 3070 | |
| 3071 | 3071 | fn 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 | 3073 | const ptr = mod.intern_pool.indexToKey(ptr_val.ip_index).ptr; |
| 3074 | 3074 | switch (ptr.addr) { |
| 3075 | 3075 | .decl => |decl_index| { |
| ... | ... | @@ -3132,7 +3132,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue |
| 3132 | 3132 | } |
| 3133 | 3133 | |
| 3134 | 3134 | fn 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 | 3136 | const decl = mod.declPtr(decl_index); |
| 3137 | 3137 | try mod.markDeclAlive(decl); |
| 3138 | 3138 | const ptr_ty = try mod.singleMutPtrType(decl.ty); |
| ... | ... | @@ -3144,7 +3144,7 @@ fn lowerAnonDeclRef( |
| 3144 | 3144 | anon_decl: InternPool.Key.Ptr.Addr.AnonDecl, |
| 3145 | 3145 | offset: u32, |
| 3146 | 3146 | ) InnerError!WValue { |
| 3147 | | const mod = func.bin_file.base.options.module.?; |
| 3147 | const mod = func.bin_file.base.comp.module.?; |
| 3148 | 3148 | const decl_val = anon_decl.val; |
| 3149 | 3149 | const ty = Type.fromInterned(mod.intern_pool.typeOf(decl_val)); |
| 3150 | 3150 | |
| ... | ... | @@ -3172,7 +3172,7 @@ fn lowerAnonDeclRef( |
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | 3174 | fn 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 | 3176 | if (tv.ty.isSlice(mod)) { |
| 3177 | 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 | 3225 | /// This function is intended to assert that `isByRef` returns `false` for `ty`. |
| 3226 | 3226 | /// However such an assertion fails on the behavior tests currently. |
| 3227 | 3227 | fn 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 | 3229 | // TODO: enable this assertion |
| 3230 | 3230 | //assert(!isByRef(ty, mod)); |
| 3231 | 3231 | const ip = &mod.intern_pool; |
| ... | ... | @@ -3394,7 +3394,7 @@ fn storeSimdImmd(func: *CodeGen, value: [16]u8) !WValue { |
| 3394 | 3394 | } |
| 3395 | 3395 | |
| 3396 | 3396 | fn 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 | 3398 | const ip = &mod.intern_pool; |
| 3399 | 3399 | switch (ty.zigTypeTag(mod)) { |
| 3400 | 3400 | .Bool, .ErrorSet => return WValue{ .imm32 = 0xaaaaaaaa }, |
| ... | ... | @@ -3436,7 +3436,7 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue { |
| 3436 | 3436 | /// It's illegal to provide a value with a type that cannot be represented |
| 3437 | 3437 | /// as an integer value. |
| 3438 | 3438 | fn 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.?; |
| 3440 | 3440 | |
| 3441 | 3441 | switch (val.ip_index) { |
| 3442 | 3442 | .none => {}, |
| ... | ... | @@ -3472,7 +3472,7 @@ fn intStorageAsI32(storage: InternPool.Key.Int.Storage, mod: *Module) i32 { |
| 3472 | 3472 | } |
| 3473 | 3473 | |
| 3474 | 3474 | fn 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 | 3476 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 3477 | 3477 | const block_ty = ty_pl.ty.toType(); |
| 3478 | 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 | 3593 | /// NOTE: This leaves the result on top of the stack, rather than a new local. |
| 3594 | 3594 | fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareOperator) InnerError!WValue { |
| 3595 | 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 | 3597 | if (ty.zigTypeTag(mod) == .Optional and !ty.optionalReprIsPayload(mod)) { |
| 3598 | 3598 | const payload_ty = ty.optionalChild(mod); |
| 3599 | 3599 | if (payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -3711,7 +3711,7 @@ fn airCmpLtErrorsLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3711 | 3711 | const errors_len = WValue{ .memory = sym_index }; |
| 3712 | 3712 | |
| 3713 | 3713 | try func.emitWValue(operand); |
| 3714 | | const mod = func.bin_file.base.options.module.?; |
| 3714 | const mod = func.bin_file.base.comp.module.?; |
| 3715 | 3715 | const err_int_ty = try mod.errorIntType(); |
| 3716 | 3716 | const errors_len_val = try func.load(errors_len, err_int_ty, 0); |
| 3717 | 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 | 3720 | } |
| 3721 | 3721 | |
| 3722 | 3722 | fn 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 | 3724 | const br = func.air.instructions.items(.data)[@intFromEnum(inst)].br; |
| 3725 | 3725 | const block = func.blocks.get(br.block_inst).?; |
| 3726 | 3726 | |
| ... | ... | @@ -3747,7 +3747,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3747 | 3747 | |
| 3748 | 3748 | const operand = try func.resolveInst(ty_op.operand); |
| 3749 | 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.?; |
| 3751 | 3751 | |
| 3752 | 3752 | const result = result: { |
| 3753 | 3753 | if (operand_ty.zigTypeTag(mod) == .Bool) { |
| ... | ... | @@ -3818,7 +3818,7 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3818 | 3818 | const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand); |
| 3819 | 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 | 3822 | if (isByRef(given_ty, mod) and !isByRef(wanted_ty, mod)) { |
| 3823 | 3823 | const loaded_memory = try func.load(operand, wanted_ty, 0); |
| 3824 | 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 | 3834 | } |
| 3835 | 3835 | |
| 3836 | 3836 | fn 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 | 3838 | // if we bitcast a float to or from an integer we must use the 'reinterpret' instruction |
| 3839 | 3839 | if (!(wanted_ty.isAnyFloat() or given_ty.isAnyFloat())) return operand; |
| 3840 | 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 | 3852 | } |
| 3853 | 3853 | |
| 3854 | 3854 | fn 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 | 3856 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 3857 | 3857 | const extra = func.air.extraData(Air.StructField, ty_pl.payload); |
| 3858 | 3858 | |
| ... | ... | @@ -3864,7 +3864,7 @@ fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3864 | 3864 | } |
| 3865 | 3865 | |
| 3866 | 3866 | fn 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 | 3868 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 3869 | 3869 | const struct_ptr = try func.resolveInst(ty_op.operand); |
| 3870 | 3870 | const struct_ptr_ty = func.typeOf(ty_op.operand); |
| ... | ... | @@ -3883,7 +3883,7 @@ fn structFieldPtr( |
| 3883 | 3883 | struct_ty: Type, |
| 3884 | 3884 | index: u32, |
| 3885 | 3885 | ) InnerError!WValue { |
| 3886 | | const mod = func.bin_file.base.options.module.?; |
| 3886 | const mod = func.bin_file.base.comp.module.?; |
| 3887 | 3887 | const result_ty = func.typeOfIndex(inst); |
| 3888 | 3888 | const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); |
| 3889 | 3889 | |
| ... | ... | @@ -3914,7 +3914,7 @@ fn structFieldPtr( |
| 3914 | 3914 | } |
| 3915 | 3915 | |
| 3916 | 3916 | fn 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 | 3918 | const ip = &mod.intern_pool; |
| 3919 | 3919 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 3920 | 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 | 4013 | } |
| 4014 | 4014 | |
| 4015 | 4015 | fn 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 | 4017 | // result type is always 'noreturn' |
| 4018 | 4018 | const blocktype = wasm.block_empty; |
| 4019 | 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 | 4193 | } |
| 4194 | 4194 | |
| 4195 | 4195 | fn 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 | 4197 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 4198 | 4198 | const operand = try func.resolveInst(un_op); |
| 4199 | 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 | 4228 | } |
| 4229 | 4229 | |
| 4230 | 4230 | fn 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 | 4232 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4233 | 4233 | |
| 4234 | 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 | 4256 | } |
| 4257 | 4257 | |
| 4258 | 4258 | fn 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 | 4260 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4261 | 4261 | |
| 4262 | 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 | 4280 | } |
| 4281 | 4281 | |
| 4282 | 4282 | fn 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 | 4284 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4285 | 4285 | |
| 4286 | 4286 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -4310,7 +4310,7 @@ fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void |
| 4310 | 4310 | } |
| 4311 | 4311 | |
| 4312 | 4312 | fn 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 | 4314 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4315 | 4315 | |
| 4316 | 4316 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -4342,7 +4342,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4342 | 4342 | const ty = ty_op.ty.toType(); |
| 4343 | 4343 | const operand = try func.resolveInst(ty_op.operand); |
| 4344 | 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 | 4346 | if (ty.zigTypeTag(mod) == .Vector or operand_ty.zigTypeTag(mod) == .Vector) { |
| 4347 | 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 | 4365 | /// Asserts type's bitsize <= 128 |
| 4366 | 4366 | /// NOTE: May leave the result on the top of the stack. |
| 4367 | 4367 | fn 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 | 4369 | const given_bitsize = @as(u16, @intCast(given.bitSize(mod))); |
| 4370 | 4370 | const wanted_bitsize = @as(u16, @intCast(wanted.bitSize(mod))); |
| 4371 | 4371 | assert(given_bitsize <= 128); |
| ... | ... | @@ -4433,7 +4433,7 @@ fn intcast(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerErro |
| 4433 | 4433 | } |
| 4434 | 4434 | |
| 4435 | 4435 | fn 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 | 4437 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 4438 | 4438 | const operand = try func.resolveInst(un_op); |
| 4439 | 4439 | |
| ... | ... | @@ -4447,7 +4447,7 @@ fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind: |
| 4447 | 4447 | /// For a given type and operand, checks if it's considered `null`. |
| 4448 | 4448 | /// NOTE: Leaves the result on the stack |
| 4449 | 4449 | fn 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 | 4451 | try func.emitWValue(operand); |
| 4452 | 4452 | const payload_ty = optional_ty.optionalChild(mod); |
| 4453 | 4453 | if (!optional_ty.optionalReprIsPayload(mod)) { |
| ... | ... | @@ -4475,7 +4475,7 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcod |
| 4475 | 4475 | } |
| 4476 | 4476 | |
| 4477 | 4477 | fn 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 | 4479 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4480 | 4480 | const opt_ty = func.typeOf(ty_op.operand); |
| 4481 | 4481 | const payload_ty = func.typeOfIndex(inst); |
| ... | ... | @@ -4498,7 +4498,7 @@ fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4498 | 4498 | } |
| 4499 | 4499 | |
| 4500 | 4500 | fn 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 | 4502 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4503 | 4503 | const operand = try func.resolveInst(ty_op.operand); |
| 4504 | 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 | 4515 | } |
| 4516 | 4516 | |
| 4517 | 4517 | fn 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 | 4519 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4520 | 4520 | const operand = try func.resolveInst(ty_op.operand); |
| 4521 | 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 | 4543 | fn airWrapOptional(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4544 | 4544 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4545 | 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.?; |
| 4547 | 4547 | |
| 4548 | 4548 | const result = result: { |
| 4549 | 4549 | if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) { |
| ... | ... | @@ -4600,7 +4600,7 @@ fn airSliceLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4600 | 4600 | } |
| 4601 | 4601 | |
| 4602 | 4602 | fn 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 | 4604 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 4605 | 4605 | |
| 4606 | 4606 | const slice_ty = func.typeOf(bin_op.lhs); |
| ... | ... | @@ -4630,7 +4630,7 @@ fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4630 | 4630 | } |
| 4631 | 4631 | |
| 4632 | 4632 | fn 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 | 4634 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 4635 | 4635 | const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data; |
| 4636 | 4636 | |
| ... | ... | @@ -4683,7 +4683,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4683 | 4683 | /// Truncates a given operand to a given type, discarding any overflown bits. |
| 4684 | 4684 | /// NOTE: Resulting value is left on the stack. |
| 4685 | 4685 | fn 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 | 4687 | const given_bits = @as(u16, @intCast(given_ty.bitSize(mod))); |
| 4688 | 4688 | if (toWasmBits(given_bits) == null) { |
| 4689 | 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 | 4707 | } |
| 4708 | 4708 | |
| 4709 | 4709 | fn 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 | 4711 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4712 | 4712 | |
| 4713 | 4713 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -4730,7 +4730,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4730 | 4730 | } |
| 4731 | 4731 | |
| 4732 | 4732 | fn 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 | 4734 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 4735 | 4735 | const operand = try func.resolveInst(un_op); |
| 4736 | 4736 | const ptr_ty = func.typeOf(un_op); |
| ... | ... | @@ -4745,7 +4745,7 @@ fn airIntFromPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4745 | 4745 | } |
| 4746 | 4746 | |
| 4747 | 4747 | fn 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 | 4749 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 4750 | 4750 | |
| 4751 | 4751 | const ptr_ty = func.typeOf(bin_op.lhs); |
| ... | ... | @@ -4782,7 +4782,7 @@ fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4782 | 4782 | } |
| 4783 | 4783 | |
| 4784 | 4784 | fn 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 | 4786 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 4787 | 4787 | const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data; |
| 4788 | 4788 | |
| ... | ... | @@ -4812,7 +4812,7 @@ fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4812 | 4812 | } |
| 4813 | 4813 | |
| 4814 | 4814 | fn 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 | 4816 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 4817 | 4817 | const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data; |
| 4818 | 4818 | |
| ... | ... | @@ -4840,7 +4840,7 @@ fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 4840 | 4840 | } |
| 4841 | 4841 | |
| 4842 | 4842 | fn 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 | 4844 | if (safety) { |
| 4845 | 4845 | // TODO if the value is undef, write 0xaa bytes to dest |
| 4846 | 4846 | } else { |
| ... | ... | @@ -4873,7 +4873,7 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void |
| 4873 | 4873 | /// this to wasm's memset instruction. When the feature is not present, |
| 4874 | 4874 | /// we implement it manually. |
| 4875 | 4875 | fn 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 | 4877 | const abi_size = @as(u32, @intCast(elem_ty.abiSize(mod))); |
| 4878 | 4878 | |
| 4879 | 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 | 4962 | } |
| 4963 | 4963 | |
| 4964 | 4964 | fn 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 | 4966 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 4967 | 4967 | |
| 4968 | 4968 | const array_ty = func.typeOf(bin_op.lhs); |
| ... | ... | @@ -5031,7 +5031,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5031 | 5031 | } |
| 5032 | 5032 | |
| 5033 | 5033 | fn 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 | 5035 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5036 | 5036 | |
| 5037 | 5037 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -5076,7 +5076,7 @@ fn airIntFromFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5076 | 5076 | } |
| 5077 | 5077 | |
| 5078 | 5078 | fn 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 | 5080 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5081 | 5081 | |
| 5082 | 5082 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -5122,7 +5122,7 @@ fn airFloatFromInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5122 | 5122 | } |
| 5123 | 5123 | |
| 5124 | 5124 | fn 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 | 5126 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5127 | 5127 | const operand = try func.resolveInst(ty_op.operand); |
| 5128 | 5128 | const ty = func.typeOfIndex(inst); |
| ... | ... | @@ -5201,7 +5201,7 @@ fn airSelect(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5201 | 5201 | } |
| 5202 | 5202 | |
| 5203 | 5203 | fn 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 | 5205 | const inst_ty = func.typeOfIndex(inst); |
| 5206 | 5206 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 5207 | 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 | 5270 | } |
| 5271 | 5271 | |
| 5272 | 5272 | fn 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 | 5274 | const ip = &mod.intern_pool; |
| 5275 | 5275 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 5276 | 5276 | const result_ty = func.typeOfIndex(inst); |
| ... | ... | @@ -5400,7 +5400,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5400 | 5400 | } |
| 5401 | 5401 | |
| 5402 | 5402 | fn 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 | 5404 | const ip = &mod.intern_pool; |
| 5405 | 5405 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 5406 | 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 | 5499 | } |
| 5500 | 5500 | |
| 5501 | 5501 | fn 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 | 5503 | assert(operand_ty.hasRuntimeBitsIgnoreComptime(mod)); |
| 5504 | 5504 | assert(op == .eq or op == .neq); |
| 5505 | 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 | 5535 | /// NOTE: Leaves the result of the comparison on top of the stack. |
| 5536 | 5536 | /// TODO: Lower this to compiler_rt call when bitsize > 128 |
| 5537 | 5537 | fn 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 | 5539 | assert(operand_ty.abiSize(mod) >= 16); |
| 5540 | 5540 | assert(!(lhs != .stack and rhs == .stack)); |
| 5541 | 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 | 5577 | } |
| 5578 | 5578 | |
| 5579 | 5579 | fn 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 | 5581 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 5582 | 5582 | const un_ty = func.typeOf(bin_op.lhs).childType(mod); |
| 5583 | 5583 | const tag_ty = func.typeOf(bin_op.rhs); |
| ... | ... | @@ -5601,7 +5601,7 @@ fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5601 | 5601 | } |
| 5602 | 5602 | |
| 5603 | 5603 | fn 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 | 5605 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5606 | 5606 | |
| 5607 | 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 | 5706 | } |
| 5707 | 5707 | |
| 5708 | 5708 | fn 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 | 5710 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5711 | 5711 | |
| 5712 | 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 | 5732 | } |
| 5733 | 5733 | |
| 5734 | 5734 | fn 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 | 5736 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 5737 | 5737 | const extra = func.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; |
| 5738 | 5738 | |
| ... | ... | @@ -5753,7 +5753,7 @@ fn airFieldParentPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5753 | 5753 | } |
| 5754 | 5754 | |
| 5755 | 5755 | fn 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 | 5757 | if (ptr_ty.isSlice(mod)) { |
| 5758 | 5758 | return func.slicePtr(ptr); |
| 5759 | 5759 | } else { |
| ... | ... | @@ -5762,7 +5762,7 @@ fn sliceOrArrayPtr(func: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue |
| 5762 | 5762 | } |
| 5763 | 5763 | |
| 5764 | 5764 | fn 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 | 5766 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 5767 | 5767 | const dst = try func.resolveInst(bin_op.lhs); |
| 5768 | 5768 | const dst_ty = func.typeOf(bin_op.lhs); |
| ... | ... | @@ -5802,7 +5802,7 @@ fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5802 | 5802 | } |
| 5803 | 5803 | |
| 5804 | 5804 | fn 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 | 5806 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 5807 | 5807 | |
| 5808 | 5808 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -5863,7 +5863,7 @@ fn airErrorName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5863 | 5863 | // to make a copy of the ptr+value but can point towards them directly. |
| 5864 | 5864 | const error_table_symbol = try func.bin_file.getErrorTableSymbol(); |
| 5865 | 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 | 5867 | const abi_size = name_ty.abiSize(mod); |
| 5868 | 5868 | |
| 5869 | 5869 | 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 | 5903 | const lhs_op = try func.resolveInst(extra.lhs); |
| 5904 | 5904 | const rhs_op = try func.resolveInst(extra.rhs); |
| 5905 | 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.?; |
| 5907 | 5907 | |
| 5908 | 5908 | if (lhs_ty.zigTypeTag(mod) == .Vector) { |
| 5909 | 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 | 5975 | } |
| 5976 | 5976 | |
| 5977 | 5977 | fn 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 | 5979 | assert(op == .add or op == .sub); |
| 5980 | 5980 | const int_info = ty.intInfo(mod); |
| 5981 | 5981 | const is_signed = int_info.signedness == .signed; |
| ... | ... | @@ -6040,7 +6040,7 @@ fn addSubWithOverflowBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, |
| 6040 | 6040 | } |
| 6041 | 6041 | |
| 6042 | 6042 | fn 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 | 6044 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 6045 | 6045 | const extra = func.air.extraData(Air.Bin, ty_pl.payload).data; |
| 6046 | 6046 | |
| ... | ... | @@ -6103,7 +6103,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6103 | 6103 | const lhs = try func.resolveInst(extra.lhs); |
| 6104 | 6104 | const rhs = try func.resolveInst(extra.rhs); |
| 6105 | 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.?; |
| 6107 | 6107 | |
| 6108 | 6108 | if (lhs_ty.zigTypeTag(mod) == .Vector) { |
| 6109 | 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 | 6273 | |
| 6274 | 6274 | fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 6275 | 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 | 6277 | const target = mod.getTarget(); |
| 6278 | 6278 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6279 | 6279 | |
| ... | ... | @@ -6317,7 +6317,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 6317 | 6317 | } |
| 6318 | 6318 | |
| 6319 | 6319 | fn 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 | 6321 | const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 6322 | 6322 | const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data; |
| 6323 | 6323 | |
| ... | ... | @@ -6351,7 +6351,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6351 | 6351 | } |
| 6352 | 6352 | |
| 6353 | 6353 | fn 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 | 6355 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 6356 | 6356 | |
| 6357 | 6357 | const ty = func.typeOf(ty_op.operand); |
| ... | ... | @@ -6404,7 +6404,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6404 | 6404 | } |
| 6405 | 6405 | |
| 6406 | 6406 | fn 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 | 6408 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 6409 | 6409 | |
| 6410 | 6410 | const ty = func.typeOf(ty_op.operand); |
| ... | ... | @@ -6471,7 +6471,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6471 | 6471 | fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void { |
| 6472 | 6472 | if (func.debug_output != .dwarf) return func.finishAir(inst, .none, &.{}); |
| 6473 | 6473 | |
| 6474 | | const mod = func.bin_file.base.options.module.?; |
| 6474 | const mod = func.bin_file.base.comp.module.?; |
| 6475 | 6475 | const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 6476 | 6476 | const ty = func.typeOf(pl_op.operand); |
| 6477 | 6477 | const operand = try func.resolveInst(pl_op.operand); |
| ... | ... | @@ -6517,7 +6517,7 @@ fn airTry(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6517 | 6517 | } |
| 6518 | 6518 | |
| 6519 | 6519 | fn 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 | 6521 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 6522 | 6522 | const extra = func.air.extraData(Air.TryPtr, ty_pl.payload); |
| 6523 | 6523 | const err_union_ptr = try func.resolveInst(extra.data.ptr); |
| ... | ... | @@ -6535,7 +6535,7 @@ fn lowerTry( |
| 6535 | 6535 | err_union_ty: Type, |
| 6536 | 6536 | operand_is_ptr: bool, |
| 6537 | 6537 | ) InnerError!WValue { |
| 6538 | | const mod = func.bin_file.base.options.module.?; |
| 6538 | const mod = func.bin_file.base.comp.module.?; |
| 6539 | 6539 | if (operand_is_ptr) { |
| 6540 | 6540 | return func.fail("TODO: lowerTry for pointers", .{}); |
| 6541 | 6541 | } |
| ... | ... | @@ -6584,7 +6584,7 @@ fn lowerTry( |
| 6584 | 6584 | } |
| 6585 | 6585 | |
| 6586 | 6586 | fn 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 | 6588 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 6589 | 6589 | |
| 6590 | 6590 | const ty = func.typeOfIndex(inst); |
| ... | ... | @@ -6655,7 +6655,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6655 | 6655 | } |
| 6656 | 6656 | |
| 6657 | 6657 | fn 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 | 6659 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6660 | 6660 | |
| 6661 | 6661 | const ty = func.typeOfIndex(inst); |
| ... | ... | @@ -6670,7 +6670,7 @@ fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6670 | 6670 | } |
| 6671 | 6671 | |
| 6672 | 6672 | fn 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 | 6674 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6675 | 6675 | |
| 6676 | 6676 | const ty = func.typeOfIndex(inst); |
| ... | ... | @@ -6693,7 +6693,7 @@ fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6693 | 6693 | fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6694 | 6694 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6695 | 6695 | |
| 6696 | | const mod = func.bin_file.base.options.module.?; |
| 6696 | const mod = func.bin_file.base.comp.module.?; |
| 6697 | 6697 | const ty = func.typeOfIndex(inst); |
| 6698 | 6698 | const lhs = try func.resolveInst(bin_op.lhs); |
| 6699 | 6699 | const rhs = try func.resolveInst(bin_op.rhs); |
| ... | ... | @@ -6806,7 +6806,7 @@ fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6806 | 6806 | } |
| 6807 | 6807 | |
| 6808 | 6808 | fn 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 | 6810 | const int_bits = ty.intInfo(mod).bits; |
| 6811 | 6811 | const wasm_bits = toWasmBits(int_bits) orelse { |
| 6812 | 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 | 6836 | fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6837 | 6837 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6838 | 6838 | |
| 6839 | | const mod = func.bin_file.base.options.module.?; |
| 6839 | const mod = func.bin_file.base.comp.module.?; |
| 6840 | 6840 | const ty = func.typeOfIndex(inst); |
| 6841 | 6841 | const lhs = try func.resolveInst(bin_op.lhs); |
| 6842 | 6842 | const rhs = try func.resolveInst(bin_op.rhs); |
| ... | ... | @@ -6883,7 +6883,7 @@ fn airMod(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6883 | 6883 | /// The result will be sign extended to 32 bits if N <= 32 or 64 bits if N <= 64. |
| 6884 | 6884 | /// Support for integers wider than 64 bits has not yet been implemented. |
| 6885 | 6885 | fn 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 | 6887 | const int_bits = ty.intInfo(mod).bits; |
| 6888 | 6888 | const wasm_bits = toWasmBits(int_bits) orelse { |
| 6889 | 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 | 6919 | assert(op == .add or op == .sub); |
| 6920 | 6920 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 6921 | 6921 | |
| 6922 | | const mod = func.bin_file.base.options.module.?; |
| 6922 | const mod = func.bin_file.base.comp.module.?; |
| 6923 | 6923 | const ty = func.typeOfIndex(inst); |
| 6924 | 6924 | const lhs = try func.resolveInst(bin_op.lhs); |
| 6925 | 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 | 6967 | } |
| 6968 | 6968 | |
| 6969 | 6969 | fn 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 | 6971 | const int_info = ty.intInfo(mod); |
| 6972 | 6972 | const wasm_bits = toWasmBits(int_info.bits).?; |
| 6973 | 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 | 7034 | fn airShlSat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7035 | 7035 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 7036 | 7036 | |
| 7037 | | const mod = func.bin_file.base.options.module.?; |
| 7037 | const mod = func.bin_file.base.comp.module.?; |
| 7038 | 7038 | const ty = func.typeOfIndex(inst); |
| 7039 | 7039 | const int_info = ty.intInfo(mod); |
| 7040 | 7040 | const is_signed = int_info.signedness == .signed; |
| ... | ... | @@ -7155,7 +7155,7 @@ fn callIntrinsic( |
| 7155 | 7155 | }; |
| 7156 | 7156 | |
| 7157 | 7157 | // Always pass over C-ABI |
| 7158 | | const mod = func.bin_file.base.options.module.?; |
| 7158 | const mod = func.bin_file.base.comp.module.?; |
| 7159 | 7159 | var func_type = try genFunctype(func.gpa, .C, param_types, return_type, mod); |
| 7160 | 7160 | defer func_type.deinit(func.gpa); |
| 7161 | 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 | 7208 | } |
| 7209 | 7209 | |
| 7210 | 7210 | fn 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 | 7212 | const enum_decl_index = enum_ty.getOwnerDecl(mod); |
| 7213 | 7213 | |
| 7214 | 7214 | var arena_allocator = std.heap.ArenaAllocator.init(func.gpa); |
| ... | ... | @@ -7364,7 +7364,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 7364 | 7364 | } |
| 7365 | 7365 | |
| 7366 | 7366 | fn 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 | 7368 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 7369 | 7369 | |
| 7370 | 7370 | const operand = try func.resolveInst(ty_op.operand); |
| ... | ... | @@ -7449,7 +7449,7 @@ inline fn useAtomicFeature(func: *const CodeGen) bool { |
| 7449 | 7449 | } |
| 7450 | 7450 | |
| 7451 | 7451 | fn 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 | 7453 | const ty_pl = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 7454 | 7454 | const extra = func.air.extraData(Air.Cmpxchg, ty_pl.payload).data; |
| 7455 | 7455 | |
| ... | ... | @@ -7522,7 +7522,7 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7522 | 7522 | } |
| 7523 | 7523 | |
| 7524 | 7524 | fn 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 | 7526 | const atomic_load = func.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load; |
| 7527 | 7527 | const ptr = try func.resolveInst(atomic_load.ptr); |
| 7528 | 7528 | const ty = func.typeOfIndex(inst); |
| ... | ... | @@ -7549,7 +7549,7 @@ fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7549 | 7549 | } |
| 7550 | 7550 | |
| 7551 | 7551 | fn 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 | 7553 | const pl_op = func.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 7554 | 7554 | const extra = func.air.extraData(Air.AtomicRmw, pl_op.payload).data; |
| 7555 | 7555 | |
| ... | ... | @@ -7735,7 +7735,7 @@ fn airFence(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7735 | 7735 | } |
| 7736 | 7736 | |
| 7737 | 7737 | fn 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 | 7739 | const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 7740 | 7740 | |
| 7741 | 7741 | const ptr = try func.resolveInst(bin_op.lhs); |
| ... | ... | @@ -7774,11 +7774,11 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 7774 | 7774 | } |
| 7775 | 7775 | |
| 7776 | 7776 | fn 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 | 7778 | return func.air.typeOf(inst, &mod.intern_pool); |
| 7779 | 7779 | } |
| 7780 | 7780 | |
| 7781 | 7781 | fn 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 | 7783 | return func.air.typeOfIndex(inst, &mod.intern_pool); |
| 7784 | 7784 | } |