aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-02 14:37:33 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:40:03 -0700
commit00f82f1c46126f1fc6655c6142ef16e8e5afbf4e (patch)
treeaa9f759bddb01a7469083363da65ef4717509a52 /src/arch/wasm/CodeGen.zig
parentc7e84ddb722df0403dd6ae8283820c02efc77e50 (diff)
downloadzig-00f82f1c46126f1fc6655c6142ef16e8e5afbf4e.tar.gz
zig-00f82f1c46126f1fc6655c6142ef16e8e5afbf4e.zip
stage2: add `interned` AIR tag
This required additionally passing the `InternPool` into some AIR methods. Also, implement `Type.isNoReturn` for interned types.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig240
1 files changed, 127 insertions, 113 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index b592ffcb2a..cd61eaf1fb 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -790,7 +790,7 @@ fn resolveInst(func: *CodeGen, ref: Air.Inst.Ref) InnerError!WValue {
const mod = func.bin_file.base.options.module.?;
const val = func.air.value(ref, mod).?;
- const ty = func.air.typeOf(ref);
+ const ty = func.typeOf(ref);
if (!ty.hasRuntimeBitsIgnoreComptime(mod) and !ty.isInt(mod) and !ty.isError(mod)) {
gop.value_ptr.* = WValue{ .none = {} };
return gop.value_ptr.*;
@@ -1260,7 +1260,7 @@ fn genFunc(func: *CodeGen) InnerError!void {
// we emit an unreachable instruction to tell the stack validator that part will never be reached.
if (func_type.returns.len != 0 and func.air.instructions.len > 0) {
const inst = @intCast(u32, func.air.instructions.len - 1);
- const last_inst_ty = func.air.typeOfIndex(inst);
+ const last_inst_ty = func.typeOfIndex(inst);
if (!last_inst_ty.hasRuntimeBitsIgnoreComptime(mod) or last_inst_ty.isNoReturn()) {
try func.addTag(.@"unreachable");
}
@@ -1541,7 +1541,7 @@ fn allocStack(func: *CodeGen, ty: Type) !WValue {
/// if it is set, to ensure the stack alignment will be set correctly.
fn allocStackPtr(func: *CodeGen, inst: Air.Inst.Index) !WValue {
const mod = func.bin_file.base.options.module.?;
- const ptr_ty = func.air.typeOfIndex(inst);
+ const ptr_ty = func.typeOfIndex(inst);
const pointee_ty = ptr_ty.childType();
if (func.initial_stack_value == .none) {
@@ -1834,6 +1834,7 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
return switch (air_tags[inst]) {
.constant => unreachable,
.const_ty => unreachable,
+ .interned => unreachable,
.add => func.airBinOp(inst, .add),
.add_sat => func.airSatBinOp(inst, .add),
@@ -2073,8 +2074,11 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
+ const ip = &mod.intern_pool;
+
for (body) |inst| {
- if (func.liveness.isUnused(inst) and !func.air.mustLower(inst)) {
+ if (func.liveness.isUnused(inst) and !func.air.mustLower(inst, ip.*)) {
continue;
}
const old_bookkeeping_value = func.air_bookkeeping;
@@ -2134,8 +2138,8 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
- const child_type = func.air.typeOfIndex(inst).childType();
const mod = func.bin_file.base.options.module.?;
+ const child_type = func.typeOfIndex(inst).childType();
var result = result: {
if (!child_type.isFnOrHasRuntimeBitsIgnoreComptime(mod)) {
@@ -2157,7 +2161,7 @@ fn airRetLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const ret_ty = func.air.typeOf(un_op).childType();
+ const ret_ty = func.typeOf(un_op).childType();
const fn_info = func.decl.ty.fnInfo();
if (!ret_ty.hasRuntimeBitsIgnoreComptime(mod)) {
@@ -2179,7 +2183,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
const extra = func.air.extraData(Air.Call, pl_op.payload);
const args = @ptrCast([]const Air.Inst.Ref, func.air.extra[extra.end..][0..extra.data.args_len]);
- const ty = func.air.typeOf(pl_op.operand);
+ const ty = func.typeOf(pl_op.operand);
const mod = func.bin_file.base.options.module.?;
const fn_ty = switch (ty.zigTypeTag(mod)) {
@@ -2228,7 +2232,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
for (args) |arg| {
const arg_val = try func.resolveInst(arg);
- const arg_ty = func.air.typeOf(arg);
+ const arg_ty = func.typeOf(arg);
if (!arg_ty.hasRuntimeBitsIgnoreComptime(mod)) continue;
try func.lowerArg(fn_ty.fnInfo().cc, arg_ty, arg_val);
@@ -2296,7 +2300,7 @@ fn airStore(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const ptr_info = ptr_ty.ptrInfo().data;
const ty = ptr_ty.childType();
@@ -2449,7 +2453,7 @@ fn airLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
const ty = func.air.getRefType(ty_op.ty);
- const ptr_ty = func.air.typeOf(ty_op.operand);
+ const ptr_ty = func.typeOf(ty_op.operand);
const ptr_info = ptr_ty.ptrInfo().data;
if (!ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{ty_op.operand});
@@ -2522,11 +2526,11 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu
}
fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const arg_index = func.arg_index;
const arg = func.args[arg_index];
const cc = func.decl.ty.fnInfo().cc;
- const arg_ty = func.air.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
+ const arg_ty = func.typeOfIndex(inst);
if (cc == .C) {
const arg_classes = abi.classifyType(arg_ty, mod);
for (arg_classes) |class| {
@@ -2572,8 +2576,8 @@ fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
- const lhs_ty = func.air.typeOf(bin_op.lhs);
- const rhs_ty = func.air.typeOf(bin_op.rhs);
+ const lhs_ty = func.typeOf(bin_op.lhs);
+ const rhs_ty = func.typeOf(bin_op.rhs);
// For certain operations, such as shifting, the types are different.
// When converting this to a WebAssembly type, they *must* match to perform
@@ -2770,7 +2774,7 @@ const FloatOp = enum {
fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError!void {
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const ty = func.air.typeOf(un_op);
+ const ty = func.typeOf(un_op);
const result = try (try func.floatOp(op, ty, &.{operand})).toLocal(func, ty);
func.finishAir(inst, result, &.{un_op});
@@ -2847,8 +2851,8 @@ fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
- const lhs_ty = func.air.typeOf(bin_op.lhs);
- const rhs_ty = func.air.typeOf(bin_op.rhs);
+ const lhs_ty = func.typeOf(bin_op.lhs);
+ const rhs_ty = func.typeOf(bin_op.rhs);
if (lhs_ty.zigTypeTag(mod) == .Vector or rhs_ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: Implement wrapping arithmetic for vectors", .{});
@@ -3387,7 +3391,7 @@ fn airCmp(func: *CodeGen, inst: Air.Inst.Index, op: std.math.CompareOperator) In
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
- const operand_ty = func.air.typeOf(bin_op.lhs);
+ const operand_ty = func.typeOf(bin_op.lhs);
const result = try (try func.cmp(lhs, rhs, operand_ty, op)).toLocal(func, Type.u32); // comparison result is always 32 bits
func.finishAir(inst, result, &.{ bin_op.lhs, bin_op.rhs });
}
@@ -3488,7 +3492,7 @@ fn airBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const block = func.blocks.get(br.block_inst).?;
// if operand has codegen bits we should break with a value
- if (func.air.typeOf(br.operand).hasRuntimeBitsIgnoreComptime(mod)) {
+ if (func.typeOf(br.operand).hasRuntimeBitsIgnoreComptime(mod)) {
const operand = try func.resolveInst(br.operand);
try func.lowerToStack(operand);
@@ -3509,7 +3513,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const operand_ty = func.air.typeOf(ty_op.operand);
+ const operand_ty = func.typeOf(ty_op.operand);
const mod = func.bin_file.base.options.module.?;
const result = result: {
@@ -3575,8 +3579,8 @@ fn airBitcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const result = result: {
const operand = try func.resolveInst(ty_op.operand);
- const wanted_ty = func.air.typeOfIndex(inst);
- const given_ty = func.air.typeOf(ty_op.operand);
+ const wanted_ty = func.typeOfIndex(inst);
+ const given_ty = func.typeOf(ty_op.operand);
if (given_ty.isAnyFloat() or wanted_ty.isAnyFloat()) {
const bitcast_result = try func.bitcast(wanted_ty, given_ty, operand);
break :result try bitcast_result.toLocal(func, wanted_ty);
@@ -3609,7 +3613,7 @@ fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const extra = func.air.extraData(Air.StructField, ty_pl.payload);
const struct_ptr = try func.resolveInst(extra.data.struct_operand);
- const struct_ty = func.air.typeOf(extra.data.struct_operand).childType();
+ const struct_ty = func.typeOf(extra.data.struct_operand).childType();
const result = try func.structFieldPtr(inst, extra.data.struct_operand, struct_ptr, struct_ty, extra.data.field_index);
func.finishAir(inst, result, &.{extra.data.struct_operand});
}
@@ -3617,7 +3621,7 @@ fn airStructFieldPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airStructFieldPtrIndex(func: *CodeGen, inst: Air.Inst.Index, index: u32) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const struct_ptr = try func.resolveInst(ty_op.operand);
- const struct_ty = func.air.typeOf(ty_op.operand).childType();
+ const struct_ty = func.typeOf(ty_op.operand).childType();
const result = try func.structFieldPtr(inst, ty_op.operand, struct_ptr, struct_ty, index);
func.finishAir(inst, result, &.{ty_op.operand});
@@ -3632,7 +3636,7 @@ fn structFieldPtr(
index: u32,
) InnerError!WValue {
const mod = func.bin_file.base.options.module.?;
- const result_ty = func.air.typeOfIndex(inst);
+ const result_ty = func.typeOfIndex(inst);
const offset = switch (struct_ty.containerLayout()) {
.Packed => switch (struct_ty.zigTypeTag(mod)) {
.Struct => offset: {
@@ -3663,7 +3667,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
const struct_field = func.air.extraData(Air.StructField, ty_pl.payload).data;
- const struct_ty = func.air.typeOf(struct_field.struct_operand);
+ const struct_ty = func.typeOf(struct_field.struct_operand);
const operand = try func.resolveInst(struct_field.struct_operand);
const field_index = struct_field.field_index;
const field_ty = struct_ty.structFieldType(field_index);
@@ -3762,7 +3766,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const blocktype = wasm.block_empty;
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
const target = try func.resolveInst(pl_op.operand);
- const target_ty = func.air.typeOf(pl_op.operand);
+ const target_ty = func.typeOf(pl_op.operand);
const switch_br = func.air.extraData(Air.SwitchBr, pl_op.payload);
const liveness = try func.liveness.getSwitchBr(func.gpa, inst, switch_br.data.cases_len + 1);
defer func.gpa.free(liveness.deaths);
@@ -3940,7 +3944,7 @@ fn airIsErr(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode) InnerErro
const mod = func.bin_file.base.options.module.?;
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const err_union_ty = func.air.typeOf(un_op);
+ const err_union_ty = func.typeOf(un_op);
const pl_ty = err_union_ty.errorUnionPayload();
const result = result: {
@@ -3976,7 +3980,7 @@ fn airUnwrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: boo
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const op_ty = func.air.typeOf(ty_op.operand);
+ const op_ty = func.typeOf(ty_op.operand);
const err_ty = if (op_is_ptr) op_ty.childType() else op_ty;
const payload_ty = err_ty.errorUnionPayload();
@@ -4004,7 +4008,7 @@ fn airUnwrapErrUnionError(func: *CodeGen, inst: Air.Inst.Index, op_is_ptr: bool)
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const op_ty = func.air.typeOf(ty_op.operand);
+ const op_ty = func.typeOf(ty_op.operand);
const err_ty = if (op_is_ptr) op_ty.childType() else op_ty;
const payload_ty = err_ty.errorUnionPayload();
@@ -4028,9 +4032,9 @@ fn airWrapErrUnionPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const err_ty = func.air.typeOfIndex(inst);
+ const err_ty = func.typeOfIndex(inst);
- const pl_ty = func.air.typeOf(ty_op.operand);
+ const pl_ty = func.typeOf(ty_op.operand);
const result = result: {
if (!pl_ty.hasRuntimeBitsIgnoreComptime(mod)) {
break :result func.reuseOperand(ty_op.operand, operand);
@@ -4082,7 +4086,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty = func.air.getRefType(ty_op.ty);
const operand = try func.resolveInst(ty_op.operand);
- const operand_ty = func.air.typeOf(ty_op.operand);
+ const operand_ty = func.typeOf(ty_op.operand);
const mod = func.bin_file.base.options.module.?;
if (ty.zigTypeTag(mod) == .Vector or operand_ty.zigTypeTag(mod) == .Vector) {
return func.fail("todo Wasm intcast for vectors", .{});
@@ -4155,7 +4159,7 @@ fn airIsNull(func: *CodeGen, inst: Air.Inst.Index, opcode: wasm.Opcode, op_kind:
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const op_ty = func.air.typeOf(un_op);
+ const op_ty = func.typeOf(un_op);
const optional_ty = if (op_kind == .ptr) op_ty.childType() else op_ty;
const is_null = try func.isNull(operand, optional_ty, opcode);
const result = try is_null.toLocal(func, optional_ty);
@@ -4196,8 +4200,8 @@ fn isNull(func: *CodeGen, operand: WValue, optional_ty: Type, opcode: wasm.Opcod
fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const opt_ty = func.air.typeOf(ty_op.operand);
- const payload_ty = func.air.typeOfIndex(inst);
+ const opt_ty = func.typeOf(ty_op.operand);
+ const payload_ty = func.typeOfIndex(inst);
if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
return func.finishAir(inst, .none, &.{ty_op.operand});
}
@@ -4219,7 +4223,7 @@ fn airOptionalPayload(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airOptionalPayloadPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const opt_ty = func.air.typeOf(ty_op.operand).childType();
+ const opt_ty = func.typeOf(ty_op.operand).childType();
const mod = func.bin_file.base.options.module.?;
const result = result: {
@@ -4238,7 +4242,7 @@ fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi
const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const opt_ty = func.air.typeOf(ty_op.operand).childType();
+ const opt_ty = func.typeOf(ty_op.operand).childType();
var buf: Type.Payload.ElemType = undefined;
const payload_ty = opt_ty.optionalChild(&buf);
if (!payload_ty.hasRuntimeBitsIgnoreComptime(mod)) {
@@ -4263,7 +4267,7 @@ fn airOptionalPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi
fn airWrapOptional(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const payload_ty = func.air.typeOf(ty_op.operand);
+ const payload_ty = func.typeOf(ty_op.operand);
const mod = func.bin_file.base.options.module.?;
const result = result: {
@@ -4276,7 +4280,7 @@ fn airWrapOptional(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
const operand = try func.resolveInst(ty_op.operand);
- const op_ty = func.air.typeOfIndex(inst);
+ const op_ty = func.typeOfIndex(inst);
if (op_ty.optionalReprIsPayload(mod)) {
break :result func.reuseOperand(ty_op.operand, operand);
}
@@ -4304,7 +4308,7 @@ fn airSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
- const slice_ty = func.air.typeOfIndex(inst);
+ const slice_ty = func.typeOfIndex(inst);
const slice = try func.allocStack(slice_ty);
try func.store(slice, lhs, Type.usize, 0);
@@ -4323,7 +4327,7 @@ fn airSliceLen(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airSliceElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const slice_ty = func.air.typeOf(bin_op.lhs);
+ const slice_ty = func.typeOf(bin_op.lhs);
const slice = try func.resolveInst(bin_op.lhs);
const index = try func.resolveInst(bin_op.rhs);
const elem_ty = slice_ty.childType();
@@ -4395,7 +4399,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const operand = try func.resolveInst(ty_op.operand);
const wanted_ty = func.air.getRefType(ty_op.ty);
- const op_ty = func.air.typeOf(ty_op.operand);
+ const op_ty = func.typeOf(ty_op.operand);
const result = try func.trunc(operand, wanted_ty, op_ty);
func.finishAir(inst, try result.toLocal(func, wanted_ty), &.{ty_op.operand});
@@ -4432,7 +4436,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const array_ty = func.air.typeOf(ty_op.operand).childType();
+ const array_ty = func.typeOf(ty_op.operand).childType();
const slice_ty = func.air.getRefType(ty_op.ty);
// create a slice on the stack
@@ -4453,7 +4457,7 @@ fn airArrayToSlice(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airPtrToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const ptr_ty = func.air.typeOf(un_op);
+ const ptr_ty = func.typeOf(un_op);
const result = if (ptr_ty.isSlice())
try func.slicePtr(operand)
else switch (operand) {
@@ -4467,7 +4471,7 @@ fn airPtrToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airPtrElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const ptr = try func.resolveInst(bin_op.lhs);
const index = try func.resolveInst(bin_op.rhs);
const elem_ty = ptr_ty.childType();
@@ -4505,7 +4509,7 @@ fn airPtrElemPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
const bin_op = func.air.extraData(Air.Bin, ty_pl.payload).data;
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const elem_ty = func.air.getRefType(ty_pl.ty).childType();
const mod = func.bin_file.base.options.module.?;
const elem_size = elem_ty.abiSize(mod);
@@ -4538,7 +4542,7 @@ fn airPtrBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const ptr = try func.resolveInst(bin_op.lhs);
const offset = try func.resolveInst(bin_op.rhs);
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const pointee_ty = switch (ptr_ty.ptrSize()) {
.One => ptr_ty.childType().childType(), // ptr to array, so get array element type
else => ptr_ty.childType(),
@@ -4568,7 +4572,7 @@ fn airMemset(func: *CodeGen, inst: Air.Inst.Index, safety: bool) InnerError!void
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const ptr = try func.resolveInst(bin_op.lhs);
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const value = try func.resolveInst(bin_op.rhs);
const len = switch (ptr_ty.ptrSize()) {
.Slice => try func.sliceLen(ptr),
@@ -4683,7 +4687,7 @@ fn memset(func: *CodeGen, elem_ty: Type, ptr: WValue, len: WValue, value: WValue
fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const array_ty = func.air.typeOf(bin_op.lhs);
+ const array_ty = func.typeOf(bin_op.lhs);
const array = try func.resolveInst(bin_op.lhs);
const index = try func.resolveInst(bin_op.rhs);
const elem_ty = array_ty.childType();
@@ -4750,12 +4754,12 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const dest_ty = func.air.typeOfIndex(inst);
- const op_ty = func.air.typeOf(ty_op.operand);
- const mod = func.bin_file.base.options.module.?;
+ const dest_ty = func.typeOfIndex(inst);
+ const op_ty = func.typeOf(ty_op.operand);
if (op_ty.abiSize(mod) > 8) {
return func.fail("TODO: floatToInt for integers/floats with bitsize larger than 64 bits", .{});
@@ -4775,12 +4779,12 @@ fn airFloatToInt(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airIntToFloat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const dest_ty = func.air.typeOfIndex(inst);
- const op_ty = func.air.typeOf(ty_op.operand);
- const mod = func.bin_file.base.options.module.?;
+ const dest_ty = func.typeOfIndex(inst);
+ const op_ty = func.typeOf(ty_op.operand);
if (op_ty.abiSize(mod) > 8) {
return func.fail("TODO: intToFloat for integers/floats with bitsize larger than 64 bits", .{});
@@ -4804,7 +4808,7 @@ fn airSplat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const elem_ty = ty.childType();
if (determineSimdStoreStrategy(ty, mod) == .direct) blk: {
@@ -4881,7 +4885,7 @@ fn airSelect(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
- const inst_ty = func.air.typeOfIndex(inst);
+ const inst_ty = func.typeOfIndex(inst);
const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
const extra = func.air.extraData(Air.Shuffle, ty_pl.payload).data;
@@ -4894,7 +4898,7 @@ fn airShuffle(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const elem_size = child_ty.abiSize(mod);
// TODO: One of them could be by ref; handle in loop
- if (isByRef(func.air.typeOf(extra.a), mod) or isByRef(inst_ty, mod)) {
+ if (isByRef(func.typeOf(extra.a), mod) or isByRef(inst_ty, mod)) {
const result = try func.allocStack(inst_ty);
for (0..mask_len) |index| {
@@ -4951,11 +4955,11 @@ fn airReduce(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
- const result_ty = func.air.typeOfIndex(inst);
+ const result_ty = func.typeOfIndex(inst);
const len = @intCast(usize, result_ty.arrayLen());
const elements = @ptrCast([]const Air.Inst.Ref, func.air.extra[ty_pl.payload..][0..len]);
- const mod = func.bin_file.base.options.module.?;
const result: WValue = result_value: {
switch (result_ty.zigTypeTag(mod)) {
@@ -5085,7 +5089,7 @@ fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const extra = func.air.extraData(Air.UnionInit, ty_pl.payload).data;
const result = result: {
- const union_ty = func.air.typeOfIndex(inst);
+ const union_ty = func.typeOfIndex(inst);
const layout = union_ty.unionGetLayout(mod);
const union_obj = union_ty.cast(Type.Payload.Union).?.data;
const field = union_obj.fields.values()[extra.field_index];
@@ -5164,7 +5168,7 @@ fn airPrefetch(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airWasmMemorySize(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
- const result = try func.allocLocal(func.air.typeOfIndex(inst));
+ const result = try func.allocLocal(func.typeOfIndex(inst));
try func.addLabel(.memory_size, pl_op.payload);
try func.addLabel(.local_set, result.local.value);
func.finishAir(inst, result, &.{pl_op.operand});
@@ -5174,7 +5178,7 @@ fn airWasmMemoryGrow(func: *CodeGen, inst: Air.Inst.Index) !void {
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
const operand = try func.resolveInst(pl_op.operand);
- const result = try func.allocLocal(func.air.typeOfIndex(inst));
+ const result = try func.allocLocal(func.typeOfIndex(inst));
try func.emitWValue(operand);
try func.addLabel(.memory_grow, pl_op.payload);
try func.addLabel(.local_set, result.local.value);
@@ -5263,8 +5267,8 @@ fn cmpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, operand_ty: Type, op: std
fn airSetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const un_ty = func.air.typeOf(bin_op.lhs).childType();
- const tag_ty = func.air.typeOf(bin_op.rhs);
+ const un_ty = func.typeOf(bin_op.lhs).childType();
+ const tag_ty = func.typeOf(bin_op.rhs);
const layout = un_ty.unionGetLayout(mod);
if (layout.tag_size == 0) return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
@@ -5288,8 +5292,8 @@ fn airGetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const un_ty = func.air.typeOf(ty_op.operand);
- const tag_ty = func.air.typeOfIndex(inst);
+ const un_ty = func.typeOf(ty_op.operand);
+ const tag_ty = func.typeOfIndex(inst);
const layout = un_ty.unionGetLayout(mod);
if (layout.tag_size == 0) return func.finishAir(inst, .none, &.{ty_op.operand});
@@ -5307,9 +5311,9 @@ fn airGetUnionTag(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
fn airFpext(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const dest_ty = func.air.typeOfIndex(inst);
+ const dest_ty = func.typeOfIndex(inst);
const operand = try func.resolveInst(ty_op.operand);
- const extended = try func.fpext(operand, func.air.typeOf(ty_op.operand), dest_ty);
+ const extended = try func.fpext(operand, func.typeOf(ty_op.operand), dest_ty);
const result = try extended.toLocal(func, dest_ty);
func.finishAir(inst, result, &.{ty_op.operand});
}
@@ -5352,9 +5356,9 @@ fn fpext(func: *CodeGen, operand: WValue, given: Type, wanted: Type) InnerError!
fn airFptrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const dest_ty = func.air.typeOfIndex(inst);
+ const dest_ty = func.typeOfIndex(inst);
const operand = try func.resolveInst(ty_op.operand);
- const truncated = try func.fptrunc(operand, func.air.typeOf(ty_op.operand), dest_ty);
+ const truncated = try func.fptrunc(operand, func.typeOf(ty_op.operand), dest_ty);
const result = try truncated.toLocal(func, dest_ty);
func.finishAir(inst, result, &.{ty_op.operand});
}
@@ -5393,7 +5397,7 @@ fn airErrUnionPayloadPtrSet(func: *CodeGen, inst: Air.Inst.Index) InnerError!voi
const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const err_set_ty = func.air.typeOf(ty_op.operand).childType();
+ const err_set_ty = func.typeOf(ty_op.operand).childType();
const payload_ty = err_set_ty.errorUnionPayload();
const operand = try func.resolveInst(ty_op.operand);
@@ -5448,10 +5452,10 @@ fn airMemcpy(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const dst = try func.resolveInst(bin_op.lhs);
- const dst_ty = func.air.typeOf(bin_op.lhs);
+ const dst_ty = func.typeOf(bin_op.lhs);
const ptr_elem_ty = dst_ty.childType();
const src = try func.resolveInst(bin_op.rhs);
- const src_ty = func.air.typeOf(bin_op.rhs);
+ const src_ty = func.typeOf(bin_op.rhs);
const len = switch (dst_ty.ptrSize()) {
.Slice => blk: {
const slice_len = try func.sliceLen(dst);
@@ -5485,12 +5489,12 @@ fn airRetAddr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
const operand = try func.resolveInst(ty_op.operand);
- const op_ty = func.air.typeOf(ty_op.operand);
- const result_ty = func.air.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
+ const op_ty = func.typeOf(ty_op.operand);
+ const result_ty = func.typeOfIndex(inst);
if (op_ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: Implement @popCount for vectors", .{});
@@ -5585,7 +5589,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
const lhs_op = try func.resolveInst(extra.lhs);
const rhs_op = try func.resolveInst(extra.rhs);
- const lhs_ty = func.air.typeOf(extra.lhs);
+ const lhs_ty = func.typeOf(extra.lhs);
const mod = func.bin_file.base.options.module.?;
if (lhs_ty.zigTypeTag(mod) == .Vector) {
@@ -5599,7 +5603,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
};
if (wasm_bits == 128) {
- const result = try func.addSubWithOverflowBigInt(lhs_op, rhs_op, lhs_ty, func.air.typeOfIndex(inst), op);
+ const result = try func.addSubWithOverflowBigInt(lhs_op, rhs_op, lhs_ty, func.typeOfIndex(inst), op);
return func.finishAir(inst, result, &.{ extra.lhs, extra.rhs });
}
@@ -5649,7 +5653,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
var overflow_local = try overflow_bit.toLocal(func, Type.u32);
defer overflow_local.free(func);
- const result_ptr = try func.allocStack(func.air.typeOfIndex(inst));
+ const result_ptr = try func.allocStack(func.typeOfIndex(inst));
try func.store(result_ptr, result, lhs_ty, 0);
const offset = @intCast(u32, lhs_ty.abiSize(mod));
try func.store(result_ptr, overflow_local, Type.initTag(.u1), offset);
@@ -5729,8 +5733,8 @@ fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const lhs = try func.resolveInst(extra.lhs);
const rhs = try func.resolveInst(extra.rhs);
- const lhs_ty = func.air.typeOf(extra.lhs);
- const rhs_ty = func.air.typeOf(extra.rhs);
+ const lhs_ty = func.typeOf(extra.lhs);
+ const rhs_ty = func.typeOf(extra.rhs);
if (lhs_ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
@@ -5771,7 +5775,7 @@ fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
var overflow_local = try overflow_bit.toLocal(func, Type.initTag(.u1));
defer overflow_local.free(func);
- const result_ptr = try func.allocStack(func.air.typeOfIndex(inst));
+ const result_ptr = try func.allocStack(func.typeOfIndex(inst));
try func.store(result_ptr, result, lhs_ty, 0);
const offset = @intCast(u32, lhs_ty.abiSize(mod));
try func.store(result_ptr, overflow_local, Type.initTag(.u1), offset);
@@ -5785,7 +5789,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const lhs = try func.resolveInst(extra.lhs);
const rhs = try func.resolveInst(extra.rhs);
- const lhs_ty = func.air.typeOf(extra.lhs);
+ const lhs_ty = func.typeOf(extra.lhs);
const mod = func.bin_file.base.options.module.?;
if (lhs_ty.zigTypeTag(mod) == .Vector) {
@@ -5946,7 +5950,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
var bin_op_local = try bin_op.toLocal(func, lhs_ty);
defer bin_op_local.free(func);
- const result_ptr = try func.allocStack(func.air.typeOfIndex(inst));
+ const result_ptr = try func.allocStack(func.typeOfIndex(inst));
try func.store(result_ptr, bin_op_local, lhs_ty, 0);
const offset = @intCast(u32, lhs_ty.abiSize(mod));
try func.store(result_ptr, overflow_bit, Type.initTag(.u1), offset);
@@ -5955,10 +5959,10 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: enum { max, min }) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const ty = func.air.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
+ const ty = func.typeOfIndex(inst);
if (ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: `@maximum` and `@minimum` for vectors", .{});
}
@@ -5986,11 +5990,11 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: enum { max, min }) InnerE
}
fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;
- const ty = func.air.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
+ const ty = func.typeOfIndex(inst);
if (ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: `@mulAdd` for vectors", .{});
}
@@ -6020,11 +6024,11 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const ty = func.air.typeOf(ty_op.operand);
- const result_ty = func.air.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
+ const ty = func.typeOf(ty_op.operand);
+ const result_ty = func.typeOfIndex(inst);
if (ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: `@clz` for vectors", .{});
}
@@ -6073,12 +6077,12 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
}
fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const ty = func.air.typeOf(ty_op.operand);
- const result_ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOf(ty_op.operand);
+ const result_ty = func.typeOfIndex(inst);
- const mod = func.bin_file.base.options.module.?;
if (ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: `@ctz` for vectors", .{});
}
@@ -6141,7 +6145,7 @@ fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void {
if (func.debug_output != .dwarf) return func.finishAir(inst, .none, &.{});
const pl_op = func.air.instructions.items(.data)[inst].pl_op;
- const ty = func.air.typeOf(pl_op.operand);
+ const ty = func.typeOf(pl_op.operand);
const operand = try func.resolveInst(pl_op.operand);
log.debug("airDbgVar: %{d}: {}, {}", .{ inst, ty.fmtDebug(), operand });
@@ -6179,7 +6183,7 @@ fn airTry(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const err_union = try func.resolveInst(pl_op.operand);
const extra = func.air.extraData(Air.Try, pl_op.payload);
const body = func.air.extra[extra.end..][0..extra.data.body_len];
- const err_union_ty = func.air.typeOf(pl_op.operand);
+ const err_union_ty = func.typeOf(pl_op.operand);
const result = try lowerTry(func, inst, err_union, body, err_union_ty, false);
func.finishAir(inst, result, &.{pl_op.operand});
}
@@ -6189,7 +6193,7 @@ fn airTryPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const extra = func.air.extraData(Air.TryPtr, ty_pl.payload);
const err_union_ptr = try func.resolveInst(extra.data.ptr);
const body = func.air.extra[extra.end..][0..extra.data.body_len];
- const err_union_ty = func.air.typeOf(extra.data.ptr).childType();
+ const err_union_ty = func.typeOf(extra.data.ptr).childType();
const result = try lowerTry(func, inst, err_union_ptr, body, err_union_ty, true);
func.finishAir(inst, result, &.{extra.data.ptr});
}
@@ -6251,11 +6255,11 @@ fn lowerTry(
}
fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
+ const mod = func.bin_file.base.options.module.?;
const ty_op = func.air.instructions.items(.data)[inst].ty_op;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const operand = try func.resolveInst(ty_op.operand);
- const mod = func.bin_file.base.options.module.?;
if (ty.zigTypeTag(mod) == .Vector) {
return func.fail("TODO: @byteSwap for vectors", .{});
@@ -6325,7 +6329,7 @@ fn airDiv(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
@@ -6340,7 +6344,7 @@ fn airDivTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
@@ -6361,7 +6365,7 @@ fn airDivFloor(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const mod = func.bin_file.base.options.module.?;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
@@ -6512,7 +6516,7 @@ fn airSatBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const mod = func.bin_file.base.options.module.?;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const lhs = try func.resolveInst(bin_op.lhs);
const rhs = try func.resolveInst(bin_op.rhs);
@@ -6626,7 +6630,7 @@ fn airShlSat(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const bin_op = func.air.instructions.items(.data)[inst].bin_op;
const mod = func.bin_file.base.options.module.?;
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const int_info = ty.intInfo(mod);
const is_signed = int_info.signedness == .signed;
if (int_info.bits > 64) {
@@ -6785,11 +6789,11 @@ fn callIntrinsic(
fn airTagName(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const un_op = func.air.instructions.items(.data)[inst].un_op;
const operand = try func.resolveInst(un_op);
- const enum_ty = func.air.typeOf(un_op);
+ const enum_ty = func.typeOf(un_op);
const func_sym_index = try func.getTagNameFunction(enum_ty);
- const result_ptr = try func.allocStack(func.air.typeOfIndex(inst));
+ const result_ptr = try func.allocStack(func.typeOfIndex(inst));
try func.lowerToStack(result_ptr);
try func.emitWValue(operand);
try func.addLabel(.call, func_sym_index);
@@ -7061,9 +7065,9 @@ fn airCmpxchg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ty_pl = func.air.instructions.items(.data)[inst].ty_pl;
const extra = func.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
- const ptr_ty = func.air.typeOf(extra.ptr);
+ const ptr_ty = func.typeOf(extra.ptr);
const ty = ptr_ty.childType();
- const result_ty = func.air.typeOfIndex(inst);
+ const result_ty = func.typeOfIndex(inst);
const ptr_operand = try func.resolveInst(extra.ptr);
const expected_val = try func.resolveInst(extra.expected_value);
@@ -7133,7 +7137,7 @@ fn airAtomicLoad(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const mod = func.bin_file.base.options.module.?;
const atomic_load = func.air.instructions.items(.data)[inst].atomic_load;
const ptr = try func.resolveInst(atomic_load.ptr);
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
if (func.useAtomicFeature()) {
const tag: wasm.AtomicsOpcode = switch (ty.abiSize(mod)) {
@@ -7163,7 +7167,7 @@ fn airAtomicRmw(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ptr = try func.resolveInst(pl_op.operand);
const operand = try func.resolveInst(extra.operand);
- const ty = func.air.typeOfIndex(inst);
+ const ty = func.typeOfIndex(inst);
const op: std.builtin.AtomicRmwOp = extra.op();
if (func.useAtomicFeature()) {
@@ -7348,7 +7352,7 @@ fn airAtomicStore(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const ptr = try func.resolveInst(bin_op.lhs);
const operand = try func.resolveInst(bin_op.rhs);
- const ptr_ty = func.air.typeOf(bin_op.lhs);
+ const ptr_ty = func.typeOf(bin_op.lhs);
const ty = ptr_ty.childType();
if (func.useAtomicFeature()) {
@@ -7380,3 +7384,13 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
const result = try WValue.toLocal(.stack, func, Type.usize);
return func.finishAir(inst, result, &.{});
}
+
+fn typeOf(func: *CodeGen, inst: Air.Inst.Ref) Type {
+ const mod = func.bin_file.base.options.module.?;
+ return func.air.typeOf(inst, mod.intern_pool);
+}
+
+fn typeOfIndex(func: *CodeGen, inst: Air.Inst.Index) Type {
+ const mod = func.bin_file.base.options.module.?;
+ return func.air.typeOfIndex(inst, mod.intern_pool);
+}