authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-07 10:43:57+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-07 10:45:45+03:00
log252388eb28fde40f085e14cd341efdc701093fe1
treec14f6b026b1b193b9e1034e3c705e3b9c94ab7cd
parentc9006d9479c619d9ed555164831e11a04d88d382

AstGen: move error_to_int, int_to_error and select to extended


4 files changed, 58 insertions(+), 53 deletions(-)

src/AstGen.zig+18-6
...@@ -2332,8 +2332,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner...@@ -2332,8 +2332,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
2332 .error_union_type,2332 .error_union_type,
2333 .bit_not,2333 .bit_not,
2334 .error_value,2334 .error_value,
2335 .error_to_int,
2336 .int_to_error,
2337 .slice_start,2335 .slice_start,
2338 .slice_end,2336 .slice_end,
2339 .slice_sentinel,2337 .slice_sentinel,
...@@ -2420,7 +2418,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner...@@ -2420,7 +2418,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
2420 .splat,2418 .splat,
2421 .reduce,2419 .reduce,
2422 .shuffle,2420 .shuffle,
2423 .select,
2424 .atomic_load,2421 .atomic_load,
2425 .atomic_rmw,2422 .atomic_rmw,
2426 .mul_add,2423 .mul_add,
...@@ -7355,8 +7352,6 @@ fn builtinCall(...@@ -7355,8 +7352,6 @@ fn builtinCall(
7355 .align_of => return simpleUnOpType(gz, scope, rl, node, params[0], .align_of),7352 .align_of => return simpleUnOpType(gz, scope, rl, node, params[0], .align_of),
73567353
7357 .ptr_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .ptr_to_int),7354 .ptr_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .ptr_to_int),
7358 .error_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .error_to_int),
7359 .int_to_error => return simpleUnOp(gz, scope, rl, node, .{ .coerced_ty = .u16_type }, params[0], .int_to_error),
7360 .compile_error => return simpleUnOp(gz, scope, rl, node, .{ .ty = .const_slice_u8_type }, params[0], .compile_error),7355 .compile_error => return simpleUnOp(gz, scope, rl, node, .{ .ty = .const_slice_u8_type }, params[0], .compile_error),
7361 .set_eval_branch_quota => return simpleUnOp(gz, scope, rl, node, .{ .coerced_ty = .u32_type }, params[0], .set_eval_branch_quota),7356 .set_eval_branch_quota => return simpleUnOp(gz, scope, rl, node, .{ .coerced_ty = .u32_type }, params[0], .set_eval_branch_quota),
7362 .enum_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .enum_to_int),7357 .enum_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .enum_to_int),
...@@ -7396,6 +7391,22 @@ fn builtinCall(...@@ -7396,6 +7391,22 @@ fn builtinCall(
7396 .truncate => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate),7391 .truncate => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate),
7397 // zig fmt: on7392 // zig fmt: on
73987393
7394 .error_to_int => {
7395 const operand = try expr(gz, scope, .none, params[0]);
7396 const result = try gz.addExtendedPayload(.error_to_int, Zir.Inst.UnNode{
7397 .node = gz.nodeIndexToRelative(node),
7398 .operand = operand,
7399 });
7400 return rvalue(gz, rl, result, node);
7401 },
7402 .int_to_error => {
7403 const operand = try expr(gz, scope, .{ .coerced_ty = .u16_type }, params[0]);
7404 const result = try gz.addExtendedPayload(.int_to_error, Zir.Inst.UnNode{
7405 .node = gz.nodeIndexToRelative(node),
7406 .operand = operand,
7407 });
7408 return rvalue(gz, rl, result, node);
7409 },
7399 .align_cast => {7410 .align_cast => {
7400 const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]);7411 const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]);
7401 const rhs = try expr(gz, scope, .none, params[1]);7412 const rhs = try expr(gz, scope, .none, params[1]);
...@@ -7635,7 +7646,8 @@ fn builtinCall(...@@ -7635,7 +7646,8 @@ fn builtinCall(
7635 return rvalue(gz, rl, result, node);7646 return rvalue(gz, rl, result, node);
7636 },7647 },
7637 .select => {7648 .select => {
7638 const result = try gz.addPlNode(.select, node, Zir.Inst.Select{7649 const result = try gz.addExtendedPayload(.select, Zir.Inst.Select{
7650 .node = gz.nodeIndexToRelative(node),
7639 .elem_type = try typeExpr(gz, scope, params[0]),7651 .elem_type = try typeExpr(gz, scope, params[0]),
7640 .pred = try expr(gz, scope, .none, params[1]),7652 .pred = try expr(gz, scope, .none, params[1]),
7641 .a = try expr(gz, scope, .none, params[2]),7653 .a = try expr(gz, scope, .none, params[2]),
src/Sema.zig+23-24
...@@ -739,8 +739,6 @@ fn analyzeBodyInner(...@@ -739,8 +739,6 @@ fn analyzeBodyInner(
739 .err_union_payload_unsafe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, false),739 .err_union_payload_unsafe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, false),
740 .error_union_type => try sema.zirErrorUnionType(block, inst),740 .error_union_type => try sema.zirErrorUnionType(block, inst),
741 .error_value => try sema.zirErrorValue(block, inst),741 .error_value => try sema.zirErrorValue(block, inst),
742 .error_to_int => try sema.zirErrorToInt(block, inst),
743 .int_to_error => try sema.zirIntToError(block, inst),
744 .field_ptr => try sema.zirFieldPtr(block, inst),742 .field_ptr => try sema.zirFieldPtr(block, inst),
745 .field_ptr_named => try sema.zirFieldPtrNamed(block, inst),743 .field_ptr_named => try sema.zirFieldPtrNamed(block, inst),
746 .field_val => try sema.zirFieldVal(block, inst),744 .field_val => try sema.zirFieldVal(block, inst),
...@@ -835,7 +833,6 @@ fn analyzeBodyInner(...@@ -835,7 +833,6 @@ fn analyzeBodyInner(
835 .splat => try sema.zirSplat(block, inst),833 .splat => try sema.zirSplat(block, inst),
836 .reduce => try sema.zirReduce(block, inst),834 .reduce => try sema.zirReduce(block, inst),
837 .shuffle => try sema.zirShuffle(block, inst),835 .shuffle => try sema.zirShuffle(block, inst),
838 .select => try sema.zirSelect(block, inst),
839 .atomic_load => try sema.zirAtomicLoad(block, inst),836 .atomic_load => try sema.zirAtomicLoad(block, inst),
840 .atomic_rmw => try sema.zirAtomicRmw(block, inst),837 .atomic_rmw => try sema.zirAtomicRmw(block, inst),
841 .mul_add => try sema.zirMulAdd(block, inst),838 .mul_add => try sema.zirMulAdd(block, inst),
...@@ -942,6 +939,9 @@ fn analyzeBodyInner(...@@ -942,6 +939,9 @@ fn analyzeBodyInner(
942 .field_call_bind_named => try sema.zirFieldCallBindNamed(block, extended),939 .field_call_bind_named => try sema.zirFieldCallBindNamed(block, extended),
943 .err_set_cast => try sema.zirErrSetCast( block, extended),940 .err_set_cast => try sema.zirErrSetCast( block, extended),
944 .await_nosuspend => try sema.zirAwaitNosuspend( block, extended),941 .await_nosuspend => try sema.zirAwaitNosuspend( block, extended),
942 .select => try sema.zirSelect( block, extended),
943 .error_to_int => try sema.zirErrorToInt( block, extended),
944 .int_to_error => try sema.zirIntToError( block, extended),
945 // zig fmt: on945 // zig fmt: on
946 .fence => {946 .fence => {
947 try sema.zirFence(block, extended);947 try sema.zirFence(block, extended);
...@@ -6240,18 +6240,18 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -6240,18 +6240,18 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
6240 );6240 );
6241}6241}
62426242
6243fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {6243fn zirErrorToInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
6244 const tracy = trace(@src());6244 const tracy = trace(@src());
6245 defer tracy.end();6245 defer tracy.end();
62466246
6247 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6247 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6248 const src = inst_data.src();6248 const src = LazySrcLoc.nodeOffset(extra.node);
6249 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };6249 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
6250 const op = try sema.resolveInst(inst_data.operand);6250 const uncasted_operand = try sema.resolveInst(extra.operand);
6251 const op_coerced = try sema.coerce(block, Type.anyerror, op, operand_src);6251 const operand = try sema.coerce(block, Type.anyerror, uncasted_operand, operand_src);
6252 const result_ty = Type.u16;6252 const result_ty = Type.u16;
62536253
6254 if (try sema.resolveMaybeUndefVal(block, src, op_coerced)) |val| {6254 if (try sema.resolveMaybeUndefVal(block, src, operand)) |val| {
6255 if (val.isUndef()) {6255 if (val.isUndef()) {
6256 return sema.addConstUndef(result_ty);6256 return sema.addConstUndef(result_ty);
6257 }6257 }
...@@ -6273,7 +6273,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -6273,7 +6273,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
6273 }6273 }
6274 }6274 }
62756275
6276 const op_ty = sema.typeOf(op);6276 const op_ty = sema.typeOf(uncasted_operand);
6277 try sema.resolveInferredErrorSetTy(block, src, op_ty);6277 try sema.resolveInferredErrorSetTy(block, src, op_ty);
6278 if (!op_ty.isAnyError()) {6278 if (!op_ty.isAnyError()) {
6279 const names = op_ty.errorSetNames();6279 const names = op_ty.errorSetNames();
...@@ -6285,17 +6285,17 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -6285,17 +6285,17 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
6285 }6285 }
62866286
6287 try sema.requireRuntimeBlock(block, src);6287 try sema.requireRuntimeBlock(block, src);
6288 return block.addBitCast(result_ty, op_coerced);6288 return block.addBitCast(result_ty, operand);
6289}6289}
62906290
6291fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {6291fn zirIntToError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
6292 const tracy = trace(@src());6292 const tracy = trace(@src());
6293 defer tracy.end();6293 defer tracy.end();
62946294
6295 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6295 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6296 const src = inst_data.src();6296 const src = LazySrcLoc.nodeOffset(extra.node);
6297 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };6297 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
6298 const uncasted_operand = try sema.resolveInst(inst_data.operand);6298 const uncasted_operand = try sema.resolveInst(extra.operand);
6299 const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src);6299 const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src);
6300 const target = sema.mod.getTarget();6300 const target = sema.mod.getTarget();
63016301
...@@ -16703,14 +16703,13 @@ fn analyzeShuffle(...@@ -16703,14 +16703,13 @@ fn analyzeShuffle(
16703 });16703 });
16704}16704}
1670516705
16706fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {16706fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
16707 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;16707 const extra = sema.code.extraData(Zir.Inst.Select, extended.operand).data;
16708 const extra = sema.code.extraData(Zir.Inst.Select, inst_data.payload_index).data;
1670916708
16710 const elem_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };16709 const elem_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node };
16711 const pred_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };16710 const pred_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node };
16712 const a_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };16711 const a_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node };
16713 const b_src: LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node };16712 const b_src: LazySrcLoc = .{ .node_offset_builtin_call_arg3 = extra.node };
1671416713
16715 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);16714 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
16716 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);16715 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
src/Zir.zig+10-16
...@@ -778,10 +778,6 @@ pub const Inst = struct {...@@ -778,10 +778,6 @@ pub const Inst = struct {
778 /// Implement builtin `@ptrToInt`. Uses `un_node`.778 /// Implement builtin `@ptrToInt`. Uses `un_node`.
779 /// Convert a pointer to a `usize` integer.779 /// Convert a pointer to a `usize` integer.
780 ptr_to_int,780 ptr_to_int,
781 /// Implement builtin `@errToInt`. Uses `un_node`.
782 error_to_int,
783 /// Implement builtin `@intToError`. Uses `un_node`.
784 int_to_error,
785 /// Emit an error message and fail compilation.781 /// Emit an error message and fail compilation.
786 /// Uses the `un_node` field.782 /// Uses the `un_node` field.
787 compile_error,783 compile_error,
...@@ -916,9 +912,6 @@ pub const Inst = struct {...@@ -916,9 +912,6 @@ pub const Inst = struct {
916 /// Implements the `@shuffle` builtin.912 /// Implements the `@shuffle` builtin.
917 /// Uses the `pl_node` union field with payload `Shuffle`.913 /// Uses the `pl_node` union field with payload `Shuffle`.
918 shuffle,914 shuffle,
919 /// Implements the `@select` builtin.
920 /// Uses the `pl_node` union field with payload `Select`.
921 select,
922 /// Implements the `@atomicLoad` builtin.915 /// Implements the `@atomicLoad` builtin.
923 /// Uses the `pl_node` union field with payload `AtomicLoad`.916 /// Uses the `pl_node` union field with payload `AtomicLoad`.
924 atomic_load,917 atomic_load,
...@@ -1125,8 +1118,6 @@ pub const Inst = struct {...@@ -1125,8 +1118,6 @@ pub const Inst = struct {
1125 .err_union_payload_unsafe_ptr,1118 .err_union_payload_unsafe_ptr,
1126 .err_union_code,1119 .err_union_code,
1127 .err_union_code_ptr,1120 .err_union_code_ptr,
1128 .error_to_int,
1129 .int_to_error,
1130 .ptr_type,1121 .ptr_type,
1131 .ptr_type_simple,1122 .ptr_type_simple,
1132 .ensure_err_payload_void,1123 .ensure_err_payload_void,
...@@ -1230,7 +1221,6 @@ pub const Inst = struct {...@@ -1230,7 +1221,6 @@ pub const Inst = struct {
1230 .splat,1221 .splat,
1231 .reduce,1222 .reduce,
1232 .shuffle,1223 .shuffle,
1233 .select,
1234 .atomic_load,1224 .atomic_load,
1235 .atomic_rmw,1225 .atomic_rmw,
1236 .atomic_store,1226 .atomic_store,
...@@ -1423,8 +1413,6 @@ pub const Inst = struct {...@@ -1423,8 +1413,6 @@ pub const Inst = struct {
1423 .err_union_payload_unsafe_ptr,1413 .err_union_payload_unsafe_ptr,
1424 .err_union_code,1414 .err_union_code,
1425 .err_union_code_ptr,1415 .err_union_code_ptr,
1426 .error_to_int,
1427 .int_to_error,
1428 .ptr_type,1416 .ptr_type,
1429 .ptr_type_simple,1417 .ptr_type_simple,
1430 .enum_literal,1418 .enum_literal,
...@@ -1516,7 +1504,6 @@ pub const Inst = struct {...@@ -1516,7 +1504,6 @@ pub const Inst = struct {
1516 .splat,1504 .splat,
1517 .reduce,1505 .reduce,
1518 .shuffle,1506 .shuffle,
1519 .select,
1520 .atomic_load,1507 .atomic_load,
1521 .atomic_rmw,1508 .atomic_rmw,
1522 .mul_add,1509 .mul_add,
...@@ -1731,8 +1718,6 @@ pub const Inst = struct {...@@ -1731,8 +1718,6 @@ pub const Inst = struct {
1731 .bit_size_of = .un_node,1718 .bit_size_of = .un_node,
17321719
1733 .ptr_to_int = .un_node,1720 .ptr_to_int = .un_node,
1734 .error_to_int = .un_node,
1735 .int_to_error = .un_node,
1736 .compile_error = .un_node,1721 .compile_error = .un_node,
1737 .set_eval_branch_quota = .un_node,1722 .set_eval_branch_quota = .un_node,
1738 .enum_to_int = .un_node,1723 .enum_to_int = .un_node,
...@@ -1802,7 +1787,6 @@ pub const Inst = struct {...@@ -1802,7 +1787,6 @@ pub const Inst = struct {
1802 .splat = .pl_node,1787 .splat = .pl_node,
1803 .reduce = .pl_node,1788 .reduce = .pl_node,
1804 .shuffle = .pl_node,1789 .shuffle = .pl_node,
1805 .select = .pl_node,
1806 .atomic_load = .pl_node,1790 .atomic_load = .pl_node,
1807 .atomic_rmw = .pl_node,1791 .atomic_rmw = .pl_node,
1808 .atomic_store = .pl_node,1792 .atomic_store = .pl_node,
...@@ -1971,6 +1955,15 @@ pub const Inst = struct {...@@ -1971,6 +1955,15 @@ pub const Inst = struct {
1971 await_nosuspend,1955 await_nosuspend,
1972 /// `operand` is `src_node: i32`.1956 /// `operand` is `src_node: i32`.
1973 breakpoint,1957 breakpoint,
1958 /// Implements the `@select` builtin.
1959 /// operand` is payload index to `Select`.
1960 select,
1961 /// Implement builtin `@errToInt`.
1962 /// `operand` is payload index to `UnNode`.
1963 error_to_int,
1964 /// Implement builtin `@intToError`.
1965 /// `operand` is payload index to `UnNode`.
1966 int_to_error,
19741967
1975 pub const InstData = struct {1968 pub const InstData = struct {
1976 opcode: Extended,1969 opcode: Extended,
...@@ -3448,6 +3441,7 @@ pub const Inst = struct {...@@ -3448,6 +3441,7 @@ pub const Inst = struct {
3448 };3441 };
34493442
3450 pub const Select = struct {3443 pub const Select = struct {
3444 node: i32,
3451 elem_type: Ref,3445 elem_type: Ref,
3452 pred: Ref,3446 pred: Ref,
3453 a: Ref,3447 a: Ref,
src/print_zir.zig+7-7
...@@ -189,8 +189,6 @@ const Writer = struct {...@@ -189,8 +189,6 @@ const Writer = struct {
189 .typeof_log2_int_type,189 .typeof_log2_int_type,
190 .log2_int_type,190 .log2_int_type,
191 .ptr_to_int,191 .ptr_to_int,
192 .error_to_int,
193 .int_to_error,
194 .compile_error,192 .compile_error,
195 .set_eval_branch_quota,193 .set_eval_branch_quota,
196 .enum_to_int,194 .enum_to_int,
...@@ -284,7 +282,6 @@ const Writer = struct {...@@ -284,7 +282,6 @@ const Writer = struct {
284 .memcpy => try self.writeMemcpy(stream, inst),282 .memcpy => try self.writeMemcpy(stream, inst),
285 .memset => try self.writeMemset(stream, inst),283 .memset => try self.writeMemset(stream, inst),
286 .shuffle => try self.writeShuffle(stream, inst),284 .shuffle => try self.writeShuffle(stream, inst),
287 .select => try self.writeSelect(stream, inst),
288 .mul_add => try self.writeMulAdd(stream, inst),285 .mul_add => try self.writeMulAdd(stream, inst),
289 .field_parent_ptr => try self.writeFieldParentPtr(stream, inst),286 .field_parent_ptr => try self.writeFieldParentPtr(stream, inst),
290 .builtin_call => try self.writeBuiltinCall(stream, inst),287 .builtin_call => try self.writeBuiltinCall(stream, inst),
...@@ -478,6 +475,8 @@ const Writer = struct {...@@ -478,6 +475,8 @@ const Writer = struct {
478 .compile_log => try self.writeNodeMultiOp(stream, extended),475 .compile_log => try self.writeNodeMultiOp(stream, extended),
479 .typeof_peer => try self.writeTypeofPeer(stream, extended),476 .typeof_peer => try self.writeTypeofPeer(stream, extended),
480477
478 .select => try self.writeSelect(stream, extended),
479
481 .add_with_overflow,480 .add_with_overflow,
482 .sub_with_overflow,481 .sub_with_overflow,
483 .mul_with_overflow,482 .mul_with_overflow,
...@@ -496,6 +495,8 @@ const Writer = struct {...@@ -496,6 +495,8 @@ const Writer = struct {
496 .set_float_mode,495 .set_float_mode,
497 .set_align_stack,496 .set_align_stack,
498 .wasm_memory_size,497 .wasm_memory_size,
498 .error_to_int,
499 .int_to_error,
499 => {500 => {
500 const inst_data = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;501 const inst_data = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;
501 const src = LazySrcLoc.nodeOffset(inst_data.node);502 const src = LazySrcLoc.nodeOffset(inst_data.node);
...@@ -772,9 +773,8 @@ const Writer = struct {...@@ -772,9 +773,8 @@ const Writer = struct {
772 try self.writeSrc(stream, inst_data.src());773 try self.writeSrc(stream, inst_data.src());
773 }774 }
774775
775 fn writeSelect(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {776 fn writeSelect(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
776 const inst_data = self.code.instructions.items(.data)[inst].pl_node;777 const extra = self.code.extraData(Zir.Inst.Select, extended.operand).data;
777 const extra = self.code.extraData(Zir.Inst.Select, inst_data.payload_index).data;
778 try self.writeInstRef(stream, extra.elem_type);778 try self.writeInstRef(stream, extra.elem_type);
779 try stream.writeAll(", ");779 try stream.writeAll(", ");
780 try self.writeInstRef(stream, extra.pred);780 try self.writeInstRef(stream, extra.pred);
...@@ -783,7 +783,7 @@ const Writer = struct {...@@ -783,7 +783,7 @@ const Writer = struct {
783 try stream.writeAll(", ");783 try stream.writeAll(", ");
784 try self.writeInstRef(stream, extra.b);784 try self.writeInstRef(stream, extra.b);
785 try stream.writeAll(") ");785 try stream.writeAll(") ");
786 try self.writeSrc(stream, inst_data.src());786 try self.writeSrc(stream, LazySrcLoc.nodeOffset(extra.node));
787 }787 }
788788
789 fn writeMulAdd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {789 fn writeMulAdd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {