| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //! Semantic analysis of ZIR instructions. |
| 2 | 2 | //! Shared to every Block. Stored on the stack. |
| 3 | | //! State used for compiling a `zir.Code` into TZIR. |
| 3 | //! State used for compiling a `Zir` into TZIR. |
| 4 | 4 | //! Transforms untyped ZIR instructions into semantically-analyzed TZIR instructions. |
| 5 | 5 | //! Does type checking, comptime control flow, and safety-check generation. |
| 6 | 6 | //! This is the the heart of the Zig compiler. |
| ... | ... | @@ -10,7 +10,7 @@ mod: *Module, |
| 10 | 10 | gpa: *Allocator, |
| 11 | 11 | /// Points to the arena allocator of the Decl. |
| 12 | 12 | arena: *Allocator, |
| 13 | | code: zir.Code, |
| 13 | code: Zir, |
| 14 | 14 | /// Maps ZIR to TZIR. |
| 15 | 15 | inst_map: []*Inst, |
| 16 | 16 | /// When analyzing an inline function call, owner_decl is the Decl of the caller |
| ... | ... | @@ -52,7 +52,7 @@ const Value = @import("value.zig").Value; |
| 52 | 52 | const Type = @import("type.zig").Type; |
| 53 | 53 | const TypedValue = @import("TypedValue.zig"); |
| 54 | 54 | const ir = @import("ir.zig"); |
| 55 | | const zir = @import("zir.zig"); |
| 55 | const Zir = @import("zir.zig"); // TODO rename to Zir.zig |
| 56 | 56 | const Module = @import("Module.zig"); |
| 57 | 57 | const Inst = ir.Inst; |
| 58 | 58 | const Body = ir.Body; |
| ... | ... | @@ -64,14 +64,14 @@ const LazySrcLoc = Module.LazySrcLoc; |
| 64 | 64 | const RangeSet = @import("RangeSet.zig"); |
| 65 | 65 | const AstGen = @import("AstGen.zig"); |
| 66 | 66 | |
| 67 | | pub fn root(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Index { |
| 67 | pub fn root(sema: *Sema, root_block: *Scope.Block) !Zir.Inst.Index { |
| 68 | 68 | const inst_data = sema.code.instructions.items(.data)[0].pl_node; |
| 69 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 69 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 70 | 70 | const root_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 71 | 71 | return sema.analyzeBody(root_block, root_body); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | | pub fn rootAsRef(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Ref { |
| 74 | pub fn rootAsRef(sema: *Sema, root_block: *Scope.Block) !Zir.Inst.Ref { |
| 75 | 75 | const break_inst = try sema.root(root_block); |
| 76 | 76 | return sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 77 | 77 | } |
| ... | ... | @@ -89,7 +89,7 @@ pub fn rootAsType(sema: *Sema, root_block: *Scope.Block) !Type { |
| 89 | 89 | /// Returns only the result from the body that is specified. |
| 90 | 90 | /// Only appropriate to call when it is determined at comptime that this body |
| 91 | 91 | /// has no peers. |
| 92 | | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) InnerError!*Inst { |
| 92 | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!*Inst { |
| 93 | 93 | const break_inst = try sema.analyzeBody(block, body); |
| 94 | 94 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 95 | 95 | return sema.resolveInst(operand_ref); |
| ... | ... | @@ -99,22 +99,22 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) I |
| 99 | 99 | /// return type of `analyzeBody` so that we can tail call them. |
| 100 | 100 | /// Only appropriate to return when the instruction is known to be NoReturn |
| 101 | 101 | /// solely based on the ZIR tag. |
| 102 | | const always_noreturn: InnerError!zir.Inst.Index = @as(zir.Inst.Index, undefined); |
| 102 | const always_noreturn: InnerError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined); |
| 103 | 103 | |
| 104 | 104 | /// This function is the main loop of `Sema` and it can be used in two different ways: |
| 105 | 105 | /// * The traditional way where there are N breaks out of the block and peer type |
| 106 | | /// resolution is done on the break operands. In this case, the `zir.Inst.Index` |
| 106 | /// resolution is done on the break operands. In this case, the `Zir.Inst.Index` |
| 107 | 107 | /// part of the return value will be `undefined`, and callsites should ignore it, |
| 108 | 108 | /// finding the block result value via the block scope. |
| 109 | 109 | /// * The "flat" way. There is only 1 break out of the block, and it is with a `break_inline` |
| 110 | | /// instruction. In this case, the `zir.Inst.Index` part of the return value will be |
| 110 | /// instruction. In this case, the `Zir.Inst.Index` part of the return value will be |
| 111 | 111 | /// the break instruction. This communicates both which block the break applies to, as |
| 112 | 112 | /// well as the operand. No block scope needs to be created for this strategy. |
| 113 | 113 | pub fn analyzeBody( |
| 114 | 114 | sema: *Sema, |
| 115 | 115 | block: *Scope.Block, |
| 116 | | body: []const zir.Inst.Index, |
| 117 | | ) InnerError!zir.Inst.Index { |
| 116 | body: []const Zir.Inst.Index, |
| 117 | ) InnerError!Zir.Inst.Index { |
| 118 | 118 | // No tracy calls here, to avoid interfering with the tail call mechanism. |
| 119 | 119 | |
| 120 | 120 | const map = block.sema.inst_map; |
| ... | ... | @@ -368,7 +368,7 @@ pub fn analyzeBody( |
| 368 | 368 | .block_inline => blk: { |
| 369 | 369 | // Directly analyze the block body without introducing a new block. |
| 370 | 370 | const inst_data = datas[inst].pl_node; |
| 371 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 371 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 372 | 372 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 373 | 373 | const break_inst = try sema.analyzeBody(block, inline_body); |
| 374 | 374 | const break_data = datas[break_inst].@"break"; |
| ... | ... | @@ -381,7 +381,7 @@ pub fn analyzeBody( |
| 381 | 381 | .condbr_inline => blk: { |
| 382 | 382 | const inst_data = datas[inst].pl_node; |
| 383 | 383 | const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node }; |
| 384 | | const extra = sema.code.extraData(zir.Inst.CondBr, inst_data.payload_index); |
| 384 | const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index); |
| 385 | 385 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 386 | 386 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; |
| 387 | 387 | const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition); |
| ... | ... | @@ -401,19 +401,19 @@ pub fn analyzeBody( |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /// TODO when we rework TZIR memory layout, this function will no longer have a possible error. |
| 404 | | pub fn resolveInst(sema: *Sema, zir_ref: zir.Inst.Ref) error{OutOfMemory}!*ir.Inst { |
| 404 | pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) error{OutOfMemory}!*ir.Inst { |
| 405 | 405 | var i: usize = @enumToInt(zir_ref); |
| 406 | 406 | |
| 407 | 407 | // First section of indexes correspond to a set number of constant values. |
| 408 | | if (i < zir.Inst.Ref.typed_value_map.len) { |
| 408 | if (i < Zir.Inst.Ref.typed_value_map.len) { |
| 409 | 409 | // TODO when we rework TZIR memory layout, this function can be as simple as: |
| 410 | | // if (zir_ref < zir.const_inst_list.len + sema.param_count) |
| 410 | // if (zir_ref < Zir.const_inst_list.len + sema.param_count) |
| 411 | 411 | // return zir_ref; |
| 412 | 412 | // Until then we allocate memory for a new, mutable `ir.Inst` to match what |
| 413 | 413 | // TZIR expects. |
| 414 | | return sema.mod.constInst(sema.arena, .unneeded, zir.Inst.Ref.typed_value_map[i]); |
| 414 | return sema.mod.constInst(sema.arena, .unneeded, Zir.Inst.Ref.typed_value_map[i]); |
| 415 | 415 | } |
| 416 | | i -= zir.Inst.Ref.typed_value_map.len; |
| 416 | i -= Zir.Inst.Ref.typed_value_map.len; |
| 417 | 417 | |
| 418 | 418 | // Next section of indexes correspond to function parameters, if any. |
| 419 | 419 | if (i < sema.param_inst_list.len) { |
| ... | ... | @@ -429,7 +429,7 @@ fn resolveConstString( |
| 429 | 429 | sema: *Sema, |
| 430 | 430 | block: *Scope.Block, |
| 431 | 431 | src: LazySrcLoc, |
| 432 | | zir_ref: zir.Inst.Ref, |
| 432 | zir_ref: Zir.Inst.Ref, |
| 433 | 433 | ) ![]u8 { |
| 434 | 434 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 435 | 435 | const wanted_type = Type.initTag(.const_slice_u8); |
| ... | ... | @@ -438,7 +438,7 @@ fn resolveConstString( |
| 438 | 438 | return val.toAllocatedBytes(sema.arena); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | | fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: zir.Inst.Ref) !Type { |
| 441 | fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 442 | 442 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 443 | 443 | const wanted_type = Type.initTag(.@"type"); |
| 444 | 444 | const coerced_inst = try sema.coerce(block, wanted_type, tzir_inst, src); |
| ... | ... | @@ -476,7 +476,7 @@ fn resolveAlreadyCoercedInt( |
| 476 | 476 | sema: *Sema, |
| 477 | 477 | block: *Scope.Block, |
| 478 | 478 | src: LazySrcLoc, |
| 479 | | zir_ref: zir.Inst.Ref, |
| 479 | zir_ref: Zir.Inst.Ref, |
| 480 | 480 | comptime Int: type, |
| 481 | 481 | ) !Int { |
| 482 | 482 | comptime assert(@typeInfo(Int).Int.bits <= 64); |
| ... | ... | @@ -492,7 +492,7 @@ fn resolveInt( |
| 492 | 492 | sema: *Sema, |
| 493 | 493 | block: *Scope.Block, |
| 494 | 494 | src: LazySrcLoc, |
| 495 | | zir_ref: zir.Inst.Ref, |
| 495 | zir_ref: Zir.Inst.Ref, |
| 496 | 496 | dest_type: Type, |
| 497 | 497 | ) !u64 { |
| 498 | 498 | const tzir_inst = try sema.resolveInst(zir_ref); |
| ... | ... | @@ -506,7 +506,7 @@ fn resolveInstConst( |
| 506 | 506 | sema: *Sema, |
| 507 | 507 | block: *Scope.Block, |
| 508 | 508 | src: LazySrcLoc, |
| 509 | | zir_ref: zir.Inst.Ref, |
| 509 | zir_ref: Zir.Inst.Ref, |
| 510 | 510 | ) InnerError!TypedValue { |
| 511 | 511 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 512 | 512 | const val = try sema.resolveConstValue(block, src, tzir_inst); |
| ... | ... | @@ -516,13 +516,13 @@ fn resolveInstConst( |
| 516 | 516 | }; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 519 | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 520 | 520 | const tracy = trace(@src()); |
| 521 | 521 | defer tracy.end(); |
| 522 | 522 | return sema.mod.fail(&block.base, sema.src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 525 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 526 | 526 | const tracy = trace(@src()); |
| 527 | 527 | defer tracy.end(); |
| 528 | 528 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); |
| ... | ... | @@ -531,7 +531,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 531 | 531 | fn zirStructDecl( |
| 532 | 532 | sema: *Sema, |
| 533 | 533 | block: *Scope.Block, |
| 534 | | inst: zir.Inst.Index, |
| 534 | inst: Zir.Inst.Index, |
| 535 | 535 | layout: std.builtin.TypeInfo.ContainerLayout, |
| 536 | 536 | ) InnerError!*Inst { |
| 537 | 537 | const tracy = trace(@src()); |
| ... | ... | @@ -540,7 +540,7 @@ fn zirStructDecl( |
| 540 | 540 | const gpa = sema.gpa; |
| 541 | 541 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 542 | 542 | const src = inst_data.src(); |
| 543 | | const extra = sema.code.extraData(zir.Inst.StructDecl, inst_data.payload_index); |
| 543 | const extra = sema.code.extraData(Zir.Inst.StructDecl, inst_data.payload_index); |
| 544 | 544 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 545 | 545 | const fields_len = extra.data.fields_len; |
| 546 | 546 | |
| ... | ... | @@ -650,7 +650,7 @@ fn zirStructDecl( |
| 650 | 650 | |
| 651 | 651 | const field_name_zir = sema.code.nullTerminatedString(sema.code.extra[extra_index]); |
| 652 | 652 | extra_index += 1; |
| 653 | | const field_type_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 653 | const field_type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 654 | 654 | extra_index += 1; |
| 655 | 655 | |
| 656 | 656 | // This string needs to outlive the ZIR code. |
| ... | ... | @@ -669,7 +669,7 @@ fn zirStructDecl( |
| 669 | 669 | }; |
| 670 | 670 | |
| 671 | 671 | if (has_align) { |
| 672 | | const align_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 672 | const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 673 | 673 | extra_index += 1; |
| 674 | 674 | // TODO: if we need to report an error here, use a source location |
| 675 | 675 | // that points to this alignment expression rather than the struct. |
| ... | ... | @@ -677,7 +677,7 @@ fn zirStructDecl( |
| 677 | 677 | gop.entry.value.abi_align = (try sema.resolveInstConst(block, src, align_ref)).val; |
| 678 | 678 | } |
| 679 | 679 | if (has_default) { |
| 680 | | const default_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 680 | const default_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 681 | 681 | extra_index += 1; |
| 682 | 682 | // TODO: if we need to report an error here, use a source location |
| 683 | 683 | // that points to this default value expression rather than the struct. |
| ... | ... | @@ -692,7 +692,7 @@ fn zirStructDecl( |
| 692 | 692 | fn zirEnumDecl( |
| 693 | 693 | sema: *Sema, |
| 694 | 694 | block: *Scope.Block, |
| 695 | | inst: zir.Inst.Index, |
| 695 | inst: Zir.Inst.Index, |
| 696 | 696 | nonexhaustive: bool, |
| 697 | 697 | ) InnerError!*Inst { |
| 698 | 698 | const tracy = trace(@src()); |
| ... | ... | @@ -701,7 +701,7 @@ fn zirEnumDecl( |
| 701 | 701 | const gpa = sema.gpa; |
| 702 | 702 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 703 | 703 | const src = inst_data.src(); |
| 704 | | const extra = sema.code.extraData(zir.Inst.EnumDecl, inst_data.payload_index); |
| 704 | const extra = sema.code.extraData(Zir.Inst.EnumDecl, inst_data.payload_index); |
| 705 | 705 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 706 | 706 | const fields_len = extra.data.fields_len; |
| 707 | 707 | |
| ... | ... | @@ -842,7 +842,7 @@ fn zirEnumDecl( |
| 842 | 842 | assert(!gop.found_existing); |
| 843 | 843 | |
| 844 | 844 | if (has_tag_value) { |
| 845 | | const tag_val_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 845 | const tag_val_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 846 | 846 | extra_index += 1; |
| 847 | 847 | // TODO: if we need to report an error here, use a source location |
| 848 | 848 | // that points to this default value expression rather than the struct. |
| ... | ... | @@ -858,29 +858,29 @@ fn zirEnumDecl( |
| 858 | 858 | return sema.analyzeDeclVal(block, src, new_decl); |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | | fn zirUnionDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 861 | fn zirUnionDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 862 | 862 | const tracy = trace(@src()); |
| 863 | 863 | defer tracy.end(); |
| 864 | 864 | |
| 865 | 865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 866 | 866 | const src = inst_data.src(); |
| 867 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 867 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 868 | 868 | |
| 869 | 869 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirUnionDecl", .{}); |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | | fn zirOpaqueDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 872 | fn zirOpaqueDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 873 | 873 | const tracy = trace(@src()); |
| 874 | 874 | defer tracy.end(); |
| 875 | 875 | |
| 876 | 876 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 877 | 877 | const src = inst_data.src(); |
| 878 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 878 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 879 | 879 | |
| 880 | 880 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{}); |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | | fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 883 | fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 884 | 884 | const tracy = trace(@src()); |
| 885 | 885 | defer tracy.end(); |
| 886 | 886 | |
| ... | ... | @@ -892,7 +892,7 @@ fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 892 | 892 | return block.addNoOp(src, ptr_type, .alloc); |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | | fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 895 | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 896 | 896 | const tracy = trace(@src()); |
| 897 | 897 | defer tracy.end(); |
| 898 | 898 | |
| ... | ... | @@ -901,7 +901,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 901 | 901 | return sema.analyzeRef(block, inst_data.src(), operand); |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | | fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 904 | fn zirRetType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 905 | 905 | const tracy = trace(@src()); |
| 906 | 906 | defer tracy.end(); |
| 907 | 907 | |
| ... | ... | @@ -912,7 +912,7 @@ fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 912 | 912 | return sema.mod.constType(sema.arena, src, ret_type); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | | fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 915 | fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 916 | 916 | const tracy = trace(@src()); |
| 917 | 917 | defer tracy.end(); |
| 918 | 918 | |
| ... | ... | @@ -935,7 +935,7 @@ fn ensureResultUsed( |
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | | fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 938 | fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 939 | 939 | const tracy = trace(@src()); |
| 940 | 940 | defer tracy.end(); |
| 941 | 941 | |
| ... | ... | @@ -948,7 +948,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde |
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 951 | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 952 | 952 | const tracy = trace(@src()); |
| 953 | 953 | defer tracy.end(); |
| 954 | 954 | |
| ... | ... | @@ -982,7 +982,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 982 | 982 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 985 | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 986 | 986 | const tracy = trace(@src()); |
| 987 | 987 | defer tracy.end(); |
| 988 | 988 | |
| ... | ... | @@ -995,7 +995,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* |
| 995 | 995 | return block.addNoOp(var_decl_src, ptr_type, .alloc); |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 998 | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 999 | 999 | const tracy = trace(@src()); |
| 1000 | 1000 | defer tracy.end(); |
| 1001 | 1001 | |
| ... | ... | @@ -1012,7 +1012,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 1012 | 1012 | fn zirAllocInferred( |
| 1013 | 1013 | sema: *Sema, |
| 1014 | 1014 | block: *Scope.Block, |
| 1015 | | inst: zir.Inst.Index, |
| 1015 | inst: Zir.Inst.Index, |
| 1016 | 1016 | inferred_alloc_ty: Type, |
| 1017 | 1017 | ) InnerError!*Inst { |
| 1018 | 1018 | const tracy = trace(@src()); |
| ... | ... | @@ -1038,7 +1038,7 @@ fn zirAllocInferred( |
| 1038 | 1038 | return result; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | | fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1041 | fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1042 | 1042 | const tracy = trace(@src()); |
| 1043 | 1043 | defer tracy.end(); |
| 1044 | 1044 | |
| ... | ... | @@ -1064,7 +1064,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde |
| 1064 | 1064 | ptr.tag = .alloc; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | | fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1067 | fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1068 | 1068 | const tracy = trace(@src()); |
| 1069 | 1069 | defer tracy.end(); |
| 1070 | 1070 | |
| ... | ... | @@ -1072,26 +1072,26 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Ind |
| 1072 | 1072 | const mod = sema.mod; |
| 1073 | 1073 | const validate_inst = sema.code.instructions.items(.data)[inst].pl_node; |
| 1074 | 1074 | const struct_init_src = validate_inst.src(); |
| 1075 | | const validate_extra = sema.code.extraData(zir.Inst.Block, validate_inst.payload_index); |
| 1075 | const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index); |
| 1076 | 1076 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 1077 | 1077 | |
| 1078 | 1078 | const struct_obj: *Module.Struct = s: { |
| 1079 | 1079 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 1080 | | const field_ptr_extra = sema.code.extraData(zir.Inst.Field, field_ptr_data.payload_index).data; |
| 1080 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; |
| 1081 | 1081 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); |
| 1082 | 1082 | break :s object_ptr.ty.elemType().castTag(.@"struct").?.data; |
| 1083 | 1083 | }; |
| 1084 | 1084 | |
| 1085 | 1085 | // Maps field index to field_ptr index of where it was already initialized. |
| 1086 | | const found_fields = try gpa.alloc(zir.Inst.Index, struct_obj.fields.entries.items.len); |
| 1086 | const found_fields = try gpa.alloc(Zir.Inst.Index, struct_obj.fields.entries.items.len); |
| 1087 | 1087 | defer gpa.free(found_fields); |
| 1088 | 1088 | |
| 1089 | | mem.set(zir.Inst.Index, found_fields, 0); |
| 1089 | mem.set(Zir.Inst.Index, found_fields, 0); |
| 1090 | 1090 | |
| 1091 | 1091 | for (instrs) |field_ptr| { |
| 1092 | 1092 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; |
| 1093 | 1093 | const field_src: LazySrcLoc = .{ .node_offset_back2tok = field_ptr_data.src_node }; |
| 1094 | | const field_ptr_extra = sema.code.extraData(zir.Inst.Field, field_ptr_data.payload_index).data; |
| 1094 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; |
| 1095 | 1095 | const field_name = sema.code.nullTerminatedString(field_ptr_extra.field_name_start); |
| 1096 | 1096 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 1097 | 1097 | return sema.failWithBadFieldAccess(block, struct_obj, field_src, field_name); |
| ... | ... | @@ -1164,7 +1164,7 @@ fn failWithBadFieldAccess( |
| 1164 | 1164 | return mod.failWithOwnedErrorMsg(&block.base, msg); |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | | fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1167 | fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1168 | 1168 | const tracy = trace(@src()); |
| 1169 | 1169 | defer tracy.end(); |
| 1170 | 1170 | |
| ... | ... | @@ -1180,7 +1180,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 1180 | 1180 | return sema.storePtr(block, src, bitcasted_ptr, value); |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | | fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1183 | fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1184 | 1184 | const tracy = trace(@src()); |
| 1185 | 1185 | defer tracy.end(); |
| 1186 | 1186 | |
| ... | ... | @@ -1199,7 +1199,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1199 | 1199 | return sema.storePtr(block, src, bitcasted_ptr, value); |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | | fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1202 | fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1203 | 1203 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1204 | 1204 | const src = inst_data.src(); |
| 1205 | 1205 | try sema.requireFunctionBlock(block, src); |
| ... | ... | @@ -1208,7 +1208,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1208 | 1208 | sema.branch_quota = quota; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | | fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1211 | fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1212 | 1212 | const tracy = trace(@src()); |
| 1213 | 1213 | defer tracy.end(); |
| 1214 | 1214 | |
| ... | ... | @@ -1218,19 +1218,19 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!v |
| 1218 | 1218 | return sema.storePtr(block, sema.src, ptr, value); |
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | | fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1221 | fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1222 | 1222 | const tracy = trace(@src()); |
| 1223 | 1223 | defer tracy.end(); |
| 1224 | 1224 | |
| 1225 | 1225 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1226 | 1226 | const src = inst_data.src(); |
| 1227 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 1227 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 1228 | 1228 | const ptr = try sema.resolveInst(extra.lhs); |
| 1229 | 1229 | const value = try sema.resolveInst(extra.rhs); |
| 1230 | 1230 | return sema.storePtr(block, src, ptr, value); |
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1233 | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1234 | 1234 | const tracy = trace(@src()); |
| 1235 | 1235 | defer tracy.end(); |
| 1236 | 1236 | |
| ... | ... | @@ -1266,7 +1266,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 1266 | 1266 | return sema.mod.constType(sema.arena, src, param_type); |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | | fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1269 | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1270 | 1270 | const tracy = trace(@src()); |
| 1271 | 1271 | defer tracy.end(); |
| 1272 | 1272 | |
| ... | ... | @@ -1292,7 +1292,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 1292 | 1292 | return sema.analyzeDeclRef(block, .unneeded, new_decl); |
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | | fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1295 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1296 | 1296 | const tracy = trace(@src()); |
| 1297 | 1297 | defer tracy.end(); |
| 1298 | 1298 | |
| ... | ... | @@ -1300,7 +1300,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 1300 | 1300 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1303 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1304 | 1304 | const arena = sema.arena; |
| 1305 | 1305 | const inst_data = sema.code.instructions.items(.data)[inst].float; |
| 1306 | 1306 | const src = inst_data.src(); |
| ... | ... | @@ -1312,10 +1312,10 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* |
| 1312 | 1312 | }); |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1315 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1316 | 1316 | const arena = sema.arena; |
| 1317 | 1317 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1318 | | const extra = sema.code.extraData(zir.Inst.Float128, inst_data.payload_index).data; |
| 1318 | const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; |
| 1319 | 1319 | const src = inst_data.src(); |
| 1320 | 1320 | const number = extra.get(); |
| 1321 | 1321 | |
| ... | ... | @@ -1325,7 +1325,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 1325 | 1325 | }); |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | | fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index { |
| 1328 | fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 1329 | 1329 | const tracy = trace(@src()); |
| 1330 | 1330 | defer tracy.end(); |
| 1331 | 1331 | |
| ... | ... | @@ -1336,13 +1336,13 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1336 | 1336 | return sema.mod.fail(&block.base, src, "{s}", .{msg}); |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | | fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1339 | fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1340 | 1340 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| 1341 | 1341 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); |
| 1342 | 1342 | const writer = managed.writer(); |
| 1343 | 1343 | |
| 1344 | 1344 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1345 | | const extra = sema.code.extraData(zir.Inst.MultiOp, inst_data.payload_index); |
| 1345 | const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| 1346 | 1346 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); |
| 1347 | 1347 | |
| 1348 | 1348 | for (args) |arg_ref, i| { |
| ... | ... | @@ -1363,7 +1363,7 @@ fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 1363 | 1363 | } |
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | | fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index { |
| 1366 | fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 1367 | 1367 | const tracy = trace(@src()); |
| 1368 | 1368 | defer tracy.end(); |
| 1369 | 1369 | |
| ... | ... | @@ -1373,13 +1373,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 1373 | 1373 | return always_noreturn; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1376 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1377 | 1377 | const tracy = trace(@src()); |
| 1378 | 1378 | defer tracy.end(); |
| 1379 | 1379 | |
| 1380 | 1380 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1381 | 1381 | const src = inst_data.src(); |
| 1382 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 1382 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 1383 | 1383 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1384 | 1384 | |
| 1385 | 1385 | // TZIR expects a block outside the loop block too. |
| ... | ... | @@ -1434,13 +1434,13 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 1434 | 1434 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1437 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1438 | 1438 | const tracy = trace(@src()); |
| 1439 | 1439 | defer tracy.end(); |
| 1440 | 1440 | |
| 1441 | 1441 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1442 | 1442 | const src = inst_data.src(); |
| 1443 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 1443 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 1444 | 1444 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1445 | 1445 | |
| 1446 | 1446 | // Reserve space for a Block instruction so that generated Break instructions can |
| ... | ... | @@ -1566,12 +1566,12 @@ fn analyzeBlockBody( |
| 1566 | 1566 | return &merges.block_inst.base; |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | | fn zirExport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1569 | fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1570 | 1570 | const tracy = trace(@src()); |
| 1571 | 1571 | defer tracy.end(); |
| 1572 | 1572 | |
| 1573 | 1573 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1574 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 1574 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 1575 | 1575 | const src = inst_data.src(); |
| 1576 | 1576 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 1577 | 1577 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| ... | ... | @@ -1588,7 +1588,7 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 1588 | 1588 | try sema.mod.analyzeExport(&block.base, src, export_name, actual_fn.owner_decl); |
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | | fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1591 | fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1592 | 1592 | const tracy = trace(@src()); |
| 1593 | 1593 | defer tracy.end(); |
| 1594 | 1594 | |
| ... | ... | @@ -1598,7 +1598,7 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 1598 | 1598 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | | fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index { |
| 1601 | fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 1602 | 1602 | const tracy = trace(@src()); |
| 1603 | 1603 | defer tracy.end(); |
| 1604 | 1604 | |
| ... | ... | @@ -1638,7 +1638,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 1638 | 1638 | } |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | | fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 1641 | fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1642 | 1642 | const tracy = trace(@src()); |
| 1643 | 1643 | defer tracy.end(); |
| 1644 | 1644 | |
| ... | ... | @@ -1656,21 +1656,21 @@ fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 1656 | 1656 | _ = try block.addDbgStmt(src, abs_byte_off); |
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1659 | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1660 | 1660 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1661 | 1661 | const src = inst_data.src(); |
| 1662 | 1662 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; |
| 1663 | 1663 | return sema.analyzeDeclRef(block, src, decl); |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1666 | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1667 | 1667 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1668 | 1668 | const src = inst_data.src(); |
| 1669 | 1669 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; |
| 1670 | 1670 | return sema.analyzeDeclVal(block, src, decl); |
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | | fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1673 | fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1674 | 1674 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1675 | 1675 | const src = inst_data.src(); |
| 1676 | 1676 | const decl_name = inst_data.get(sema.code); |
| ... | ... | @@ -1678,7 +1678,7 @@ fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1678 | 1678 | return sema.analyzeDeclRef(block, src, decl); |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | | fn zirDeclValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1681 | fn zirDeclValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1682 | 1682 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1683 | 1683 | const src = inst_data.src(); |
| 1684 | 1684 | const decl_name = inst_data.get(sema.code); |
| ... | ... | @@ -1701,7 +1701,7 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c |
| 1701 | 1701 | fn zirCallNone( |
| 1702 | 1702 | sema: *Sema, |
| 1703 | 1703 | block: *Scope.Block, |
| 1704 | | inst: zir.Inst.Index, |
| 1704 | inst: Zir.Inst.Index, |
| 1705 | 1705 | ensure_result_used: bool, |
| 1706 | 1706 | ) InnerError!*Inst { |
| 1707 | 1707 | const tracy = trace(@src()); |
| ... | ... | @@ -1716,7 +1716,7 @@ fn zirCallNone( |
| 1716 | 1716 | fn zirCall( |
| 1717 | 1717 | sema: *Sema, |
| 1718 | 1718 | block: *Scope.Block, |
| 1719 | | inst: zir.Inst.Index, |
| 1719 | inst: Zir.Inst.Index, |
| 1720 | 1720 | modifier: std.builtin.CallOptions.Modifier, |
| 1721 | 1721 | ensure_result_used: bool, |
| 1722 | 1722 | ) InnerError!*Inst { |
| ... | ... | @@ -1726,7 +1726,7 @@ fn zirCall( |
| 1726 | 1726 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1727 | 1727 | const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node }; |
| 1728 | 1728 | const call_src = inst_data.src(); |
| 1729 | | const extra = sema.code.extraData(zir.Inst.Call, inst_data.payload_index); |
| 1729 | const extra = sema.code.extraData(Zir.Inst.Call, inst_data.payload_index); |
| 1730 | 1730 | const args = sema.code.refSlice(extra.end, extra.data.args_len); |
| 1731 | 1731 | |
| 1732 | 1732 | return sema.analyzeCall(block, extra.data.callee, func_src, call_src, modifier, ensure_result_used, args); |
| ... | ... | @@ -1735,12 +1735,12 @@ fn zirCall( |
| 1735 | 1735 | fn analyzeCall( |
| 1736 | 1736 | sema: *Sema, |
| 1737 | 1737 | block: *Scope.Block, |
| 1738 | | zir_func: zir.Inst.Ref, |
| 1738 | zir_func: Zir.Inst.Ref, |
| 1739 | 1739 | func_src: LazySrcLoc, |
| 1740 | 1740 | call_src: LazySrcLoc, |
| 1741 | 1741 | modifier: std.builtin.CallOptions.Modifier, |
| 1742 | 1742 | ensure_result_used: bool, |
| 1743 | | zir_args: []const zir.Inst.Ref, |
| 1743 | zir_args: []const Zir.Inst.Ref, |
| 1744 | 1744 | ) InnerError!*ir.Inst { |
| 1745 | 1745 | const func = try sema.resolveInst(zir_func); |
| 1746 | 1746 | |
| ... | ... | @@ -1886,7 +1886,7 @@ fn analyzeCall( |
| 1886 | 1886 | return result; |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1889 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1890 | 1890 | const tracy = trace(@src()); |
| 1891 | 1891 | defer tracy.end(); |
| 1892 | 1892 | |
| ... | ... | @@ -1897,7 +1897,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 1897 | 1897 | return sema.mod.constType(sema.arena, src, ty); |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1900 | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1901 | 1901 | const tracy = trace(@src()); |
| 1902 | 1902 | defer tracy.end(); |
| 1903 | 1903 | |
| ... | ... | @@ -1909,7 +1909,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1909 | 1909 | return sema.mod.constType(sema.arena, src, opt_type); |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | | fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1912 | fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1913 | 1913 | const tracy = trace(@src()); |
| 1914 | 1914 | defer tracy.end(); |
| 1915 | 1915 | |
| ... | ... | @@ -1921,7 +1921,7 @@ fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.I |
| 1921 | 1921 | return sema.mod.constType(sema.arena, inst_data.src(), opt_ty); |
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1924 | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1925 | 1925 | const tracy = trace(@src()); |
| 1926 | 1926 | defer tracy.end(); |
| 1927 | 1927 | |
| ... | ... | @@ -1934,14 +1934,14 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 1934 | 1934 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1937 | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1938 | 1938 | const tracy = trace(@src()); |
| 1939 | 1939 | defer tracy.end(); |
| 1940 | 1940 | |
| 1941 | 1941 | // TODO these should be lazily evaluated |
| 1942 | 1942 | const inst_data = sema.code.instructions.items(.data)[inst].array_type_sentinel; |
| 1943 | 1943 | const len = try sema.resolveInstConst(block, .unneeded, inst_data.len); |
| 1944 | | const extra = sema.code.extraData(zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; |
| 1944 | const extra = sema.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; |
| 1945 | 1945 | const sentinel = try sema.resolveInstConst(block, .unneeded, extra.sentinel); |
| 1946 | 1946 | const elem_type = try sema.resolveType(block, .unneeded, extra.elem_type); |
| 1947 | 1947 | const array_ty = try sema.mod.arrayType(sema.arena, len.val.toUnsignedInt(), sentinel.val, elem_type); |
| ... | ... | @@ -1949,12 +1949,12 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1949 | 1949 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 1950 | 1950 | } |
| 1951 | 1951 | |
| 1952 | | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1952 | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1953 | 1953 | const tracy = trace(@src()); |
| 1954 | 1954 | defer tracy.end(); |
| 1955 | 1955 | |
| 1956 | 1956 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1957 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 1957 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 1958 | 1958 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 1959 | 1959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 1960 | 1960 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| ... | ... | @@ -1970,7 +1970,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inn |
| 1970 | 1970 | return sema.mod.constType(sema.arena, src, err_union_ty); |
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1973 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1974 | 1974 | const tracy = trace(@src()); |
| 1975 | 1975 | defer tracy.end(); |
| 1976 | 1976 | |
| ... | ... | @@ -1988,7 +1988,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 1988 | 1988 | }); |
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 1991 | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1992 | 1992 | const tracy = trace(@src()); |
| 1993 | 1993 | defer tracy.end(); |
| 1994 | 1994 | |
| ... | ... | @@ -2014,7 +2014,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 2014 | 2014 | return block.addUnOp(src, Type.initTag(.u16), .error_to_int, op_coerced); |
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2017 | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2018 | 2018 | const tracy = trace(@src()); |
| 2019 | 2019 | defer tracy.end(); |
| 2020 | 2020 | |
| ... | ... | @@ -2047,12 +2047,12 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 2047 | 2047 | return block.addUnOp(src, Type.initTag(.anyerror), .int_to_error, op); |
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2050 | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2051 | 2051 | const tracy = trace(@src()); |
| 2052 | 2052 | defer tracy.end(); |
| 2053 | 2053 | |
| 2054 | 2054 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2055 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2055 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2056 | 2056 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 2057 | 2057 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 2058 | 2058 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| ... | ... | @@ -2126,7 +2126,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inn |
| 2126 | 2126 | }); |
| 2127 | 2127 | } |
| 2128 | 2128 | |
| 2129 | | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2129 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2130 | 2130 | const tracy = trace(@src()); |
| 2131 | 2131 | defer tracy.end(); |
| 2132 | 2132 | |
| ... | ... | @@ -2139,7 +2139,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 2139 | 2139 | }); |
| 2140 | 2140 | } |
| 2141 | 2141 | |
| 2142 | | fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2142 | fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2143 | 2143 | const tracy = trace(@src()); |
| 2144 | 2144 | defer tracy.end(); |
| 2145 | 2145 | |
| ... | ... | @@ -2152,7 +2152,7 @@ fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) I |
| 2152 | 2152 | }); |
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2155 | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2156 | 2156 | const mod = sema.mod; |
| 2157 | 2157 | const arena = sema.arena; |
| 2158 | 2158 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| ... | ... | @@ -2234,12 +2234,12 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2234 | 2234 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); |
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2237 | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2238 | 2238 | const mod = sema.mod; |
| 2239 | 2239 | const target = mod.getTarget(); |
| 2240 | 2240 | const arena = sema.arena; |
| 2241 | 2241 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2242 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2242 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2243 | 2243 | const src = inst_data.src(); |
| 2244 | 2244 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2245 | 2245 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| ... | ... | @@ -2293,7 +2293,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2293 | 2293 | fn zirOptionalPayloadPtr( |
| 2294 | 2294 | sema: *Sema, |
| 2295 | 2295 | block: *Scope.Block, |
| 2296 | | inst: zir.Inst.Index, |
| 2296 | inst: Zir.Inst.Index, |
| 2297 | 2297 | safety_check: bool, |
| 2298 | 2298 | ) InnerError!*Inst { |
| 2299 | 2299 | const tracy = trace(@src()); |
| ... | ... | @@ -2336,7 +2336,7 @@ fn zirOptionalPayloadPtr( |
| 2336 | 2336 | fn zirOptionalPayload( |
| 2337 | 2337 | sema: *Sema, |
| 2338 | 2338 | block: *Scope.Block, |
| 2339 | | inst: zir.Inst.Index, |
| 2339 | inst: Zir.Inst.Index, |
| 2340 | 2340 | safety_check: bool, |
| 2341 | 2341 | ) InnerError!*Inst { |
| 2342 | 2342 | const tracy = trace(@src()); |
| ... | ... | @@ -2374,7 +2374,7 @@ fn zirOptionalPayload( |
| 2374 | 2374 | fn zirErrUnionPayload( |
| 2375 | 2375 | sema: *Sema, |
| 2376 | 2376 | block: *Scope.Block, |
| 2377 | | inst: zir.Inst.Index, |
| 2377 | inst: Zir.Inst.Index, |
| 2378 | 2378 | safety_check: bool, |
| 2379 | 2379 | ) InnerError!*Inst { |
| 2380 | 2380 | const tracy = trace(@src()); |
| ... | ... | @@ -2408,7 +2408,7 @@ fn zirErrUnionPayload( |
| 2408 | 2408 | fn zirErrUnionPayloadPtr( |
| 2409 | 2409 | sema: *Sema, |
| 2410 | 2410 | block: *Scope.Block, |
| 2411 | | inst: zir.Inst.Index, |
| 2411 | inst: Zir.Inst.Index, |
| 2412 | 2412 | safety_check: bool, |
| 2413 | 2413 | ) InnerError!*Inst { |
| 2414 | 2414 | const tracy = trace(@src()); |
| ... | ... | @@ -2449,7 +2449,7 @@ fn zirErrUnionPayloadPtr( |
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | 2451 | /// Value in, value out |
| 2452 | | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2452 | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2453 | 2453 | const tracy = trace(@src()); |
| 2454 | 2454 | defer tracy.end(); |
| 2455 | 2455 | |
| ... | ... | @@ -2473,7 +2473,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | 2475 | /// Pointer in, value out |
| 2476 | | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2476 | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2477 | 2477 | const tracy = trace(@src()); |
| 2478 | 2478 | defer tracy.end(); |
| 2479 | 2479 | |
| ... | ... | @@ -2499,7 +2499,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 2499 | 2499 | return block.addUnOp(src, operand.ty.castTag(.error_union).?.data.payload, .unwrap_errunion_err_ptr, operand); |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | | fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void { |
| 2502 | fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 2503 | 2503 | const tracy = trace(@src()); |
| 2504 | 2504 | defer tracy.end(); |
| 2505 | 2505 | |
| ... | ... | @@ -2513,13 +2513,13 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde |
| 2513 | 2513 | } |
| 2514 | 2514 | } |
| 2515 | 2515 | |
| 2516 | | fn zirFnType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: bool) InnerError!*Inst { |
| 2516 | fn zirFnType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, var_args: bool) InnerError!*Inst { |
| 2517 | 2517 | const tracy = trace(@src()); |
| 2518 | 2518 | defer tracy.end(); |
| 2519 | 2519 | |
| 2520 | 2520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2521 | 2521 | const src = inst_data.src(); |
| 2522 | | const extra = sema.code.extraData(zir.Inst.FnType, inst_data.payload_index); |
| 2522 | const extra = sema.code.extraData(Zir.Inst.FnType, inst_data.payload_index); |
| 2523 | 2523 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); |
| 2524 | 2524 | |
| 2525 | 2525 | return sema.fnTypeCommon( |
| ... | ... | @@ -2532,14 +2532,14 @@ fn zirFnType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: b |
| 2532 | 2532 | ); |
| 2533 | 2533 | } |
| 2534 | 2534 | |
| 2535 | | fn zirFnTypeCc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: bool) InnerError!*Inst { |
| 2535 | fn zirFnTypeCc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, var_args: bool) InnerError!*Inst { |
| 2536 | 2536 | const tracy = trace(@src()); |
| 2537 | 2537 | defer tracy.end(); |
| 2538 | 2538 | |
| 2539 | 2539 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2540 | 2540 | const src = inst_data.src(); |
| 2541 | 2541 | const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = inst_data.src_node }; |
| 2542 | | const extra = sema.code.extraData(zir.Inst.FnTypeCc, inst_data.payload_index); |
| 2542 | const extra = sema.code.extraData(Zir.Inst.FnTypeCc, inst_data.payload_index); |
| 2543 | 2543 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); |
| 2544 | 2544 | |
| 2545 | 2545 | const cc_tv = try sema.resolveInstConst(block, cc_src, extra.data.cc); |
| ... | ... | @@ -2562,8 +2562,8 @@ fn fnTypeCommon( |
| 2562 | 2562 | sema: *Sema, |
| 2563 | 2563 | block: *Scope.Block, |
| 2564 | 2564 | src_node_offset: i32, |
| 2565 | | zir_param_types: []const zir.Inst.Ref, |
| 2566 | | zir_return_type: zir.Inst.Ref, |
| 2565 | zir_param_types: []const Zir.Inst.Ref, |
| 2566 | zir_return_type: Zir.Inst.Ref, |
| 2567 | 2567 | cc: std.builtin.CallingConvention, |
| 2568 | 2568 | var_args: bool, |
| 2569 | 2569 | ) InnerError!*Inst { |
| ... | ... | @@ -2608,7 +2608,7 @@ fn fnTypeCommon( |
| 2608 | 2608 | return sema.mod.constType(sema.arena, src, fn_ty); |
| 2609 | 2609 | } |
| 2610 | 2610 | |
| 2611 | | fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2611 | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2612 | 2612 | const tracy = trace(@src()); |
| 2613 | 2613 | defer tracy.end(); |
| 2614 | 2614 | |
| ... | ... | @@ -2616,13 +2616,13 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Ins |
| 2616 | 2616 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); |
| 2617 | 2617 | } |
| 2618 | 2618 | |
| 2619 | | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2619 | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2620 | 2620 | const tracy = trace(@src()); |
| 2621 | 2621 | defer tracy.end(); |
| 2622 | 2622 | |
| 2623 | 2623 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2624 | 2624 | const src = inst_data.src(); |
| 2625 | | const extra = sema.code.extraData(zir.Inst.As, inst_data.payload_index).data; |
| 2625 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| 2626 | 2626 | return sema.analyzeAs(block, src, extra.dest_type, extra.operand); |
| 2627 | 2627 | } |
| 2628 | 2628 | |
| ... | ... | @@ -2630,15 +2630,15 @@ fn analyzeAs( |
| 2630 | 2630 | sema: *Sema, |
| 2631 | 2631 | block: *Scope.Block, |
| 2632 | 2632 | src: LazySrcLoc, |
| 2633 | | zir_dest_type: zir.Inst.Ref, |
| 2634 | | zir_operand: zir.Inst.Ref, |
| 2633 | zir_dest_type: Zir.Inst.Ref, |
| 2634 | zir_operand: Zir.Inst.Ref, |
| 2635 | 2635 | ) InnerError!*Inst { |
| 2636 | 2636 | const dest_type = try sema.resolveType(block, src, zir_dest_type); |
| 2637 | 2637 | const operand = try sema.resolveInst(zir_operand); |
| 2638 | 2638 | return sema.coerce(block, dest_type, operand, src); |
| 2639 | 2639 | } |
| 2640 | 2640 | |
| 2641 | | fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2641 | fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2642 | 2642 | const tracy = trace(@src()); |
| 2643 | 2643 | defer tracy.end(); |
| 2644 | 2644 | |
| ... | ... | @@ -2655,14 +2655,14 @@ fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2655 | 2655 | return block.addUnOp(src, ty, .ptrtoint, ptr); |
| 2656 | 2656 | } |
| 2657 | 2657 | |
| 2658 | | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2658 | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2659 | 2659 | const tracy = trace(@src()); |
| 2660 | 2660 | defer tracy.end(); |
| 2661 | 2661 | |
| 2662 | 2662 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2663 | 2663 | const src = inst_data.src(); |
| 2664 | 2664 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 2665 | | const extra = sema.code.extraData(zir.Inst.Field, inst_data.payload_index).data; |
| 2665 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 2666 | 2666 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 2667 | 2667 | const object = try sema.resolveInst(extra.lhs); |
| 2668 | 2668 | const object_ptr = if (object.ty.zigTypeTag() == .Pointer) |
| ... | ... | @@ -2673,27 +2673,27 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2673 | 2673 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); |
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2676 | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2677 | 2677 | const tracy = trace(@src()); |
| 2678 | 2678 | defer tracy.end(); |
| 2679 | 2679 | |
| 2680 | 2680 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2681 | 2681 | const src = inst_data.src(); |
| 2682 | 2682 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 2683 | | const extra = sema.code.extraData(zir.Inst.Field, inst_data.payload_index).data; |
| 2683 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 2684 | 2684 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 2685 | 2685 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 2686 | 2686 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 2687 | 2687 | } |
| 2688 | 2688 | |
| 2689 | | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2689 | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2690 | 2690 | const tracy = trace(@src()); |
| 2691 | 2691 | defer tracy.end(); |
| 2692 | 2692 | |
| 2693 | 2693 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2694 | 2694 | const src = inst_data.src(); |
| 2695 | 2695 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2696 | | const extra = sema.code.extraData(zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 2696 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 2697 | 2697 | const object = try sema.resolveInst(extra.lhs); |
| 2698 | 2698 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 2699 | 2699 | const object_ptr = try sema.analyzeRef(block, src, object); |
| ... | ... | @@ -2701,20 +2701,20 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 2701 | 2701 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2704 | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2705 | 2705 | const tracy = trace(@src()); |
| 2706 | 2706 | defer tracy.end(); |
| 2707 | 2707 | |
| 2708 | 2708 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2709 | 2709 | const src = inst_data.src(); |
| 2710 | 2710 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2711 | | const extra = sema.code.extraData(zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 2711 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 2712 | 2712 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 2713 | 2713 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 2714 | 2714 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 2715 | 2715 | } |
| 2716 | 2716 | |
| 2717 | | fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2717 | fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2718 | 2718 | const tracy = trace(@src()); |
| 2719 | 2719 | defer tracy.end(); |
| 2720 | 2720 | |
| ... | ... | @@ -2722,7 +2722,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2722 | 2722 | const src = inst_data.src(); |
| 2723 | 2723 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2724 | 2724 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2725 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2725 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2726 | 2726 | |
| 2727 | 2727 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2728 | 2728 | const operand = try sema.resolveInst(extra.rhs); |
| ... | ... | @@ -2757,7 +2757,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2757 | 2757 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); |
| 2758 | 2758 | } |
| 2759 | 2759 | |
| 2760 | | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2760 | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2761 | 2761 | const tracy = trace(@src()); |
| 2762 | 2762 | defer tracy.end(); |
| 2763 | 2763 | |
| ... | ... | @@ -2765,14 +2765,14 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2765 | 2765 | const src = inst_data.src(); |
| 2766 | 2766 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2767 | 2767 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2768 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2768 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2769 | 2769 | |
| 2770 | 2770 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2771 | 2771 | const operand = try sema.resolveInst(extra.rhs); |
| 2772 | 2772 | return sema.bitcast(block, dest_type, operand); |
| 2773 | 2773 | } |
| 2774 | 2774 | |
| 2775 | | fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2775 | fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2776 | 2776 | const tracy = trace(@src()); |
| 2777 | 2777 | defer tracy.end(); |
| 2778 | 2778 | |
| ... | ... | @@ -2780,7 +2780,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2780 | 2780 | const src = inst_data.src(); |
| 2781 | 2781 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2782 | 2782 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2783 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2783 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2784 | 2784 | |
| 2785 | 2785 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2786 | 2786 | const operand = try sema.resolveInst(extra.rhs); |
| ... | ... | @@ -2815,7 +2815,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2815 | 2815 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); |
| 2816 | 2816 | } |
| 2817 | 2817 | |
| 2818 | | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2818 | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2819 | 2819 | const tracy = trace(@src()); |
| 2820 | 2820 | defer tracy.end(); |
| 2821 | 2821 | |
| ... | ... | @@ -2830,14 +2830,14 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2830 | 2830 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); |
| 2831 | 2831 | } |
| 2832 | 2832 | |
| 2833 | | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2833 | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2834 | 2834 | const tracy = trace(@src()); |
| 2835 | 2835 | defer tracy.end(); |
| 2836 | 2836 | |
| 2837 | 2837 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2838 | 2838 | const src = inst_data.src(); |
| 2839 | 2839 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 2840 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2840 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2841 | 2841 | const array = try sema.resolveInst(extra.lhs); |
| 2842 | 2842 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) |
| 2843 | 2843 | array |
| ... | ... | @@ -2848,7 +2848,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 2848 | 2848 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2851 | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2852 | 2852 | const tracy = trace(@src()); |
| 2853 | 2853 | defer tracy.end(); |
| 2854 | 2854 | |
| ... | ... | @@ -2858,39 +2858,39 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2858 | 2858 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 2859 | 2859 | } |
| 2860 | 2860 | |
| 2861 | | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2861 | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2862 | 2862 | const tracy = trace(@src()); |
| 2863 | 2863 | defer tracy.end(); |
| 2864 | 2864 | |
| 2865 | 2865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2866 | 2866 | const src = inst_data.src(); |
| 2867 | 2867 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 2868 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 2868 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 2869 | 2869 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2870 | 2870 | const elem_index = try sema.resolveInst(extra.rhs); |
| 2871 | 2871 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 2872 | 2872 | } |
| 2873 | 2873 | |
| 2874 | | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2874 | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2875 | 2875 | const tracy = trace(@src()); |
| 2876 | 2876 | defer tracy.end(); |
| 2877 | 2877 | |
| 2878 | 2878 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2879 | 2879 | const src = inst_data.src(); |
| 2880 | | const extra = sema.code.extraData(zir.Inst.SliceStart, inst_data.payload_index).data; |
| 2880 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| 2881 | 2881 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2882 | 2882 | const start = try sema.resolveInst(extra.start); |
| 2883 | 2883 | |
| 2884 | 2884 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); |
| 2885 | 2885 | } |
| 2886 | 2886 | |
| 2887 | | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2887 | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2888 | 2888 | const tracy = trace(@src()); |
| 2889 | 2889 | defer tracy.end(); |
| 2890 | 2890 | |
| 2891 | 2891 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2892 | 2892 | const src = inst_data.src(); |
| 2893 | | const extra = sema.code.extraData(zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 2893 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 2894 | 2894 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2895 | 2895 | const start = try sema.resolveInst(extra.start); |
| 2896 | 2896 | const end = try sema.resolveInst(extra.end); |
| ... | ... | @@ -2898,14 +2898,14 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2898 | 2898 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); |
| 2899 | 2899 | } |
| 2900 | 2900 | |
| 2901 | | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 2901 | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 2902 | 2902 | const tracy = trace(@src()); |
| 2903 | 2903 | defer tracy.end(); |
| 2904 | 2904 | |
| 2905 | 2905 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2906 | 2906 | const src = inst_data.src(); |
| 2907 | 2907 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; |
| 2908 | | const extra = sema.code.extraData(zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 2908 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 2909 | 2909 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2910 | 2910 | const start = try sema.resolveInst(extra.start); |
| 2911 | 2911 | const end = try sema.resolveInst(extra.end); |
| ... | ... | @@ -2917,7 +2917,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 2917 | 2917 | fn zirSwitchCapture( |
| 2918 | 2918 | sema: *Sema, |
| 2919 | 2919 | block: *Scope.Block, |
| 2920 | | inst: zir.Inst.Index, |
| 2920 | inst: Zir.Inst.Index, |
| 2921 | 2921 | is_multi: bool, |
| 2922 | 2922 | is_ref: bool, |
| 2923 | 2923 | ) InnerError!*Inst { |
| ... | ... | @@ -2935,7 +2935,7 @@ fn zirSwitchCapture( |
| 2935 | 2935 | fn zirSwitchCaptureElse( |
| 2936 | 2936 | sema: *Sema, |
| 2937 | 2937 | block: *Scope.Block, |
| 2938 | | inst: zir.Inst.Index, |
| 2938 | inst: Zir.Inst.Index, |
| 2939 | 2939 | is_ref: bool, |
| 2940 | 2940 | ) InnerError!*Inst { |
| 2941 | 2941 | const tracy = trace(@src()); |
| ... | ... | @@ -2952,9 +2952,9 @@ fn zirSwitchCaptureElse( |
| 2952 | 2952 | fn zirSwitchBlock( |
| 2953 | 2953 | sema: *Sema, |
| 2954 | 2954 | block: *Scope.Block, |
| 2955 | | inst: zir.Inst.Index, |
| 2955 | inst: Zir.Inst.Index, |
| 2956 | 2956 | is_ref: bool, |
| 2957 | | special_prong: zir.SpecialProng, |
| 2957 | special_prong: Zir.SpecialProng, |
| 2958 | 2958 | ) InnerError!*Inst { |
| 2959 | 2959 | const tracy = trace(@src()); |
| 2960 | 2960 | defer tracy.end(); |
| ... | ... | @@ -2962,7 +2962,7 @@ fn zirSwitchBlock( |
| 2962 | 2962 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2963 | 2963 | const src = inst_data.src(); |
| 2964 | 2964 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; |
| 2965 | | const extra = sema.code.extraData(zir.Inst.SwitchBlock, inst_data.payload_index); |
| 2965 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); |
| 2966 | 2966 | |
| 2967 | 2967 | const operand_ptr = try sema.resolveInst(extra.data.operand); |
| 2968 | 2968 | const operand = if (is_ref) |
| ... | ... | @@ -2985,9 +2985,9 @@ fn zirSwitchBlock( |
| 2985 | 2985 | fn zirSwitchBlockMulti( |
| 2986 | 2986 | sema: *Sema, |
| 2987 | 2987 | block: *Scope.Block, |
| 2988 | | inst: zir.Inst.Index, |
| 2988 | inst: Zir.Inst.Index, |
| 2989 | 2989 | is_ref: bool, |
| 2990 | | special_prong: zir.SpecialProng, |
| 2990 | special_prong: Zir.SpecialProng, |
| 2991 | 2991 | ) InnerError!*Inst { |
| 2992 | 2992 | const tracy = trace(@src()); |
| 2993 | 2993 | defer tracy.end(); |
| ... | ... | @@ -2995,7 +2995,7 @@ fn zirSwitchBlockMulti( |
| 2995 | 2995 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2996 | 2996 | const src = inst_data.src(); |
| 2997 | 2997 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; |
| 2998 | | const extra = sema.code.extraData(zir.Inst.SwitchBlockMulti, inst_data.payload_index); |
| 2998 | const extra = sema.code.extraData(Zir.Inst.SwitchBlockMulti, inst_data.payload_index); |
| 2999 | 2999 | |
| 3000 | 3000 | const operand_ptr = try sema.resolveInst(extra.data.operand); |
| 3001 | 3001 | const operand = if (is_ref) |
| ... | ... | @@ -3020,16 +3020,16 @@ fn analyzeSwitch( |
| 3020 | 3020 | block: *Scope.Block, |
| 3021 | 3021 | operand: *Inst, |
| 3022 | 3022 | extra_end: usize, |
| 3023 | | special_prong: zir.SpecialProng, |
| 3023 | special_prong: Zir.SpecialProng, |
| 3024 | 3024 | scalar_cases_len: usize, |
| 3025 | 3025 | multi_cases_len: usize, |
| 3026 | | switch_inst: zir.Inst.Index, |
| 3026 | switch_inst: Zir.Inst.Index, |
| 3027 | 3027 | src_node_offset: i32, |
| 3028 | 3028 | ) InnerError!*Inst { |
| 3029 | 3029 | const gpa = sema.gpa; |
| 3030 | 3030 | const mod = sema.mod; |
| 3031 | 3031 | |
| 3032 | | const special: struct { body: []const zir.Inst.Index, end: usize } = switch (special_prong) { |
| 3032 | const special: struct { body: []const Zir.Inst.Index, end: usize } = switch (special_prong) { |
| 3033 | 3033 | .none => .{ .body = &.{}, .end = extra_end }, |
| 3034 | 3034 | .under, .@"else" => blk: { |
| 3035 | 3035 | const body_len = sema.code.extra[extra_end]; |
| ... | ... | @@ -3079,7 +3079,7 @@ fn analyzeSwitch( |
| 3079 | 3079 | { |
| 3080 | 3080 | var scalar_i: u32 = 0; |
| 3081 | 3081 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3082 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3082 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3083 | 3083 | extra_index += 1; |
| 3084 | 3084 | const body_len = sema.code.extra[extra_index]; |
| 3085 | 3085 | extra_index += 1; |
| ... | ... | @@ -3189,7 +3189,7 @@ fn analyzeSwitch( |
| 3189 | 3189 | { |
| 3190 | 3190 | var scalar_i: u32 = 0; |
| 3191 | 3191 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3192 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3192 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3193 | 3193 | extra_index += 1; |
| 3194 | 3194 | const body_len = sema.code.extra[extra_index]; |
| 3195 | 3195 | extra_index += 1; |
| ... | ... | @@ -3229,9 +3229,9 @@ fn analyzeSwitch( |
| 3229 | 3229 | |
| 3230 | 3230 | var range_i: u32 = 0; |
| 3231 | 3231 | while (range_i < ranges_len) : (range_i += 1) { |
| 3232 | | const item_first = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3232 | const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3233 | 3233 | extra_index += 1; |
| 3234 | | const item_last = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3234 | const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3235 | 3235 | extra_index += 1; |
| 3236 | 3236 | |
| 3237 | 3237 | try sema.validateSwitchRange( |
| ... | ... | @@ -3285,7 +3285,7 @@ fn analyzeSwitch( |
| 3285 | 3285 | { |
| 3286 | 3286 | var scalar_i: u32 = 0; |
| 3287 | 3287 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3288 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3288 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3289 | 3289 | extra_index += 1; |
| 3290 | 3290 | const body_len = sema.code.extra[extra_index]; |
| 3291 | 3291 | extra_index += 1; |
| ... | ... | @@ -3368,7 +3368,7 @@ fn analyzeSwitch( |
| 3368 | 3368 | { |
| 3369 | 3369 | var scalar_i: u32 = 0; |
| 3370 | 3370 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3371 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3371 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3372 | 3372 | extra_index += 1; |
| 3373 | 3373 | const body_len = sema.code.extra[extra_index]; |
| 3374 | 3374 | extra_index += 1; |
| ... | ... | @@ -3435,7 +3435,7 @@ fn analyzeSwitch( |
| 3435 | 3435 | { |
| 3436 | 3436 | var scalar_i: usize = 0; |
| 3437 | 3437 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3438 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3438 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3439 | 3439 | extra_index += 1; |
| 3440 | 3440 | const body_len = sema.code.extra[extra_index]; |
| 3441 | 3441 | extra_index += 1; |
| ... | ... | @@ -3474,9 +3474,9 @@ fn analyzeSwitch( |
| 3474 | 3474 | |
| 3475 | 3475 | var range_i: usize = 0; |
| 3476 | 3476 | while (range_i < ranges_len) : (range_i += 1) { |
| 3477 | | const item_first = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3477 | const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3478 | 3478 | extra_index += 1; |
| 3479 | | const item_last = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3479 | const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3480 | 3480 | extra_index += 1; |
| 3481 | 3481 | |
| 3482 | 3482 | // Validation above ensured these will succeed. |
| ... | ... | @@ -3544,7 +3544,7 @@ fn analyzeSwitch( |
| 3544 | 3544 | |
| 3545 | 3545 | var scalar_i: usize = 0; |
| 3546 | 3546 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { |
| 3547 | | const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3547 | const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3548 | 3548 | extra_index += 1; |
| 3549 | 3549 | const body_len = sema.code.extra[extra_index]; |
| 3550 | 3550 | extra_index += 1; |
| ... | ... | @@ -3597,9 +3597,9 @@ fn analyzeSwitch( |
| 3597 | 3597 | |
| 3598 | 3598 | var range_i: usize = 0; |
| 3599 | 3599 | while (range_i < ranges_len) : (range_i += 1) { |
| 3600 | | const first_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3600 | const first_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3601 | 3601 | extra_index += 1; |
| 3602 | | const last_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3602 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 3603 | 3603 | extra_index += 1; |
| 3604 | 3604 | |
| 3605 | 3605 | const item_first = try sema.resolveInst(first_ref); |
| ... | ... | @@ -3696,7 +3696,7 @@ fn analyzeSwitch( |
| 3696 | 3696 | fn resolveSwitchItemVal( |
| 3697 | 3697 | sema: *Sema, |
| 3698 | 3698 | block: *Scope.Block, |
| 3699 | | item_ref: zir.Inst.Ref, |
| 3699 | item_ref: Zir.Inst.Ref, |
| 3700 | 3700 | switch_node_offset: i32, |
| 3701 | 3701 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3702 | 3702 | range_expand: AstGen.SwitchProngSrc.RangeExpand, |
| ... | ... | @@ -3720,8 +3720,8 @@ fn validateSwitchRange( |
| 3720 | 3720 | sema: *Sema, |
| 3721 | 3721 | block: *Scope.Block, |
| 3722 | 3722 | range_set: *RangeSet, |
| 3723 | | first_ref: zir.Inst.Ref, |
| 3724 | | last_ref: zir.Inst.Ref, |
| 3723 | first_ref: Zir.Inst.Ref, |
| 3724 | last_ref: Zir.Inst.Ref, |
| 3725 | 3725 | src_node_offset: i32, |
| 3726 | 3726 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3727 | 3727 | ) InnerError!void { |
| ... | ... | @@ -3735,7 +3735,7 @@ fn validateSwitchItem( |
| 3735 | 3735 | sema: *Sema, |
| 3736 | 3736 | block: *Scope.Block, |
| 3737 | 3737 | range_set: *RangeSet, |
| 3738 | | item_ref: zir.Inst.Ref, |
| 3738 | item_ref: Zir.Inst.Ref, |
| 3739 | 3739 | src_node_offset: i32, |
| 3740 | 3740 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3741 | 3741 | ) InnerError!void { |
| ... | ... | @@ -3748,7 +3748,7 @@ fn validateSwitchItemEnum( |
| 3748 | 3748 | sema: *Sema, |
| 3749 | 3749 | block: *Scope.Block, |
| 3750 | 3750 | seen_fields: []?AstGen.SwitchProngSrc, |
| 3751 | | item_ref: zir.Inst.Ref, |
| 3751 | item_ref: Zir.Inst.Ref, |
| 3752 | 3752 | src_node_offset: i32, |
| 3753 | 3753 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3754 | 3754 | ) InnerError!void { |
| ... | ... | @@ -3815,7 +3815,7 @@ fn validateSwitchItemBool( |
| 3815 | 3815 | block: *Scope.Block, |
| 3816 | 3816 | true_count: *u8, |
| 3817 | 3817 | false_count: *u8, |
| 3818 | | item_ref: zir.Inst.Ref, |
| 3818 | item_ref: Zir.Inst.Ref, |
| 3819 | 3819 | src_node_offset: i32, |
| 3820 | 3820 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3821 | 3821 | ) InnerError!void { |
| ... | ... | @@ -3837,7 +3837,7 @@ fn validateSwitchItemSparse( |
| 3837 | 3837 | sema: *Sema, |
| 3838 | 3838 | block: *Scope.Block, |
| 3839 | 3839 | seen_values: *ValueSrcMap, |
| 3840 | | item_ref: zir.Inst.Ref, |
| 3840 | item_ref: Zir.Inst.Ref, |
| 3841 | 3841 | src_node_offset: i32, |
| 3842 | 3842 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3843 | 3843 | ) InnerError!void { |
| ... | ... | @@ -3879,12 +3879,12 @@ fn validateSwitchNoRange( |
| 3879 | 3879 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); |
| 3880 | 3880 | } |
| 3881 | 3881 | |
| 3882 | | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 3882 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 3883 | 3883 | const tracy = trace(@src()); |
| 3884 | 3884 | defer tracy.end(); |
| 3885 | 3885 | |
| 3886 | 3886 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3887 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 3887 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3888 | 3888 | const src = inst_data.src(); |
| 3889 | 3889 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 3890 | 3890 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| ... | ... | @@ -3907,7 +3907,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 3907 | 3907 | return mod.constBool(arena, src, false); |
| 3908 | 3908 | } |
| 3909 | 3909 | |
| 3910 | | fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 3910 | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 3911 | 3911 | const tracy = trace(@src()); |
| 3912 | 3912 | defer tracy.end(); |
| 3913 | 3913 | |
| ... | ... | @@ -3933,13 +3933,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 3933 | 3933 | return mod.constType(sema.arena, src, file.namespace.ty); |
| 3934 | 3934 | } |
| 3935 | 3935 | |
| 3936 | | fn zirShl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 3936 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 3937 | 3937 | const tracy = trace(@src()); |
| 3938 | 3938 | defer tracy.end(); |
| 3939 | 3939 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); |
| 3940 | 3940 | } |
| 3941 | 3941 | |
| 3942 | | fn zirShr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 3942 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 3943 | 3943 | const tracy = trace(@src()); |
| 3944 | 3944 | defer tracy.end(); |
| 3945 | 3945 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{}); |
| ... | ... | @@ -3948,7 +3948,7 @@ fn zirShr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 3948 | 3948 | fn zirBitwise( |
| 3949 | 3949 | sema: *Sema, |
| 3950 | 3950 | block: *Scope.Block, |
| 3951 | | inst: zir.Inst.Index, |
| 3951 | inst: Zir.Inst.Index, |
| 3952 | 3952 | ir_tag: ir.Inst.Tag, |
| 3953 | 3953 | ) InnerError!*Inst { |
| 3954 | 3954 | const tracy = trace(@src()); |
| ... | ... | @@ -3958,7 +3958,7 @@ fn zirBitwise( |
| 3958 | 3958 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 3959 | 3959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 3960 | 3960 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 3961 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 3961 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3962 | 3962 | const lhs = try sema.resolveInst(extra.lhs); |
| 3963 | 3963 | const rhs = try sema.resolveInst(extra.rhs); |
| 3964 | 3964 | |
| ... | ... | @@ -4011,19 +4011,19 @@ fn zirBitwise( |
| 4011 | 4011 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 4012 | 4012 | } |
| 4013 | 4013 | |
| 4014 | | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4014 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4015 | 4015 | const tracy = trace(@src()); |
| 4016 | 4016 | defer tracy.end(); |
| 4017 | 4017 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); |
| 4018 | 4018 | } |
| 4019 | 4019 | |
| 4020 | | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4020 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4021 | 4021 | const tracy = trace(@src()); |
| 4022 | 4022 | defer tracy.end(); |
| 4023 | 4023 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); |
| 4024 | 4024 | } |
| 4025 | 4025 | |
| 4026 | | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4026 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4027 | 4027 | const tracy = trace(@src()); |
| 4028 | 4028 | defer tracy.end(); |
| 4029 | 4029 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{}); |
| ... | ... | @@ -4032,8 +4032,8 @@ fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 4032 | 4032 | fn zirNegate( |
| 4033 | 4033 | sema: *Sema, |
| 4034 | 4034 | block: *Scope.Block, |
| 4035 | | inst: zir.Inst.Index, |
| 4036 | | tag_override: zir.Inst.Tag, |
| 4035 | inst: Zir.Inst.Index, |
| 4036 | tag_override: Zir.Inst.Tag, |
| 4037 | 4037 | ) InnerError!*Inst { |
| 4038 | 4038 | const tracy = trace(@src()); |
| 4039 | 4039 | defer tracy.end(); |
| ... | ... | @@ -4048,7 +4048,7 @@ fn zirNegate( |
| 4048 | 4048 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); |
| 4049 | 4049 | } |
| 4050 | 4050 | |
| 4051 | | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4051 | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4052 | 4052 | const tracy = trace(@src()); |
| 4053 | 4053 | defer tracy.end(); |
| 4054 | 4054 | |
| ... | ... | @@ -4057,7 +4057,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4057 | 4057 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 4058 | 4058 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4059 | 4059 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 4060 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 4060 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4061 | 4061 | const lhs = try sema.resolveInst(extra.lhs); |
| 4062 | 4062 | const rhs = try sema.resolveInst(extra.rhs); |
| 4063 | 4063 | |
| ... | ... | @@ -4067,7 +4067,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4067 | 4067 | fn analyzeArithmetic( |
| 4068 | 4068 | sema: *Sema, |
| 4069 | 4069 | block: *Scope.Block, |
| 4070 | | zir_tag: zir.Inst.Tag, |
| 4070 | zir_tag: Zir.Inst.Tag, |
| 4071 | 4071 | lhs: *Inst, |
| 4072 | 4072 | rhs: *Inst, |
| 4073 | 4073 | src: LazySrcLoc, |
| ... | ... | @@ -4174,7 +4174,7 @@ fn analyzeArithmetic( |
| 4174 | 4174 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 4175 | 4175 | } |
| 4176 | 4176 | |
| 4177 | | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4177 | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4178 | 4178 | const tracy = trace(@src()); |
| 4179 | 4179 | defer tracy.end(); |
| 4180 | 4180 | |
| ... | ... | @@ -4188,7 +4188,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*I |
| 4188 | 4188 | fn zirAsm( |
| 4189 | 4189 | sema: *Sema, |
| 4190 | 4190 | block: *Scope.Block, |
| 4191 | | inst: zir.Inst.Index, |
| 4191 | inst: Zir.Inst.Index, |
| 4192 | 4192 | is_volatile: bool, |
| 4193 | 4193 | ) InnerError!*Inst { |
| 4194 | 4194 | const tracy = trace(@src()); |
| ... | ... | @@ -4198,7 +4198,7 @@ fn zirAsm( |
| 4198 | 4198 | const src = inst_data.src(); |
| 4199 | 4199 | const asm_source_src: LazySrcLoc = .{ .node_offset_asm_source = inst_data.src_node }; |
| 4200 | 4200 | const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = inst_data.src_node }; |
| 4201 | | const extra = sema.code.extraData(zir.Inst.Asm, inst_data.payload_index); |
| 4201 | const extra = sema.code.extraData(Zir.Inst.Asm, inst_data.payload_index); |
| 4202 | 4202 | const return_type = try sema.resolveType(block, ret_ty_src, extra.data.return_type); |
| 4203 | 4203 | const asm_source = try sema.resolveConstString(block, asm_source_src, extra.data.asm_source); |
| 4204 | 4204 | |
| ... | ... | @@ -4218,7 +4218,7 @@ fn zirAsm( |
| 4218 | 4218 | const clobbers = try sema.arena.alloc([]const u8, extra.data.clobbers_len); |
| 4219 | 4219 | |
| 4220 | 4220 | for (args) |*arg| { |
| 4221 | | arg.* = try sema.resolveInst(@intToEnum(zir.Inst.Ref, sema.code.extra[extra_i])); |
| 4221 | arg.* = try sema.resolveInst(@intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i])); |
| 4222 | 4222 | extra_i += 1; |
| 4223 | 4223 | } |
| 4224 | 4224 | for (inputs) |*name| { |
| ... | ... | @@ -4253,7 +4253,7 @@ fn zirAsm( |
| 4253 | 4253 | fn zirCmp( |
| 4254 | 4254 | sema: *Sema, |
| 4255 | 4255 | block: *Scope.Block, |
| 4256 | | inst: zir.Inst.Index, |
| 4256 | inst: Zir.Inst.Index, |
| 4257 | 4257 | op: std.math.CompareOperator, |
| 4258 | 4258 | ) InnerError!*Inst { |
| 4259 | 4259 | const tracy = trace(@src()); |
| ... | ... | @@ -4262,7 +4262,7 @@ fn zirCmp( |
| 4262 | 4262 | const mod = sema.mod; |
| 4263 | 4263 | |
| 4264 | 4264 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4265 | | const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data; |
| 4265 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4266 | 4266 | const src: LazySrcLoc = inst_data.src(); |
| 4267 | 4267 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4268 | 4268 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| ... | ... | @@ -4356,7 +4356,7 @@ fn zirCmp( |
| 4356 | 4356 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); |
| 4357 | 4357 | } |
| 4358 | 4358 | |
| 4359 | | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4359 | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4360 | 4360 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4361 | 4361 | const src = inst_data.src(); |
| 4362 | 4362 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | ... | @@ -4366,7 +4366,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 4366 | 4366 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); |
| 4367 | 4367 | } |
| 4368 | 4368 | |
| 4369 | | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4369 | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4370 | 4370 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4371 | 4371 | const src = inst_data.src(); |
| 4372 | 4372 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | ... | @@ -4376,20 +4376,20 @@ fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 4376 | 4376 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), bit_size); |
| 4377 | 4377 | } |
| 4378 | 4378 | |
| 4379 | | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4379 | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4380 | 4380 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4381 | 4381 | const src = inst_data.src(); |
| 4382 | 4382 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeInfo", .{}); |
| 4383 | 4383 | } |
| 4384 | 4384 | |
| 4385 | | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4385 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4386 | 4386 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4387 | 4387 | const src = inst_data.src(); |
| 4388 | 4388 | const operand = try sema.resolveInst(inst_data.operand); |
| 4389 | 4389 | return sema.mod.constType(sema.arena, src, operand.ty); |
| 4390 | 4390 | } |
| 4391 | 4391 | |
| 4392 | | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4392 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4393 | 4393 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4394 | 4394 | const src = inst_data.src(); |
| 4395 | 4395 | const operand_ptr = try sema.resolveInst(inst_data.operand); |
| ... | ... | @@ -4397,13 +4397,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4397 | 4397 | return sema.mod.constType(sema.arena, src, elem_ty); |
| 4398 | 4398 | } |
| 4399 | 4399 | |
| 4400 | | fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4400 | fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4401 | 4401 | const tracy = trace(@src()); |
| 4402 | 4402 | defer tracy.end(); |
| 4403 | 4403 | |
| 4404 | 4404 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4405 | 4405 | const src = inst_data.src(); |
| 4406 | | const extra = sema.code.extraData(zir.Inst.MultiOp, inst_data.payload_index); |
| 4406 | const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| 4407 | 4407 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); |
| 4408 | 4408 | |
| 4409 | 4409 | const inst_list = try sema.gpa.alloc(*ir.Inst, extra.data.operands_len); |
| ... | ... | @@ -4417,7 +4417,7 @@ fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4417 | 4417 | return sema.mod.constType(sema.arena, src, result_type); |
| 4418 | 4418 | } |
| 4419 | 4419 | |
| 4420 | | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4420 | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4421 | 4421 | const tracy = trace(@src()); |
| 4422 | 4422 | defer tracy.end(); |
| 4423 | 4423 | |
| ... | ... | @@ -4437,7 +4437,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 4437 | 4437 | fn zirBoolOp( |
| 4438 | 4438 | sema: *Sema, |
| 4439 | 4439 | block: *Scope.Block, |
| 4440 | | inst: zir.Inst.Index, |
| 4440 | inst: Zir.Inst.Index, |
| 4441 | 4441 | comptime is_bool_or: bool, |
| 4442 | 4442 | ) InnerError!*Inst { |
| 4443 | 4443 | const tracy = trace(@src()); |
| ... | ... | @@ -4468,7 +4468,7 @@ fn zirBoolOp( |
| 4468 | 4468 | fn zirBoolBr( |
| 4469 | 4469 | sema: *Sema, |
| 4470 | 4470 | parent_block: *Scope.Block, |
| 4471 | | inst: zir.Inst.Index, |
| 4471 | inst: Zir.Inst.Index, |
| 4472 | 4472 | is_bool_or: bool, |
| 4473 | 4473 | ) InnerError!*Inst { |
| 4474 | 4474 | const tracy = trace(@src()); |
| ... | ... | @@ -4478,7 +4478,7 @@ fn zirBoolBr( |
| 4478 | 4478 | const inst_data = datas[inst].bool_br; |
| 4479 | 4479 | const src: LazySrcLoc = .unneeded; |
| 4480 | 4480 | const lhs = try sema.resolveInst(inst_data.lhs); |
| 4481 | | const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index); |
| 4481 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 4482 | 4482 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 4483 | 4483 | |
| 4484 | 4484 | if (try sema.resolveDefinedValue(parent_block, src, lhs)) |lhs_val| { |
| ... | ... | @@ -4536,7 +4536,7 @@ fn zirBoolBr( |
| 4536 | 4536 | fn zirIsNull( |
| 4537 | 4537 | sema: *Sema, |
| 4538 | 4538 | block: *Scope.Block, |
| 4539 | | inst: zir.Inst.Index, |
| 4539 | inst: Zir.Inst.Index, |
| 4540 | 4540 | invert_logic: bool, |
| 4541 | 4541 | ) InnerError!*Inst { |
| 4542 | 4542 | const tracy = trace(@src()); |
| ... | ... | @@ -4551,7 +4551,7 @@ fn zirIsNull( |
| 4551 | 4551 | fn zirIsNullPtr( |
| 4552 | 4552 | sema: *Sema, |
| 4553 | 4553 | block: *Scope.Block, |
| 4554 | | inst: zir.Inst.Index, |
| 4554 | inst: Zir.Inst.Index, |
| 4555 | 4555 | invert_logic: bool, |
| 4556 | 4556 | ) InnerError!*Inst { |
| 4557 | 4557 | const tracy = trace(@src()); |
| ... | ... | @@ -4564,7 +4564,7 @@ fn zirIsNullPtr( |
| 4564 | 4564 | return sema.analyzeIsNull(block, src, loaded, invert_logic); |
| 4565 | 4565 | } |
| 4566 | 4566 | |
| 4567 | | fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4567 | fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4568 | 4568 | const tracy = trace(@src()); |
| 4569 | 4569 | defer tracy.end(); |
| 4570 | 4570 | |
| ... | ... | @@ -4573,7 +4573,7 @@ fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* |
| 4573 | 4573 | return sema.analyzeIsErr(block, inst_data.src(), operand); |
| 4574 | 4574 | } |
| 4575 | 4575 | |
| 4576 | | fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4576 | fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4577 | 4577 | const tracy = trace(@src()); |
| 4578 | 4578 | defer tracy.end(); |
| 4579 | 4579 | |
| ... | ... | @@ -4587,15 +4587,15 @@ fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 4587 | 4587 | fn zirCondbr( |
| 4588 | 4588 | sema: *Sema, |
| 4589 | 4589 | parent_block: *Scope.Block, |
| 4590 | | inst: zir.Inst.Index, |
| 4591 | | ) InnerError!zir.Inst.Index { |
| 4590 | inst: Zir.Inst.Index, |
| 4591 | ) InnerError!Zir.Inst.Index { |
| 4592 | 4592 | const tracy = trace(@src()); |
| 4593 | 4593 | defer tracy.end(); |
| 4594 | 4594 | |
| 4595 | 4595 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4596 | 4596 | const src = inst_data.src(); |
| 4597 | 4597 | const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node }; |
| 4598 | | const extra = sema.code.extraData(zir.Inst.CondBr, inst_data.payload_index); |
| 4598 | const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index); |
| 4599 | 4599 | |
| 4600 | 4600 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 4601 | 4601 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; |
| ... | ... | @@ -4628,7 +4628,7 @@ fn zirCondbr( |
| 4628 | 4628 | return always_noreturn; |
| 4629 | 4629 | } |
| 4630 | 4630 | |
| 4631 | | fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index { |
| 4631 | fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 4632 | 4632 | const tracy = trace(@src()); |
| 4633 | 4633 | defer tracy.end(); |
| 4634 | 4634 | |
| ... | ... | @@ -4648,9 +4648,9 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 4648 | 4648 | fn zirRetTok( |
| 4649 | 4649 | sema: *Sema, |
| 4650 | 4650 | block: *Scope.Block, |
| 4651 | | inst: zir.Inst.Index, |
| 4651 | inst: Zir.Inst.Index, |
| 4652 | 4652 | need_coercion: bool, |
| 4653 | | ) InnerError!zir.Inst.Index { |
| 4653 | ) InnerError!Zir.Inst.Index { |
| 4654 | 4654 | const tracy = trace(@src()); |
| 4655 | 4655 | defer tracy.end(); |
| 4656 | 4656 | |
| ... | ... | @@ -4661,7 +4661,7 @@ fn zirRetTok( |
| 4661 | 4661 | return sema.analyzeRet(block, operand, src, need_coercion); |
| 4662 | 4662 | } |
| 4663 | 4663 | |
| 4664 | | fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index { |
| 4664 | fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 4665 | 4665 | const tracy = trace(@src()); |
| 4666 | 4666 | defer tracy.end(); |
| 4667 | 4667 | |
| ... | ... | @@ -4678,7 +4678,7 @@ fn analyzeRet( |
| 4678 | 4678 | operand: *Inst, |
| 4679 | 4679 | src: LazySrcLoc, |
| 4680 | 4680 | need_coercion: bool, |
| 4681 | | ) InnerError!zir.Inst.Index { |
| 4681 | ) InnerError!Zir.Inst.Index { |
| 4682 | 4682 | if (block.inlining) |inlining| { |
| 4683 | 4683 | // We are inlining a function call; rewrite the `ret` as a `break`. |
| 4684 | 4684 | try inlining.merges.results.append(sema.gpa, operand); |
| ... | ... | @@ -4702,7 +4702,7 @@ fn analyzeRet( |
| 4702 | 4702 | return always_noreturn; |
| 4703 | 4703 | } |
| 4704 | 4704 | |
| 4705 | | fn floatOpAllowed(tag: zir.Inst.Tag) bool { |
| 4705 | fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 4706 | 4706 | // extend this swich as additional operators are implemented |
| 4707 | 4707 | return switch (tag) { |
| 4708 | 4708 | .add, .sub => true, |
| ... | ... | @@ -4710,7 +4710,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool { |
| 4710 | 4710 | }; |
| 4711 | 4711 | } |
| 4712 | 4712 | |
| 4713 | | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4713 | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4714 | 4714 | const tracy = trace(@src()); |
| 4715 | 4715 | defer tracy.end(); |
| 4716 | 4716 | |
| ... | ... | @@ -4731,36 +4731,36 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 4731 | 4731 | return sema.mod.constType(sema.arena, .unneeded, ty); |
| 4732 | 4732 | } |
| 4733 | 4733 | |
| 4734 | | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4734 | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4735 | 4735 | const tracy = trace(@src()); |
| 4736 | 4736 | defer tracy.end(); |
| 4737 | 4737 | |
| 4738 | 4738 | const src: LazySrcLoc = .unneeded; |
| 4739 | 4739 | const inst_data = sema.code.instructions.items(.data)[inst].ptr_type; |
| 4740 | | const extra = sema.code.extraData(zir.Inst.PtrType, inst_data.payload_index); |
| 4740 | const extra = sema.code.extraData(Zir.Inst.PtrType, inst_data.payload_index); |
| 4741 | 4741 | |
| 4742 | 4742 | var extra_i = extra.end; |
| 4743 | 4743 | |
| 4744 | 4744 | const sentinel = if (inst_data.flags.has_sentinel) blk: { |
| 4745 | | const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4745 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4746 | 4746 | extra_i += 1; |
| 4747 | 4747 | break :blk (try sema.resolveInstConst(block, .unneeded, ref)).val; |
| 4748 | 4748 | } else null; |
| 4749 | 4749 | |
| 4750 | 4750 | const abi_align = if (inst_data.flags.has_align) blk: { |
| 4751 | | const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4751 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4752 | 4752 | extra_i += 1; |
| 4753 | 4753 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u32); |
| 4754 | 4754 | } else 0; |
| 4755 | 4755 | |
| 4756 | 4756 | const bit_start = if (inst_data.flags.has_bit_range) blk: { |
| 4757 | | const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4757 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4758 | 4758 | extra_i += 1; |
| 4759 | 4759 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 4760 | 4760 | } else 0; |
| 4761 | 4761 | |
| 4762 | 4762 | const bit_end = if (inst_data.flags.has_bit_range) blk: { |
| 4763 | | const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4763 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 4764 | 4764 | extra_i += 1; |
| 4765 | 4765 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 4766 | 4766 | } else 0; |
| ... | ... | @@ -4785,7 +4785,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 4785 | 4785 | return sema.mod.constType(sema.arena, src, ty); |
| 4786 | 4786 | } |
| 4787 | 4787 | |
| 4788 | | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4788 | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4789 | 4789 | const tracy = trace(@src()); |
| 4790 | 4790 | defer tracy.end(); |
| 4791 | 4791 | |
| ... | ... | @@ -4799,13 +4799,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 4799 | 4799 | }); |
| 4800 | 4800 | } |
| 4801 | 4801 | |
| 4802 | | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4802 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4803 | 4803 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4804 | 4804 | const src = inst_data.src(); |
| 4805 | 4805 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInit", .{}); |
| 4806 | 4806 | } |
| 4807 | 4807 | |
| 4808 | | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst { |
| 4808 | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4809 | 4809 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4810 | 4810 | const src = inst_data.src(); |
| 4811 | 4811 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldType", .{}); |
| ... | ... | @@ -4895,7 +4895,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 4895 | 4895 | try parent_block.instructions.append(sema.gpa, &block_inst.base); |
| 4896 | 4896 | } |
| 4897 | 4897 | |
| 4898 | | fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !zir.Inst.Index { |
| 4898 | fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index { |
| 4899 | 4899 | // TODO Once we have a panic function to call, call it here instead of breakpoint. |
| 4900 | 4900 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); |
| 4901 | 4901 | _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); |