authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-15 16:12:53-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:35-08:00
log4ecc4addc432792514a86f6a8fde0285de4468b2
treebc177b477d5acdfb4b255595210b905558ddae90
parent098e0b1906479e6aa3c4afb3aeff5c85504521c2

wasm codegen: remove dependency on PerThread where possible


1 files changed, 81 insertions(+), 148 deletions(-)

src/arch/wasm/CodeGen.zig+81-148
...@@ -1233,7 +1233,7 @@ pub fn function(...@@ -1233,7 +1233,7 @@ pub fn function(
1233 const returns = fn_ty_index.ptr(wasm).returns.slice(wasm);1233 const returns = fn_ty_index.ptr(wasm).returns.slice(wasm);
1234 const any_returns = returns.len != 0;1234 const any_returns = returns.len != 0;
12351235
1236 var cc_result = try resolveCallingConventionValues(pt, fn_ty, target);1236 var cc_result = try resolveCallingConventionValues(zcu, fn_ty, target);
1237 defer cc_result.deinit(gpa);1237 defer cc_result.deinit(gpa);
12381238
1239 var code_gen: CodeGen = .{1239 var code_gen: CodeGen = .{
...@@ -1267,8 +1267,7 @@ pub fn function(...@@ -1267,8 +1267,7 @@ pub fn function(
12671267
1268fn functionInner(cg: *CodeGen, any_returns: bool) InnerError!Function {1268fn functionInner(cg: *CodeGen, any_returns: bool) InnerError!Function {
1269 const wasm = cg.wasm;1269 const wasm = cg.wasm;
1270 const pt = cg.pt;1270 const zcu = cg.pt.zcu;
1271 const zcu = pt.zcu;
12721271
1273 const start_mir_off: u32 = @intCast(wasm.mir_instructions.len);1272 const start_mir_off: u32 = @intCast(wasm.mir_instructions.len);
1274 const start_mir_extra_off: u32 = @intCast(wasm.mir_extra.items.len);1273 const start_mir_extra_off: u32 = @intCast(wasm.mir_extra.items.len);
...@@ -1325,11 +1324,10 @@ const CallWValues = struct {...@@ -1325,11 +1324,10 @@ const CallWValues = struct {
1325};1324};
13261325
1327fn resolveCallingConventionValues(1326fn resolveCallingConventionValues(
1328 pt: Zcu.PerThread,1327 zcu: *const Zcu,
1329 fn_ty: Type,1328 fn_ty: Type,
1330 target: *const std.Target,1329 target: *const std.Target,
1331) Allocator.Error!CallWValues {1330) Allocator.Error!CallWValues {
1332 const zcu = pt.zcu;
1333 const gpa = zcu.gpa;1331 const gpa = zcu.gpa;
1334 const ip = &zcu.intern_pool;1332 const ip = &zcu.intern_pool;
1335 const fn_info = zcu.typeToFunc(fn_ty).?;1333 const fn_info = zcu.typeToFunc(fn_ty).?;
...@@ -1407,8 +1405,7 @@ fn lowerArg(cg: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WV...@@ -1407,8 +1405,7 @@ fn lowerArg(cg: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value: WV
1407 return cg.lowerToStack(value);1405 return cg.lowerToStack(value);
1408 }1406 }
14091407
1410 const pt = cg.pt;1408 const zcu = cg.pt.zcu;
1411 const zcu = pt.zcu;
1412 const ty_classes = abi.classifyType(ty, zcu);1409 const ty_classes = abi.classifyType(ty, zcu);
1413 assert(ty_classes[0] != .none);1410 assert(ty_classes[0] != .none);
1414 switch (ty.zigTypeTag(zcu)) {1411 switch (ty.zigTypeTag(zcu)) {
...@@ -1494,7 +1491,8 @@ fn restoreStackPointer(cg: *CodeGen) !void {...@@ -1494,7 +1491,8 @@ fn restoreStackPointer(cg: *CodeGen) !void {
1494///1491///
1495/// Asserts Type has codegenbits1492/// Asserts Type has codegenbits
1496fn allocStack(cg: *CodeGen, ty: Type) !WValue {1493fn allocStack(cg: *CodeGen, ty: Type) !WValue {
1497 const zcu = cg.pt.zcu;1494 const pt = cg.pt;
1495 const zcu = pt.zcu;
1498 assert(ty.hasRuntimeBitsIgnoreComptime(zcu));1496 assert(ty.hasRuntimeBitsIgnoreComptime(zcu));
1499 if (cg.initial_stack_value == .none) {1497 if (cg.initial_stack_value == .none) {
1500 try cg.initializeStack();1498 try cg.initializeStack();
...@@ -1502,7 +1500,7 @@ fn allocStack(cg: *CodeGen, ty: Type) !WValue {...@@ -1502,7 +1500,7 @@ fn allocStack(cg: *CodeGen, ty: Type) !WValue {
15021500
1503 const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse {1501 const abi_size = std.math.cast(u32, ty.abiSize(zcu)) orelse {
1504 return cg.fail("Type {} with ABI size of {d} exceeds stack frame size", .{1502 return cg.fail("Type {} with ABI size of {d} exceeds stack frame size", .{
1505 ty.fmt(cg.pt), ty.abiSize(zcu),1503 ty.fmt(pt), ty.abiSize(zcu),
1506 });1504 });
1507 };1505 };
1508 const abi_align = ty.abiAlignment(zcu);1506 const abi_align = ty.abiAlignment(zcu);
...@@ -2038,8 +2036,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2038,8 +2036,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2038}2036}
20392037
2040fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {2038fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2041 const pt = cg.pt;2039 const zcu = cg.pt.zcu;
2042 const zcu = pt.zcu;
2043 const ip = &zcu.intern_pool;2040 const ip = &zcu.intern_pool;
20442041
2045 for (body) |inst| {2042 for (body) |inst| {
...@@ -2060,8 +2057,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -2060,8 +2057,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2060}2057}
20612058
2062fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {2059fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2063 const pt = cg.pt;2060 const zcu = cg.pt.zcu;
2064 const zcu = pt.zcu;
2065 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;2061 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
2066 const operand = try cg.resolveInst(un_op);2062 const operand = try cg.resolveInst(un_op);
2067 const fn_info = zcu.typeToFunc(zcu.navValue(cg.owner_nav).typeOf(zcu)).?;2063 const fn_info = zcu.typeToFunc(zcu.navValue(cg.owner_nav).typeOf(zcu)).?;
...@@ -2104,8 +2100,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2104,8 +2100,7 @@ fn airRet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2104}2100}
21052101
2106fn airRetPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {2102fn airRetPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2107 const pt = cg.pt;2103 const zcu = cg.pt.zcu;
2108 const zcu = pt.zcu;
2109 const child_type = cg.typeOfIndex(inst).childType(zcu);2104 const child_type = cg.typeOfIndex(inst).childType(zcu);
21102105
2111 const result = result: {2106 const result = result: {
...@@ -2125,8 +2120,7 @@ fn airRetPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2125,8 +2120,7 @@ fn airRetPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2125}2120}
21262121
2127fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {2122fn airRetLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2128 const pt = cg.pt;2123 const zcu = cg.pt.zcu;
2129 const zcu = pt.zcu;
2130 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;2124 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
2131 const operand = try cg.resolveInst(un_op);2125 const operand = try cg.resolveInst(un_op);
2132 const ret_ty = cg.typeOf(un_op).childType(zcu);2126 const ret_ty = cg.typeOf(un_op).childType(zcu);
...@@ -2452,8 +2446,7 @@ fn airLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2452,8 +2446,7 @@ fn airLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2452/// Loads an operand from the linear memory section.2446/// Loads an operand from the linear memory section.
2453/// NOTE: Leaves the value on the stack.2447/// NOTE: Leaves the value on the stack.
2454fn load(cg: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValue {2448fn load(cg: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValue {
2455 const pt = cg.pt;2449 const zcu = cg.pt.zcu;
2456 const zcu = pt.zcu;
2457 // load local's value from memory by its stack position2450 // load local's value from memory by its stack position
2458 try cg.emitWValue(operand);2451 try cg.emitWValue(operand);
24592452
...@@ -2526,8 +2519,7 @@ fn airArg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2526,8 +2519,7 @@ fn airArg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2526}2519}
25272520
2528fn airBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {2521fn airBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
2529 const pt = cg.pt;2522 const zcu = cg.pt.zcu;
2530 const zcu = pt.zcu;
2531 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2523 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
2532 const lhs = try cg.resolveInst(bin_op.lhs);2524 const lhs = try cg.resolveInst(bin_op.lhs);
2533 const rhs = try cg.resolveInst(bin_op.rhs);2525 const rhs = try cg.resolveInst(bin_op.rhs);
...@@ -2594,8 +2586,7 @@ fn binOp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WV...@@ -2594,8 +2586,7 @@ fn binOp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WV
2594}2586}
25952587
2596fn binOpBigInt(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {2588fn binOpBigInt(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!WValue {
2597 const pt = cg.pt;2589 const zcu = cg.pt.zcu;
2598 const zcu = pt.zcu;
2599 const int_info = ty.intInfo(zcu);2590 const int_info = ty.intInfo(zcu);
2600 if (int_info.bits > 128) {2591 if (int_info.bits > 128) {
2601 return cg.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{});2592 return cg.fail("TODO: Implement binary operation for big integers larger than 128 bits", .{});
...@@ -2877,8 +2868,7 @@ fn airUnaryFloatOp(cg: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError!v...@@ -2877,8 +2868,7 @@ fn airUnaryFloatOp(cg: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError!v
2877}2868}
28782869
2879fn floatOp(cg: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {2870fn floatOp(cg: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {
2880 const pt = cg.pt;2871 const zcu = cg.pt.zcu;
2881 const zcu = pt.zcu;
2882 if (ty.zigTypeTag(zcu) == .vector) {2872 if (ty.zigTypeTag(zcu) == .vector) {
2883 return cg.fail("TODO: Implement floatOps for vectors", .{});2873 return cg.fail("TODO: Implement floatOps for vectors", .{});
2884 }2874 }
...@@ -2952,8 +2942,7 @@ fn floatNeg(cg: *CodeGen, ty: Type, arg: WValue) InnerError!WValue {...@@ -2952,8 +2942,7 @@ fn floatNeg(cg: *CodeGen, ty: Type, arg: WValue) InnerError!WValue {
2952}2942}
29532943
2954fn airWrapBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {2944fn airWrapBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
2955 const pt = cg.pt;2945 const zcu = cg.pt.zcu;
2956 const zcu = pt.zcu;
2957 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;2946 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
29582947
2959 const lhs = try cg.resolveInst(bin_op.lhs);2948 const lhs = try cg.resolveInst(bin_op.lhs);
...@@ -3000,8 +2989,7 @@ fn wrapBinOp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerErro...@@ -3000,8 +2989,7 @@ fn wrapBinOp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerErro
3000/// Asserts `Type` is <= 128 bits.2989/// Asserts `Type` is <= 128 bits.
3001/// NOTE: When the Type is <= 64 bits, leaves the value on top of the stack, if wrapping was needed.2990/// NOTE: When the Type is <= 64 bits, leaves the value on top of the stack, if wrapping was needed.
3002fn wrapOperand(cg: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {2991fn wrapOperand(cg: *CodeGen, operand: WValue, ty: Type) InnerError!WValue {
3003 const pt = cg.pt;2992 const zcu = cg.pt.zcu;
3004 const zcu = pt.zcu;
3005 assert(ty.abiSize(zcu) <= 16);2993 assert(ty.abiSize(zcu) <= 16);
3006 const int_bits: u16 = @intCast(ty.bitSize(zcu)); // TODO use ty.intInfo(zcu).bits2994 const int_bits: u16 = @intCast(ty.bitSize(zcu)); // TODO use ty.intInfo(zcu).bits
3007 const wasm_bits = toWasmBits(int_bits) orelse {2995 const wasm_bits = toWasmBits(int_bits) orelse {
...@@ -3275,8 +3263,7 @@ fn storeSimdImmd(cg: *CodeGen, value: [16]u8) !WValue {...@@ -3275,8 +3263,7 @@ fn storeSimdImmd(cg: *CodeGen, value: [16]u8) !WValue {
3275}3263}
32763264
3277fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue {3265fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue {
3278 const pt = cg.pt;3266 const zcu = cg.pt.zcu;
3279 const zcu = pt.zcu;
3280 const ip = &zcu.intern_pool;3267 const ip = &zcu.intern_pool;
3281 switch (ty.zigTypeTag(zcu)) {3268 switch (ty.zigTypeTag(zcu)) {
3282 .bool, .error_set => return .{ .imm32 = 0xaaaaaaaa },3269 .bool, .error_set => return .{ .imm32 = 0xaaaaaaaa },
...@@ -3317,16 +3304,15 @@ fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue {...@@ -3317,16 +3304,15 @@ fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue {
3317/// It's illegal to provide a value with a type that cannot be represented3304/// It's illegal to provide a value with a type that cannot be represented
3318/// as an integer value.3305/// as an integer value.
3319fn valueAsI32(cg: *const CodeGen, val: Value) i32 {3306fn valueAsI32(cg: *const CodeGen, val: Value) i32 {
3320 const pt = cg.pt;3307 const zcu = cg.pt.zcu;
3321 const zcu = pt.zcu;
3322 const ip = &zcu.intern_pool;3308 const ip = &zcu.intern_pool;
33233309
3324 switch (val.toIntern()) {3310 switch (val.toIntern()) {
3325 .bool_true => return 1,3311 .bool_true => return 1,
3326 .bool_false => return 0,3312 .bool_false => return 0,
3327 else => return switch (ip.indexToKey(val.ip_index)) {3313 else => return switch (ip.indexToKey(val.ip_index)) {
3328 .enum_tag => |enum_tag| intIndexAsI32(ip, enum_tag.int, pt),3314 .enum_tag => |enum_tag| intIndexAsI32(ip, enum_tag.int, zcu),
3329 .int => |int| intStorageAsI32(int.storage, pt),3315 .int => |int| intStorageAsI32(int.storage, zcu),
3330 .ptr => |ptr| {3316 .ptr => |ptr| {
3331 assert(ptr.base_addr == .int);3317 assert(ptr.base_addr == .int);
3332 return @intCast(ptr.byte_offset);3318 return @intCast(ptr.byte_offset);
...@@ -3337,12 +3323,11 @@ fn valueAsI32(cg: *const CodeGen, val: Value) i32 {...@@ -3337,12 +3323,11 @@ fn valueAsI32(cg: *const CodeGen, val: Value) i32 {
3337 }3323 }
3338}3324}
33393325
3340fn intIndexAsI32(ip: *const InternPool, int: InternPool.Index, pt: Zcu.PerThread) i32 {3326fn intIndexAsI32(ip: *const InternPool, int: InternPool.Index, zcu: *const Zcu) i32 {
3341 return intStorageAsI32(ip.indexToKey(int).int.storage, pt);3327 return intStorageAsI32(ip.indexToKey(int).int.storage, zcu);
3342}3328}
33433329
3344fn intStorageAsI32(storage: InternPool.Key.Int.Storage, pt: Zcu.PerThread) i32 {3330fn intStorageAsI32(storage: InternPool.Key.Int.Storage, zcu: *const Zcu) i32 {
3345 const zcu = pt.zcu;
3346 return switch (storage) {3331 return switch (storage) {
3347 .i64 => |x| @as(i32, @intCast(x)),3332 .i64 => |x| @as(i32, @intCast(x)),
3348 .u64 => |x| @as(i32, @bitCast(@as(u32, @intCast(x)))),3333 .u64 => |x| @as(i32, @bitCast(@as(u32, @intCast(x)))),
...@@ -3359,8 +3344,7 @@ fn airBlock(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3359,8 +3344,7 @@ fn airBlock(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3359}3344}
33603345
3361fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, block_ty: Type, body: []const Air.Inst.Index) InnerError!void {3346fn lowerBlock(cg: *CodeGen, inst: Air.Inst.Index, block_ty: Type, body: []const Air.Inst.Index) InnerError!void {
3362 const pt = cg.pt;3347 const zcu = cg.pt.zcu;
3363 const zcu = pt.zcu;
3364 const wasm_block_ty = genBlockType(block_ty, zcu, cg.target);3348 const wasm_block_ty = genBlockType(block_ty, zcu, cg.target);
33653349
3366 // if wasm_block_ty is non-empty, we create a register to store the temporary value3350 // if wasm_block_ty is non-empty, we create a register to store the temporary value
...@@ -3478,8 +3462,7 @@ fn airCmp(cg: *CodeGen, inst: Air.Inst.Index, op: std.math.CompareOperator) Inne...@@ -3478,8 +3462,7 @@ fn airCmp(cg: *CodeGen, inst: Air.Inst.Index, op: std.math.CompareOperator) Inne
3478/// NOTE: This leaves the result on top of the stack, rather than a new local.3462/// NOTE: This leaves the result on top of the stack, rather than a new local.
3479fn cmp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareOperator) InnerError!WValue {3463fn cmp(cg: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareOperator) InnerError!WValue {
3480 assert(!(lhs != .stack and rhs == .stack));3464 assert(!(lhs != .stack and rhs == .stack));
3481 const pt = cg.pt;3465 const zcu = cg.pt.zcu;
3482 const zcu = pt.zcu;
3483 if (ty.zigTypeTag(zcu) == .optional and !ty.optionalReprIsPayload(zcu)) {3466 if (ty.zigTypeTag(zcu) == .optional and !ty.optionalReprIsPayload(zcu)) {
3484 const payload_ty = ty.optionalChild(zcu);3467 const payload_ty = ty.optionalChild(zcu);
3485 if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {3468 if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
...@@ -3699,8 +3682,7 @@ fn airUnreachable(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3699,8 +3682,7 @@ fn airUnreachable(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3699}3682}
37003683
3701fn airBitcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {3684fn airBitcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3702 const pt = cg.pt;3685 const zcu = cg.pt.zcu;
3703 const zcu = pt.zcu;
3704 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3686 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3705 const operand = try cg.resolveInst(ty_op.operand);3687 const operand = try cg.resolveInst(ty_op.operand);
3706 const wanted_ty = cg.typeOfIndex(inst);3688 const wanted_ty = cg.typeOfIndex(inst);
...@@ -3743,8 +3725,7 @@ fn airBitcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3743,8 +3725,7 @@ fn airBitcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3743}3725}
37443726
3745fn bitcast(cg: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) InnerError!WValue {3727fn bitcast(cg: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) InnerError!WValue {
3746 const pt = cg.pt;3728 const zcu = cg.pt.zcu;
3747 const zcu = pt.zcu;
3748 // if we bitcast a float to or from an integer we must use the 'reinterpret' instruction3729 // if we bitcast a float to or from an integer we must use the 'reinterpret' instruction
3749 if (!(wanted_ty.isAnyFloat() or given_ty.isAnyFloat())) return operand;3730 if (!(wanted_ty.isAnyFloat() or given_ty.isAnyFloat())) return operand;
3750 if (wanted_ty.ip_index == .f16_type or given_ty.ip_index == .f16_type) return operand;3731 if (wanted_ty.ip_index == .f16_type or given_ty.ip_index == .f16_type) return operand;
...@@ -3762,8 +3743,7 @@ fn bitcast(cg: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) Inner...@@ -3762,8 +3743,7 @@ fn bitcast(cg: *CodeGen, wanted_ty: Type, given_ty: Type, operand: WValue) Inner
3762}3743}
37633744
3764fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {3745fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3765 const pt = cg.pt;3746 const zcu = cg.pt.zcu;
3766 const zcu = pt.zcu;
3767 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;3747 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
3768 const extra = cg.air.extraData(Air.StructField, ty_pl.payload);3748 const extra = cg.air.extraData(Air.StructField, ty_pl.payload);
37693749
...@@ -3775,8 +3755,7 @@ fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3775,8 +3755,7 @@ fn airStructFieldPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3775}3755}
37763756
3777fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, index: u32) InnerError!void {3757fn airStructFieldPtrIndex(cg: *CodeGen, inst: Air.Inst.Index, index: u32) InnerError!void {
3778 const pt = cg.pt;3758 const zcu = cg.pt.zcu;
3779 const zcu = pt.zcu;
3780 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3759 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3781 const struct_ptr = try cg.resolveInst(ty_op.operand);3760 const struct_ptr = try cg.resolveInst(ty_op.operand);
3782 const struct_ptr_ty = cg.typeOf(ty_op.operand);3761 const struct_ptr_ty = cg.typeOf(ty_op.operand);
...@@ -4115,8 +4094,7 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4115,8 +4094,7 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4115}4094}
41164095
4117fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerError!void {4096fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerError!void {
4118 const pt = cg.pt;4097 const zcu = cg.pt.zcu;
4119 const zcu = pt.zcu;
4120 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4098 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4121 const operand = try cg.resolveInst(un_op);4099 const operand = try cg.resolveInst(un_op);
4122 const err_union_ty = cg.typeOf(un_op);4100 const err_union_ty = cg.typeOf(un_op);
...@@ -4148,8 +4126,7 @@ fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerEr...@@ -4148,8 +4126,7 @@ fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode) InnerEr
4148}4126}
41494127
4150fn airUnwrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {4128fn airUnwrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {
4151 const pt = cg.pt;4129 const zcu = cg.pt.zcu;
4152 const zcu = pt.zcu;
4153 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4130 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
41544131
4155 const operand = try cg.resolveInst(ty_op.operand);4132 const operand = try cg.resolveInst(ty_op.operand);
...@@ -4176,8 +4153,7 @@ fn airUnwrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)...@@ -4176,8 +4153,7 @@ fn airUnwrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)
4176}4153}
41774154
4178fn airUnwrapErrUnionError(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {4155fn airUnwrapErrUnionError(cg: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool) InnerError!void {
4179 const pt = cg.pt;4156 const zcu = cg.pt.zcu;
4180 const zcu = pt.zcu;
4181 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4157 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
41824158
4183 const operand = try cg.resolveInst(ty_op.operand);4159 const operand = try cg.resolveInst(ty_op.operand);
...@@ -4230,8 +4206,7 @@ fn airWrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4230,8 +4206,7 @@ fn airWrapErrUnionPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4230}4206}
42314207
4232fn airWrapErrUnionErr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4208fn airWrapErrUnionErr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4233 const pt = cg.pt;4209 const zcu = cg.pt.zcu;
4234 const zcu = pt.zcu;
4235 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4210 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
42364211
4237 const operand = try cg.resolveInst(ty_op.operand);4212 const operand = try cg.resolveInst(ty_op.operand);
...@@ -4263,8 +4238,7 @@ fn airIntcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4263,8 +4238,7 @@ fn airIntcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4263 const ty = ty_op.ty.toType();4238 const ty = ty_op.ty.toType();
4264 const operand = try cg.resolveInst(ty_op.operand);4239 const operand = try cg.resolveInst(ty_op.operand);
4265 const operand_ty = cg.typeOf(ty_op.operand);4240 const operand_ty = cg.typeOf(ty_op.operand);
4266 const pt = cg.pt;4241 const zcu = cg.pt.zcu;
4267 const zcu = pt.zcu;
4268 if (ty.zigTypeTag(zcu) == .vector or operand_ty.zigTypeTag(zcu) == .vector) {4242 if (ty.zigTypeTag(zcu) == .vector or operand_ty.zigTypeTag(zcu) == .vector) {
4269 return cg.fail("todo Wasm intcast for vectors", .{});4243 return cg.fail("todo Wasm intcast for vectors", .{});
4270 }4244 }
...@@ -4287,8 +4261,7 @@ fn airIntcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4287,8 +4261,7 @@ fn airIntcast(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4287/// Asserts type's bitsize <= 1284261/// Asserts type's bitsize <= 128
4288/// NOTE: May leave the result on the top of the stack.4262/// NOTE: May leave the result on the top of the stack.
4289fn intcast(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!WValue {4263fn intcast(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!WValue {
4290 const pt = cg.pt;4264 const zcu = cg.pt.zcu;
4291 const zcu = pt.zcu;
4292 const given_bitsize = @as(u16, @intCast(given.bitSize(zcu)));4265 const given_bitsize = @as(u16, @intCast(given.bitSize(zcu)));
4293 const wanted_bitsize = @as(u16, @intCast(wanted.bitSize(zcu)));4266 const wanted_bitsize = @as(u16, @intCast(wanted.bitSize(zcu)));
4294 assert(given_bitsize <= 128);4267 assert(given_bitsize <= 128);
...@@ -4337,8 +4310,7 @@ fn intcast(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!...@@ -4337,8 +4310,7 @@ fn intcast(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!
4337}4310}
43384311
4339fn airIsNull(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode, op_kind: enum { value, ptr }) InnerError!void {4312fn airIsNull(cg: *CodeGen, inst: Air.Inst.Index, opcode: std.wasm.Opcode, op_kind: enum { value, ptr }) InnerError!void {
4340 const pt = cg.pt;4313 const zcu = cg.pt.zcu;
4341 const zcu = pt.zcu;
4342 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4314 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4343 const operand = try cg.resolveInst(un_op);4315 const operand = try cg.resolveInst(un_op);
43444316
...@@ -4379,8 +4351,7 @@ fn isNull(cg: *CodeGen, operand: WValue, optional_ty: Type, opcode: std.wasm.Opc...@@ -4379,8 +4351,7 @@ fn isNull(cg: *CodeGen, operand: WValue, optional_ty: Type, opcode: std.wasm.Opc
4379}4351}
43804352
4381fn airOptionalPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4353fn airOptionalPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4382 const pt = cg.pt;4354 const zcu = cg.pt.zcu;
4383 const zcu = pt.zcu;
4384 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4355 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4385 const opt_ty = cg.typeOf(ty_op.operand);4356 const opt_ty = cg.typeOf(ty_op.operand);
4386 const payload_ty = cg.typeOfIndex(inst);4357 const payload_ty = cg.typeOfIndex(inst);
...@@ -4402,8 +4373,7 @@ fn airOptionalPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4402,8 +4373,7 @@ fn airOptionalPayload(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4402}4373}
44034374
4404fn airOptionalPayloadPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4375fn airOptionalPayloadPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4405 const pt = cg.pt;4376 const zcu = cg.pt.zcu;
4406 const zcu = pt.zcu;
4407 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4377 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
4408 const operand = try cg.resolveInst(ty_op.operand);4378 const operand = try cg.resolveInst(ty_op.operand);
4409 const opt_ty = cg.typeOf(ty_op.operand).childType(zcu);4379 const opt_ty = cg.typeOf(ty_op.operand).childType(zcu);
...@@ -4507,8 +4477,7 @@ fn airSliceLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4507,8 +4477,7 @@ fn airSliceLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4507}4477}
45084478
4509fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4479fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4510 const pt = cg.pt;4480 const zcu = cg.pt.zcu;
4511 const zcu = pt.zcu;
4512 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4481 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
45134482
4514 const slice_ty = cg.typeOf(bin_op.lhs);4483 const slice_ty = cg.typeOf(bin_op.lhs);
...@@ -4535,8 +4504,7 @@ fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4535,8 +4504,7 @@ fn airSliceElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4535}4504}
45364505
4537fn airSliceElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4506fn airSliceElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4538 const pt = cg.pt;4507 const zcu = cg.pt.zcu;
4539 const zcu = pt.zcu;
4540 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4508 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4541 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;4509 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;
45424510
...@@ -4579,8 +4547,7 @@ fn airTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4579,8 +4547,7 @@ fn airTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4579 const operand = try cg.resolveInst(ty_op.operand);4547 const operand = try cg.resolveInst(ty_op.operand);
4580 const wanted_ty: Type = ty_op.ty.toType();4548 const wanted_ty: Type = ty_op.ty.toType();
4581 const op_ty = cg.typeOf(ty_op.operand);4549 const op_ty = cg.typeOf(ty_op.operand);
4582 const pt = cg.pt;4550 const zcu = cg.pt.zcu;
4583 const zcu = pt.zcu;
45844551
4585 if (wanted_ty.zigTypeTag(zcu) == .vector or op_ty.zigTypeTag(zcu) == .vector) {4552 if (wanted_ty.zigTypeTag(zcu) == .vector or op_ty.zigTypeTag(zcu) == .vector) {
4586 return cg.fail("TODO: trunc for vectors", .{});4553 return cg.fail("TODO: trunc for vectors", .{});
...@@ -4597,8 +4564,7 @@ fn airTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4597,8 +4564,7 @@ fn airTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4597/// Truncates a given operand to a given type, discarding any overflown bits.4564/// Truncates a given operand to a given type, discarding any overflown bits.
4598/// NOTE: Resulting value is left on the stack.4565/// NOTE: Resulting value is left on the stack.
4599fn trunc(cg: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) InnerError!WValue {4566fn trunc(cg: *CodeGen, operand: WValue, wanted_ty: Type, given_ty: Type) InnerError!WValue {
4600 const pt = cg.pt;4567 const zcu = cg.pt.zcu;
4601 const zcu = pt.zcu;
4602 const given_bits = @as(u16, @intCast(given_ty.bitSize(zcu)));4568 const given_bits = @as(u16, @intCast(given_ty.bitSize(zcu)));
4603 if (toWasmBits(given_bits) == null) {4569 if (toWasmBits(given_bits) == null) {
4604 return cg.fail("TODO: Implement wasm integer truncation for integer bitsize: {d}", .{given_bits});4570 return cg.fail("TODO: Implement wasm integer truncation for integer bitsize: {d}", .{given_bits});
...@@ -4622,8 +4588,7 @@ fn airIntFromBool(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4622,8 +4588,7 @@ fn airIntFromBool(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4622}4588}
46234589
4624fn airArrayToSlice(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4590fn airArrayToSlice(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4625 const pt = cg.pt;4591 const zcu = cg.pt.zcu;
4626 const zcu = pt.zcu;
4627 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4592 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
46284593
4629 const operand = try cg.resolveInst(ty_op.operand);4594 const operand = try cg.resolveInst(ty_op.operand);
...@@ -4646,8 +4611,7 @@ fn airArrayToSlice(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4646,8 +4611,7 @@ fn airArrayToSlice(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4646}4611}
46474612
4648fn airIntFromPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4613fn airIntFromPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4649 const pt = cg.pt;4614 const zcu = cg.pt.zcu;
4650 const zcu = pt.zcu;
4651 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4615 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4652 const operand = try cg.resolveInst(un_op);4616 const operand = try cg.resolveInst(un_op);
4653 const ptr_ty = cg.typeOf(un_op);4617 const ptr_ty = cg.typeOf(un_op);
...@@ -4662,8 +4626,7 @@ fn airIntFromPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4662,8 +4626,7 @@ fn airIntFromPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4662}4626}
46634627
4664fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4628fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4665 const pt = cg.pt;4629 const zcu = cg.pt.zcu;
4666 const zcu = pt.zcu;
4667 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4630 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
46684631
4669 const ptr_ty = cg.typeOf(bin_op.lhs);4632 const ptr_ty = cg.typeOf(bin_op.lhs);
...@@ -4694,8 +4657,7 @@ fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4694,8 +4657,7 @@ fn airPtrElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4694}4657}
46954658
4696fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4659fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4697 const pt = cg.pt;4660 const zcu = cg.pt.zcu;
4698 const zcu = pt.zcu;
4699 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4661 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4700 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;4662 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;
47014663
...@@ -4723,8 +4685,7 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4723,8 +4685,7 @@ fn airPtrElemPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4723}4685}
47244686
4725fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {4687fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
4726 const pt = cg.pt;4688 const zcu = cg.pt.zcu;
4727 const zcu = pt.zcu;
4728 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;4689 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
4729 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;4690 const bin_op = cg.air.extraData(Air.Bin, ty_pl.payload).data;
47304691
...@@ -4750,8 +4711,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -4750,8 +4711,7 @@ fn airPtrBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
4750}4711}
47514712
4752fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {4713fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
4753 const pt = cg.pt;4714 const zcu = cg.pt.zcu;
4754 const zcu = pt.zcu;
4755 if (safety) {4715 if (safety) {
4756 // TODO if the value is undef, write 0xaa bytes to dest4716 // TODO if the value is undef, write 0xaa bytes to dest
4757 } else {4717 } else {
...@@ -4784,8 +4744,8 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {...@@ -4784,8 +4744,8 @@ fn airMemset(cg: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void {
4784/// this to wasm's memset instruction. When the feature is not present,4744/// this to wasm's memset instruction. When the feature is not present,
4785/// we implement it manually.4745/// we implement it manually.
4786fn memset(cg: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue) InnerError!void {4746fn memset(cg: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue) InnerError!void {
4787 const pt = cg.pt;4747 const zcu = cg.pt.zcu;
4788 const abi_size = @as(u32, @intCast(elem_ty.abiSize(pt.zcu)));4748 const abi_size = @as(u32, @intCast(elem_ty.abiSize(zcu)));
47894749
4790 // When bulk_memory is enabled, we lower it to wasm's memset instruction.4750 // When bulk_memory is enabled, we lower it to wasm's memset instruction.
4791 // If not, we lower it ourselves.4751 // If not, we lower it ourselves.
...@@ -4869,8 +4829,7 @@ fn memset(cg: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue)...@@ -4869,8 +4829,7 @@ fn memset(cg: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue)
4869}4829}
48704830
4871fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4831fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4872 const pt = cg.pt;4832 const zcu = cg.pt.zcu;
4873 const zcu = pt.zcu;
4874 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4833 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
48754834
4876 const array_ty = cg.typeOf(bin_op.lhs);4835 const array_ty = cg.typeOf(bin_op.lhs);
...@@ -4931,8 +4890,7 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4931,8 +4890,7 @@ fn airArrayElemVal(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4931}4890}
49324891
4933fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4892fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4934 const pt = cg.pt;4893 const zcu = cg.pt.zcu;
4935 const zcu = pt.zcu;
4936 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4894 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
49374895
4938 const operand = try cg.resolveInst(ty_op.operand);4896 const operand = try cg.resolveInst(ty_op.operand);
...@@ -4983,8 +4941,7 @@ fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4983,8 +4941,7 @@ fn airIntFromFloat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4983}4941}
49844942
4985fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4943fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4986 const pt = cg.pt;4944 const zcu = cg.pt.zcu;
4987 const zcu = pt.zcu;
4988 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4945 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
49894946
4990 const operand = try cg.resolveInst(ty_op.operand);4947 const operand = try cg.resolveInst(ty_op.operand);
...@@ -5036,8 +4993,7 @@ fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5036,8 +4993,7 @@ fn airFloatFromInt(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5036}4993}
50374994
5038fn airSplat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4995fn airSplat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5039 const pt = cg.pt;4996 const zcu = cg.pt.zcu;
5040 const zcu = pt.zcu;
5041 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;4997 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
5042 const operand = try cg.resolveInst(ty_op.operand);4998 const operand = try cg.resolveInst(ty_op.operand);
5043 const ty = cg.typeOfIndex(inst);4999 const ty = cg.typeOfIndex(inst);
...@@ -5405,8 +5361,7 @@ fn airWasmMemoryGrow(cg: *CodeGen, inst: Air.Inst.Index) !void {...@@ -5405,8 +5361,7 @@ fn airWasmMemoryGrow(cg: *CodeGen, inst: Air.Inst.Index) !void {
5405}5361}
54065362
5407fn cmpOptionals(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {5363fn cmpOptionals(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {
5408 const pt = cg.pt;5364 const zcu = cg.pt.zcu;
5409 const zcu = pt.zcu;
5410 assert(operand_ty.hasRuntimeBitsIgnoreComptime(zcu));5365 assert(operand_ty.hasRuntimeBitsIgnoreComptime(zcu));
5411 assert(op == .eq or op == .neq);5366 assert(op == .eq or op == .neq);
5412 const payload_ty = operand_ty.optionalChild(zcu);5367 const payload_ty = operand_ty.optionalChild(zcu);
...@@ -5442,8 +5397,7 @@ fn cmpOptionals(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: st...@@ -5442,8 +5397,7 @@ fn cmpOptionals(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: st
5442/// NOTE: Leaves the result of the comparison on top of the stack.5397/// NOTE: Leaves the result of the comparison on top of the stack.
5443/// TODO: Lower this to compiler_rt call when bitsize > 1285398/// TODO: Lower this to compiler_rt call when bitsize > 128
5444fn cmpBigInt(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {5399fn cmpBigInt(cg: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std.math.CompareOperator) InnerError!WValue {
5445 const pt = cg.pt;5400 const zcu = cg.pt.zcu;
5446 const zcu = pt.zcu;
5447 assert(operand_ty.abiSize(zcu) >= 16);5401 assert(operand_ty.abiSize(zcu) >= 16);
5448 assert(!(lhs != .stack and rhs == .stack));5402 assert(!(lhs != .stack and rhs == .stack));
5449 if (operand_ty.bitSize(zcu) > 128) {5403 if (operand_ty.bitSize(zcu) > 128) {
...@@ -5637,8 +5591,7 @@ fn fptrunc(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!...@@ -5637,8 +5591,7 @@ fn fptrunc(cg: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!
5637}5591}
56385592
5639fn airErrUnionPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {5593fn airErrUnionPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5640 const pt = cg.pt;5594 const zcu = cg.pt.zcu;
5641 const zcu = pt.zcu;
5642 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5595 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
56435596
5644 const err_set_ty = cg.typeOf(ty_op.operand).childType(zcu);5597 const err_set_ty = cg.typeOf(ty_op.operand).childType(zcu);
...@@ -5664,8 +5617,7 @@ fn airErrUnionPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void...@@ -5664,8 +5617,7 @@ fn airErrUnionPayloadPtrSet(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void
5664}5617}
56655618
5666fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {5619fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5667 const pt = cg.pt;5620 const zcu = cg.pt.zcu;
5668 const zcu = pt.zcu;
5669 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;5621 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
5670 const extra = cg.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;5622 const extra = cg.air.extraData(Air.FieldParentPtr, ty_pl.payload).data;
56715623
...@@ -5686,8 +5638,7 @@ fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5686,8 +5638,7 @@ fn airFieldParentPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5686}5638}
56875639
5688fn sliceOrArrayPtr(cg: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {5640fn sliceOrArrayPtr(cg: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {
5689 const pt = cg.pt;5641 const zcu = cg.pt.zcu;
5690 const zcu = pt.zcu;
5691 if (ptr_ty.isSlice(zcu)) {5642 if (ptr_ty.isSlice(zcu)) {
5692 return cg.slicePtr(ptr);5643 return cg.slicePtr(ptr);
5693 } else {5644 } else {
...@@ -5696,8 +5647,7 @@ fn sliceOrArrayPtr(cg: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {...@@ -5696,8 +5647,7 @@ fn sliceOrArrayPtr(cg: *CodeGen, ptr: WValue, ptr_ty: Type) InnerError!WValue {
5696}5647}
56975648
5698fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {5649fn airMemcpy(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5699 const pt = cg.pt;5650 const zcu = cg.pt.zcu;
5700 const zcu = pt.zcu;
5701 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;5651 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
5702 const dst = try cg.resolveInst(bin_op.lhs);5652 const dst = try cg.resolveInst(bin_op.lhs);
5703 const dst_ty = cg.typeOf(bin_op.lhs);5653 const dst_ty = cg.typeOf(bin_op.lhs);
...@@ -5788,8 +5738,7 @@ fn airPopcount(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5788,8 +5738,7 @@ fn airPopcount(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5788}5738}
57895739
5790fn airBitReverse(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {5740fn airBitReverse(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5791 const pt = cg.pt;5741 const zcu = cg.pt.zcu;
5792 const zcu = pt.zcu;
5793 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;5742 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
57945743
5795 const operand = try cg.resolveInst(ty_op.operand);5744 const operand = try cg.resolveInst(ty_op.operand);
...@@ -6176,8 +6125,7 @@ fn airMaxMin(...@@ -6176,8 +6125,7 @@ fn airMaxMin(
6176 op: enum { fmax, fmin },6125 op: enum { fmax, fmin },
6177 cmp_op: std.math.CompareOperator,6126 cmp_op: std.math.CompareOperator,
6178) InnerError!void {6127) InnerError!void {
6179 const pt = cg.pt;6128 const zcu = cg.pt.zcu;
6180 const zcu = pt.zcu;
6181 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6129 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
61826130
6183 const ty = cg.typeOfIndex(inst);6131 const ty = cg.typeOfIndex(inst);
...@@ -6218,8 +6166,7 @@ fn airMaxMin(...@@ -6218,8 +6166,7 @@ fn airMaxMin(
6218}6166}
62196167
6220fn airMulAdd(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6168fn airMulAdd(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6221 const pt = cg.pt;6169 const zcu = cg.pt.zcu;
6222 const zcu = pt.zcu;
6223 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;6170 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
6224 const bin_op = cg.air.extraData(Air.Bin, pl_op.payload).data;6171 const bin_op = cg.air.extraData(Air.Bin, pl_op.payload).data;
62256172
...@@ -6253,8 +6200,7 @@ fn airMulAdd(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6253,8 +6200,7 @@ fn airMulAdd(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6253}6200}
62546201
6255fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6202fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6256 const pt = cg.pt;6203 const zcu = cg.pt.zcu;
6257 const zcu = pt.zcu;
6258 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6204 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
62596205
6260 const ty = cg.typeOf(ty_op.operand);6206 const ty = cg.typeOf(ty_op.operand);
...@@ -6304,8 +6250,7 @@ fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6304,8 +6250,7 @@ fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6304}6250}
63056251
6306fn airCtz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6252fn airCtz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6307 const pt = cg.pt;6253 const zcu = cg.pt.zcu;
6308 const zcu = pt.zcu;
6309 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6254 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
63106255
6311 const ty = cg.typeOf(ty_op.operand);6256 const ty = cg.typeOf(ty_op.operand);
...@@ -6406,8 +6351,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6406,8 +6351,7 @@ fn airTry(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6406}6351}
64076352
6408fn airTryPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6353fn airTryPtr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6409 const pt = cg.pt;6354 const zcu = cg.pt.zcu;
6410 const zcu = pt.zcu;
6411 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;6355 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
6412 const extra = cg.air.extraData(Air.TryPtr, ty_pl.payload);6356 const extra = cg.air.extraData(Air.TryPtr, ty_pl.payload);
6413 const err_union_ptr = try cg.resolveInst(extra.data.ptr);6357 const err_union_ptr = try cg.resolveInst(extra.data.ptr);
...@@ -6425,8 +6369,7 @@ fn lowerTry(...@@ -6425,8 +6369,7 @@ fn lowerTry(
6425 err_union_ty: Type,6369 err_union_ty: Type,
6426 operand_is_ptr: bool,6370 operand_is_ptr: bool,
6427) InnerError!WValue {6371) InnerError!WValue {
6428 const pt = cg.pt;6372 const zcu = cg.pt.zcu;
6429 const zcu = pt.zcu;
6430 if (operand_is_ptr) {6373 if (operand_is_ptr) {
6431 return cg.fail("TODO: lowerTry for pointers", .{});6374 return cg.fail("TODO: lowerTry for pointers", .{});
6432 }6375 }
...@@ -6475,8 +6418,7 @@ fn lowerTry(...@@ -6475,8 +6418,7 @@ fn lowerTry(
6475}6418}
64766419
6477fn airByteSwap(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6420fn airByteSwap(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6478 const pt = cg.pt;6421 const zcu = cg.pt.zcu;
6479 const zcu = pt.zcu;
6480 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6422 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
64816423
6482 const ty = cg.typeOfIndex(inst);6424 const ty = cg.typeOfIndex(inst);
...@@ -6558,8 +6500,7 @@ fn airDivTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6558,8 +6500,7 @@ fn airDivTrunc(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6558fn airDivFloor(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {6500fn airDivFloor(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6559 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6501 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
65606502
6561 const pt = cg.pt;6503 const zcu = cg.pt.zcu;
6562 const zcu = pt.zcu;
6563 const ty = cg.typeOfIndex(inst);6504 const ty = cg.typeOfIndex(inst);
6564 const lhs = try cg.resolveInst(bin_op.lhs);6505 const lhs = try cg.resolveInst(bin_op.lhs);
6565 const rhs = try cg.resolveInst(bin_op.rhs);6506 const rhs = try cg.resolveInst(bin_op.rhs);
...@@ -6819,8 +6760,7 @@ fn airSatBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6819,8 +6760,7 @@ fn airSatBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6819 assert(op == .add or op == .sub);6760 assert(op == .add or op == .sub);
6820 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6761 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
68216762
6822 const pt = cg.pt;6763 const zcu = cg.pt.zcu;
6823 const zcu = pt.zcu;
6824 const ty = cg.typeOfIndex(inst);6764 const ty = cg.typeOfIndex(inst);
6825 const lhs = try cg.resolveInst(bin_op.lhs);6765 const lhs = try cg.resolveInst(bin_op.lhs);
6826 const rhs = try cg.resolveInst(bin_op.rhs);6766 const rhs = try cg.resolveInst(bin_op.rhs);
...@@ -7041,8 +6981,7 @@ fn callIntrinsic(...@@ -7041,8 +6981,7 @@ fn callIntrinsic(
7041 args: []const WValue,6981 args: []const WValue,
7042) InnerError!WValue {6982) InnerError!WValue {
7043 assert(param_types.len == args.len);6983 assert(param_types.len == args.len);
7044 const pt = cg.pt;6984 const zcu = cg.pt.zcu;
7045 const zcu = pt.zcu;
70466985
7047 // Always pass over C-ABI6986 // Always pass over C-ABI
70486987
...@@ -7090,8 +7029,7 @@ fn airTagName(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7090,8 +7029,7 @@ fn airTagName(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7090}7029}
70917030
7092fn airErrorSetHasValue(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {7031fn airErrorSetHasValue(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7093 const pt = cg.pt;7032 const zcu = cg.pt.zcu;
7094 const zcu = pt.zcu;
7095 const ip = &zcu.intern_pool;7033 const ip = &zcu.intern_pool;
7096 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;7034 const ty_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
70977035
...@@ -7177,8 +7115,7 @@ inline fn useAtomicFeature(cg: *const CodeGen) bool {...@@ -7177,8 +7115,7 @@ inline fn useAtomicFeature(cg: *const CodeGen) bool {
7177}7115}
71787116
7179fn airCmpxchg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {7117fn airCmpxchg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7180 const pt = cg.pt;7118 const zcu = cg.pt.zcu;
7181 const zcu = pt.zcu;
7182 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;7119 const ty_pl = cg.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
7183 const extra = cg.air.extraData(Air.Cmpxchg, ty_pl.payload).data;7120 const extra = cg.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
71847121
...@@ -7251,13 +7188,13 @@ fn airCmpxchg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7251,13 +7188,13 @@ fn airCmpxchg(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7251}7188}
72527189
7253fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {7190fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7254 const pt = cg.pt;7191 const zcu = cg.pt.zcu;
7255 const atomic_load = cg.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load;7192 const atomic_load = cg.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load;
7256 const ptr = try cg.resolveInst(atomic_load.ptr);7193 const ptr = try cg.resolveInst(atomic_load.ptr);
7257 const ty = cg.typeOfIndex(inst);7194 const ty = cg.typeOfIndex(inst);
72587195
7259 if (cg.useAtomicFeature()) {7196 if (cg.useAtomicFeature()) {
7260 const tag: std.wasm.AtomicsOpcode = switch (ty.abiSize(pt.zcu)) {7197 const tag: std.wasm.AtomicsOpcode = switch (ty.abiSize(zcu)) {
7261 1 => .i32_atomic_load8_u,7198 1 => .i32_atomic_load8_u,
7262 2 => .i32_atomic_load16_u,7199 2 => .i32_atomic_load16_u,
7263 4 => .i32_atomic_load,7200 4 => .i32_atomic_load,
...@@ -7267,7 +7204,7 @@ fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7267,7 +7204,7 @@ fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7267 try cg.emitWValue(ptr);7204 try cg.emitWValue(ptr);
7268 try cg.addAtomicMemArg(tag, .{7205 try cg.addAtomicMemArg(tag, .{
7269 .offset = ptr.offset(),7206 .offset = ptr.offset(),
7270 .alignment = @intCast(ty.abiAlignment(pt.zcu).toByteUnits().?),7207 .alignment = @intCast(ty.abiAlignment(zcu).toByteUnits().?),
7271 });7208 });
7272 } else {7209 } else {
7273 _ = try cg.load(ptr, ty, 0);7210 _ = try cg.load(ptr, ty, 0);
...@@ -7277,8 +7214,7 @@ fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7277,8 +7214,7 @@ fn airAtomicLoad(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7277}7214}
72787215
7279fn airAtomicRmw(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {7216fn airAtomicRmw(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7280 const pt = cg.pt;7217 const zcu = cg.pt.zcu;
7281 const zcu = pt.zcu;
7282 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;7218 const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
7283 const extra = cg.air.extraData(Air.AtomicRmw, pl_op.payload).data;7219 const extra = cg.air.extraData(Air.AtomicRmw, pl_op.payload).data;
72847220
...@@ -7452,8 +7388,7 @@ fn airAtomicRmw(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7452,8 +7388,7 @@ fn airAtomicRmw(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7452}7388}
74537389
7454fn airAtomicStore(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {7390fn airAtomicStore(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7455 const pt = cg.pt;7391 const zcu = cg.pt.zcu;
7456 const zcu = pt.zcu;
7457 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;7392 const bin_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
74587393
7459 const ptr = try cg.resolveInst(bin_op.lhs);7394 const ptr = try cg.resolveInst(bin_op.lhs);
...@@ -7491,14 +7426,12 @@ fn airFrameAddress(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7491,14 +7426,12 @@ fn airFrameAddress(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
7491}7426}
74927427
7493fn typeOf(cg: *CodeGen, inst: Air.Inst.Ref) Type {7428fn typeOf(cg: *CodeGen, inst: Air.Inst.Ref) Type {
7494 const pt = cg.pt;7429 const zcu = cg.pt.zcu;
7495 const zcu = pt.zcu;
7496 return cg.air.typeOf(inst, &zcu.intern_pool);7430 return cg.air.typeOf(inst, &zcu.intern_pool);
7497}7431}
74987432
7499fn typeOfIndex(cg: *CodeGen, inst: Air.Inst.Index) Type {7433fn typeOfIndex(cg: *CodeGen, inst: Air.Inst.Index) Type {
7500 const pt = cg.pt;7434 const zcu = cg.pt.zcu;
7501 const zcu = pt.zcu;
7502 return cg.air.typeOfIndex(inst, &zcu.intern_pool);7435 return cg.air.typeOfIndex(inst, &zcu.intern_pool);
7503}7436}
75047437