| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | //! Semantic analysis of ZIR instructions. | 1 | //! Semantic analysis of ZIR instructions. |
| 2 | //! Shared to every Block. Stored on the stack. | 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 | //! Transforms untyped ZIR instructions into semantically-analyzed TZIR instructions. | 4 | //! Transforms untyped ZIR instructions into semantically-analyzed TZIR instructions. |
| 5 | //! Does type checking, comptime control flow, and safety-check generation. | 5 | //! Does type checking, comptime control flow, and safety-check generation. |
| 6 | //! This is the the heart of the Zig compiler. | 6 | //! This is the the heart of the Zig compiler. |
| ... | @@ -10,7 +10,7 @@ mod: *Module, | ... | @@ -10,7 +10,7 @@ mod: *Module, |
| 10 | gpa: *Allocator, | 10 | gpa: *Allocator, |
| 11 | /// Points to the arena allocator of the Decl. | 11 | /// Points to the arena allocator of the Decl. |
| 12 | arena: *Allocator, | 12 | arena: *Allocator, |
| 13 | code: zir.Code, | 13 | code: Zir, |
| 14 | /// Maps ZIR to TZIR. | 14 | /// Maps ZIR to TZIR. |
| 15 | inst_map: []*Inst, | 15 | inst_map: []*Inst, |
| 16 | /// When analyzing an inline function call, owner_decl is the Decl of the caller | 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,7 +52,7 @@ const Value = @import("value.zig").Value; |
| 52 | const Type = @import("type.zig").Type; | 52 | const Type = @import("type.zig").Type; |
| 53 | const TypedValue = @import("TypedValue.zig"); | 53 | const TypedValue = @import("TypedValue.zig"); |
| 54 | const ir = @import("ir.zig"); | 54 | const ir = @import("ir.zig"); |
| 55 | const zir = @import("zir.zig"); | 55 | const Zir = @import("zir.zig"); // TODO rename to Zir.zig |
| 56 | const Module = @import("Module.zig"); | 56 | const Module = @import("Module.zig"); |
| 57 | const Inst = ir.Inst; | 57 | const Inst = ir.Inst; |
| 58 | const Body = ir.Body; | 58 | const Body = ir.Body; |
| ... | @@ -64,14 +64,14 @@ const LazySrcLoc = Module.LazySrcLoc; | ... | @@ -64,14 +64,14 @@ const LazySrcLoc = Module.LazySrcLoc; |
| 64 | const RangeSet = @import("RangeSet.zig"); | 64 | const RangeSet = @import("RangeSet.zig"); |
| 65 | const AstGen = @import("AstGen.zig"); | 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 | const inst_data = sema.code.instructions.items(.data)[0].pl_node; | 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 | const root_body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 70 | const root_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 71 | return sema.analyzeBody(root_block, root_body); | 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 | const break_inst = try sema.root(root_block); | 75 | const break_inst = try sema.root(root_block); |
| 76 | return sema.code.instructions.items(.data)[break_inst].@"break".operand; | 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,7 +89,7 @@ pub fn rootAsType(sema: *Sema, root_block: *Scope.Block) !Type { |
| 89 | /// Returns only the result from the body that is specified. | 89 | /// Returns only the result from the body that is specified. |
| 90 | /// Only appropriate to call when it is determined at comptime that this body | 90 | /// Only appropriate to call when it is determined at comptime that this body |
| 91 | /// has no peers. | 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 | const break_inst = try sema.analyzeBody(block, body); | 93 | const break_inst = try sema.analyzeBody(block, body); |
| 94 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; | 94 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 95 | return sema.resolveInst(operand_ref); | 95 | return sema.resolveInst(operand_ref); |
| ... | @@ -99,22 +99,22 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) I | ... | @@ -99,22 +99,22 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) I |
| 99 | /// return type of `analyzeBody` so that we can tail call them. | 99 | /// return type of `analyzeBody` so that we can tail call them. |
| 100 | /// Only appropriate to return when the instruction is known to be NoReturn | 100 | /// Only appropriate to return when the instruction is known to be NoReturn |
| 101 | /// solely based on the ZIR tag. | 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 | /// This function is the main loop of `Sema` and it can be used in two different ways: | 104 | /// This function is the main loop of `Sema` and it can be used in two different ways: |
| 105 | /// * The traditional way where there are N breaks out of the block and peer type | 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 | /// part of the return value will be `undefined`, and callsites should ignore it, | 107 | /// part of the return value will be `undefined`, and callsites should ignore it, |
| 108 | /// finding the block result value via the block scope. | 108 | /// finding the block result value via the block scope. |
| 109 | /// * The "flat" way. There is only 1 break out of the block, and it is with a `break_inline` | 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 | /// the break instruction. This communicates both which block the break applies to, as | 111 | /// the break instruction. This communicates both which block the break applies to, as |
| 112 | /// well as the operand. No block scope needs to be created for this strategy. | 112 | /// well as the operand. No block scope needs to be created for this strategy. |
| 113 | pub fn analyzeBody( | 113 | pub fn analyzeBody( |
| 114 | sema: *Sema, | 114 | sema: *Sema, |
| 115 | block: *Scope.Block, | 115 | block: *Scope.Block, |
| 116 | body: []const zir.Inst.Index, | 116 | body: []const Zir.Inst.Index, |
| 117 | ) InnerError!zir.Inst.Index { | 117 | ) InnerError!Zir.Inst.Index { |
| 118 | // No tracy calls here, to avoid interfering with the tail call mechanism. | 118 | // No tracy calls here, to avoid interfering with the tail call mechanism. |
| 119 | | 119 | |
| 120 | const map = block.sema.inst_map; | 120 | const map = block.sema.inst_map; |
| ... | @@ -368,7 +368,7 @@ pub fn analyzeBody( | ... | @@ -368,7 +368,7 @@ pub fn analyzeBody( |
| 368 | .block_inline => blk: { | 368 | .block_inline => blk: { |
| 369 | // Directly analyze the block body without introducing a new block. | 369 | // Directly analyze the block body without introducing a new block. |
| 370 | const inst_data = datas[inst].pl_node; | 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 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 372 | const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 373 | const break_inst = try sema.analyzeBody(block, inline_body); | 373 | const break_inst = try sema.analyzeBody(block, inline_body); |
| 374 | const break_data = datas[break_inst].@"break"; | 374 | const break_data = datas[break_inst].@"break"; |
| ... | @@ -381,7 +381,7 @@ pub fn analyzeBody( | ... | @@ -381,7 +381,7 @@ pub fn analyzeBody( |
| 381 | .condbr_inline => blk: { | 381 | .condbr_inline => blk: { |
| 382 | const inst_data = datas[inst].pl_node; | 382 | const inst_data = datas[inst].pl_node; |
| 383 | const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node }; | 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 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; | 385 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 386 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; | 386 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; |
| 387 | const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition); | 387 | const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition); |
| ... | @@ -401,19 +401,19 @@ pub fn analyzeBody( | ... | @@ -401,19 +401,19 @@ pub fn analyzeBody( |
| 401 | } | 401 | } |
| 402 | | 402 | |
| 403 | /// TODO when we rework TZIR memory layout, this function will no longer have a possible error. | 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 | var i: usize = @enumToInt(zir_ref); | 405 | var i: usize = @enumToInt(zir_ref); |
| 406 | | 406 | |
| 407 | // First section of indexes correspond to a set number of constant values. | 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 | // TODO when we rework TZIR memory layout, this function can be as simple as: | 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 | // return zir_ref; | 411 | // return zir_ref; |
| 412 | // Until then we allocate memory for a new, mutable `ir.Inst` to match what | 412 | // Until then we allocate memory for a new, mutable `ir.Inst` to match what |
| 413 | // TZIR expects. | 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 | // Next section of indexes correspond to function parameters, if any. | 418 | // Next section of indexes correspond to function parameters, if any. |
| 419 | if (i < sema.param_inst_list.len) { | 419 | if (i < sema.param_inst_list.len) { |
| ... | @@ -429,7 +429,7 @@ fn resolveConstString( | ... | @@ -429,7 +429,7 @@ fn resolveConstString( |
| 429 | sema: *Sema, | 429 | sema: *Sema, |
| 430 | block: *Scope.Block, | 430 | block: *Scope.Block, |
| 431 | src: LazySrcLoc, | 431 | src: LazySrcLoc, |
| 432 | zir_ref: zir.Inst.Ref, | 432 | zir_ref: Zir.Inst.Ref, |
| 433 | ) ![]u8 { | 433 | ) ![]u8 { |
| 434 | const tzir_inst = try sema.resolveInst(zir_ref); | 434 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 435 | const wanted_type = Type.initTag(.const_slice_u8); | 435 | const wanted_type = Type.initTag(.const_slice_u8); |
| ... | @@ -438,7 +438,7 @@ fn resolveConstString( | ... | @@ -438,7 +438,7 @@ fn resolveConstString( |
| 438 | return val.toAllocatedBytes(sema.arena); | 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 | const tzir_inst = try sema.resolveInst(zir_ref); | 442 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 443 | const wanted_type = Type.initTag(.@"type"); | 443 | const wanted_type = Type.initTag(.@"type"); |
| 444 | const coerced_inst = try sema.coerce(block, wanted_type, tzir_inst, src); | 444 | const coerced_inst = try sema.coerce(block, wanted_type, tzir_inst, src); |
| ... | @@ -476,7 +476,7 @@ fn resolveAlreadyCoercedInt( | ... | @@ -476,7 +476,7 @@ fn resolveAlreadyCoercedInt( |
| 476 | sema: *Sema, | 476 | sema: *Sema, |
| 477 | block: *Scope.Block, | 477 | block: *Scope.Block, |
| 478 | src: LazySrcLoc, | 478 | src: LazySrcLoc, |
| 479 | zir_ref: zir.Inst.Ref, | 479 | zir_ref: Zir.Inst.Ref, |
| 480 | comptime Int: type, | 480 | comptime Int: type, |
| 481 | ) !Int { | 481 | ) !Int { |
| 482 | comptime assert(@typeInfo(Int).Int.bits <= 64); | 482 | comptime assert(@typeInfo(Int).Int.bits <= 64); |
| ... | @@ -492,7 +492,7 @@ fn resolveInt( | ... | @@ -492,7 +492,7 @@ fn resolveInt( |
| 492 | sema: *Sema, | 492 | sema: *Sema, |
| 493 | block: *Scope.Block, | 493 | block: *Scope.Block, |
| 494 | src: LazySrcLoc, | 494 | src: LazySrcLoc, |
| 495 | zir_ref: zir.Inst.Ref, | 495 | zir_ref: Zir.Inst.Ref, |
| 496 | dest_type: Type, | 496 | dest_type: Type, |
| 497 | ) !u64 { | 497 | ) !u64 { |
| 498 | const tzir_inst = try sema.resolveInst(zir_ref); | 498 | const tzir_inst = try sema.resolveInst(zir_ref); |
| ... | @@ -506,7 +506,7 @@ fn resolveInstConst( | ... | @@ -506,7 +506,7 @@ fn resolveInstConst( |
| 506 | sema: *Sema, | 506 | sema: *Sema, |
| 507 | block: *Scope.Block, | 507 | block: *Scope.Block, |
| 508 | src: LazySrcLoc, | 508 | src: LazySrcLoc, |
| 509 | zir_ref: zir.Inst.Ref, | 509 | zir_ref: Zir.Inst.Ref, |
| 510 | ) InnerError!TypedValue { | 510 | ) InnerError!TypedValue { |
| 511 | const tzir_inst = try sema.resolveInst(zir_ref); | 511 | const tzir_inst = try sema.resolveInst(zir_ref); |
| 512 | const val = try sema.resolveConstValue(block, src, tzir_inst); | 512 | const val = try sema.resolveConstValue(block, src, tzir_inst); |
| ... | @@ -516,13 +516,13 @@ fn resolveInstConst( | ... | @@ -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 | const tracy = trace(@src()); | 520 | const tracy = trace(@src()); |
| 521 | defer tracy.end(); | 521 | defer tracy.end(); |
| 522 | return sema.mod.fail(&block.base, sema.src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); | 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 | const tracy = trace(@src()); | 526 | const tracy = trace(@src()); |
| 527 | defer tracy.end(); | 527 | defer tracy.end(); |
| 528 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); | 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,7 +531,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 531 | fn zirStructDecl( | 531 | fn zirStructDecl( |
| 532 | sema: *Sema, | 532 | sema: *Sema, |
| 533 | block: *Scope.Block, | 533 | block: *Scope.Block, |
| 534 | inst: zir.Inst.Index, | 534 | inst: Zir.Inst.Index, |
| 535 | layout: std.builtin.TypeInfo.ContainerLayout, | 535 | layout: std.builtin.TypeInfo.ContainerLayout, |
| 536 | ) InnerError!*Inst { | 536 | ) InnerError!*Inst { |
| 537 | const tracy = trace(@src()); | 537 | const tracy = trace(@src()); |
| ... | @@ -540,7 +540,7 @@ fn zirStructDecl( | ... | @@ -540,7 +540,7 @@ fn zirStructDecl( |
| 540 | const gpa = sema.gpa; | 540 | const gpa = sema.gpa; |
| 541 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 541 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 542 | const src = inst_data.src(); | 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 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 544 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 545 | const fields_len = extra.data.fields_len; | 545 | const fields_len = extra.data.fields_len; |
| 546 | | 546 | |
| ... | @@ -650,7 +650,7 @@ fn zirStructDecl( | ... | @@ -650,7 +650,7 @@ fn zirStructDecl( |
| 650 | | 650 | |
| 651 | const field_name_zir = sema.code.nullTerminatedString(sema.code.extra[extra_index]); | 651 | const field_name_zir = sema.code.nullTerminatedString(sema.code.extra[extra_index]); |
| 652 | extra_index += 1; | 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 | extra_index += 1; | 654 | extra_index += 1; |
| 655 | | 655 | |
| 656 | // This string needs to outlive the ZIR code. | 656 | // This string needs to outlive the ZIR code. |
| ... | @@ -669,7 +669,7 @@ fn zirStructDecl( | ... | @@ -669,7 +669,7 @@ fn zirStructDecl( |
| 669 | }; | 669 | }; |
| 670 | | 670 | |
| 671 | if (has_align) { | 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 | extra_index += 1; | 673 | extra_index += 1; |
| 674 | // TODO: if we need to report an error here, use a source location | 674 | // TODO: if we need to report an error here, use a source location |
| 675 | // that points to this alignment expression rather than the struct. | 675 | // that points to this alignment expression rather than the struct. |
| ... | @@ -677,7 +677,7 @@ fn zirStructDecl( | ... | @@ -677,7 +677,7 @@ fn zirStructDecl( |
| 677 | gop.entry.value.abi_align = (try sema.resolveInstConst(block, src, align_ref)).val; | 677 | gop.entry.value.abi_align = (try sema.resolveInstConst(block, src, align_ref)).val; |
| 678 | } | 678 | } |
| 679 | if (has_default) { | 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 | extra_index += 1; | 681 | extra_index += 1; |
| 682 | // TODO: if we need to report an error here, use a source location | 682 | // TODO: if we need to report an error here, use a source location |
| 683 | // that points to this default value expression rather than the struct. | 683 | // that points to this default value expression rather than the struct. |
| ... | @@ -692,7 +692,7 @@ fn zirStructDecl( | ... | @@ -692,7 +692,7 @@ fn zirStructDecl( |
| 692 | fn zirEnumDecl( | 692 | fn zirEnumDecl( |
| 693 | sema: *Sema, | 693 | sema: *Sema, |
| 694 | block: *Scope.Block, | 694 | block: *Scope.Block, |
| 695 | inst: zir.Inst.Index, | 695 | inst: Zir.Inst.Index, |
| 696 | nonexhaustive: bool, | 696 | nonexhaustive: bool, |
| 697 | ) InnerError!*Inst { | 697 | ) InnerError!*Inst { |
| 698 | const tracy = trace(@src()); | 698 | const tracy = trace(@src()); |
| ... | @@ -701,7 +701,7 @@ fn zirEnumDecl( | ... | @@ -701,7 +701,7 @@ fn zirEnumDecl( |
| 701 | const gpa = sema.gpa; | 701 | const gpa = sema.gpa; |
| 702 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 702 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 703 | const src = inst_data.src(); | 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 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 705 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 706 | const fields_len = extra.data.fields_len; | 706 | const fields_len = extra.data.fields_len; |
| 707 | | 707 | |
| ... | @@ -842,7 +842,7 @@ fn zirEnumDecl( | ... | @@ -842,7 +842,7 @@ fn zirEnumDecl( |
| 842 | assert(!gop.found_existing); | 842 | assert(!gop.found_existing); |
| 843 | | 843 | |
| 844 | if (has_tag_value) { | 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 | extra_index += 1; | 846 | extra_index += 1; |
| 847 | // TODO: if we need to report an error here, use a source location | 847 | // TODO: if we need to report an error here, use a source location |
| 848 | // that points to this default value expression rather than the struct. | 848 | // that points to this default value expression rather than the struct. |
| ... | @@ -858,29 +858,29 @@ fn zirEnumDecl( | ... | @@ -858,29 +858,29 @@ fn zirEnumDecl( |
| 858 | return sema.analyzeDeclVal(block, src, new_decl); | 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 | const tracy = trace(@src()); | 862 | const tracy = trace(@src()); |
| 863 | defer tracy.end(); | 863 | defer tracy.end(); |
| 864 | | 864 | |
| 865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 866 | const src = inst_data.src(); | 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 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirUnionDecl", .{}); | 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 | const tracy = trace(@src()); | 873 | const tracy = trace(@src()); |
| 874 | defer tracy.end(); | 874 | defer tracy.end(); |
| 875 | | 875 | |
| 876 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 876 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 877 | const src = inst_data.src(); | 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 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{}); | 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 | const tracy = trace(@src()); | 884 | const tracy = trace(@src()); |
| 885 | defer tracy.end(); | 885 | defer tracy.end(); |
| 886 | | 886 | |
| ... | @@ -892,7 +892,7 @@ fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! | ... | @@ -892,7 +892,7 @@ fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 892 | return block.addNoOp(src, ptr_type, .alloc); | 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 | const tracy = trace(@src()); | 896 | const tracy = trace(@src()); |
| 897 | defer tracy.end(); | 897 | defer tracy.end(); |
| 898 | | 898 | |
| ... | @@ -901,7 +901,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In | ... | @@ -901,7 +901,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 901 | return sema.analyzeRef(block, inst_data.src(), operand); | 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 | const tracy = trace(@src()); | 905 | const tracy = trace(@src()); |
| 906 | defer tracy.end(); | 906 | defer tracy.end(); |
| 907 | | 907 | |
| ... | @@ -912,7 +912,7 @@ fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -912,7 +912,7 @@ fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 912 | return sema.mod.constType(sema.arena, src, ret_type); | 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 | const tracy = trace(@src()); | 916 | const tracy = trace(@src()); |
| 917 | defer tracy.end(); | 917 | defer tracy.end(); |
| 918 | | 918 | |
| ... | @@ -935,7 +935,7 @@ fn ensureResultUsed( | ... | @@ -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 | const tracy = trace(@src()); | 939 | const tracy = trace(@src()); |
| 940 | defer tracy.end(); | 940 | defer tracy.end(); |
| 941 | | 941 | |
| ... | @@ -948,7 +948,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde | ... | @@ -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 | const tracy = trace(@src()); | 952 | const tracy = trace(@src()); |
| 953 | defer tracy.end(); | 953 | defer tracy.end(); |
| 954 | | 954 | |
| ... | @@ -982,7 +982,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In | ... | @@ -982,7 +982,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 982 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); | 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 | const tracy = trace(@src()); | 986 | const tracy = trace(@src()); |
| 987 | defer tracy.end(); | 987 | defer tracy.end(); |
| 988 | | 988 | |
| ... | @@ -995,7 +995,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* | ... | @@ -995,7 +995,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* |
| 995 | return block.addNoOp(var_decl_src, ptr_type, .alloc); | 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 | const tracy = trace(@src()); | 999 | const tracy = trace(@src()); |
| 1000 | defer tracy.end(); | 1000 | defer tracy.end(); |
| 1001 | | 1001 | |
| ... | @@ -1012,7 +1012,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro | ... | @@ -1012,7 +1012,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 1012 | fn zirAllocInferred( | 1012 | fn zirAllocInferred( |
| 1013 | sema: *Sema, | 1013 | sema: *Sema, |
| 1014 | block: *Scope.Block, | 1014 | block: *Scope.Block, |
| 1015 | inst: zir.Inst.Index, | 1015 | inst: Zir.Inst.Index, |
| 1016 | inferred_alloc_ty: Type, | 1016 | inferred_alloc_ty: Type, |
| 1017 | ) InnerError!*Inst { | 1017 | ) InnerError!*Inst { |
| 1018 | const tracy = trace(@src()); | 1018 | const tracy = trace(@src()); |
| ... | @@ -1038,7 +1038,7 @@ fn zirAllocInferred( | ... | @@ -1038,7 +1038,7 @@ fn zirAllocInferred( |
| 1038 | return result; | 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 | const tracy = trace(@src()); | 1042 | const tracy = trace(@src()); |
| 1043 | defer tracy.end(); | 1043 | defer tracy.end(); |
| 1044 | | 1044 | |
| ... | @@ -1064,7 +1064,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde | ... | @@ -1064,7 +1064,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde |
| 1064 | ptr.tag = .alloc; | 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 | const tracy = trace(@src()); | 1068 | const tracy = trace(@src()); |
| 1069 | defer tracy.end(); | 1069 | defer tracy.end(); |
| 1070 | | 1070 | |
| ... | @@ -1072,26 +1072,26 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Ind | ... | @@ -1072,26 +1072,26 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Ind |
| 1072 | const mod = sema.mod; | 1072 | const mod = sema.mod; |
| 1073 | const validate_inst = sema.code.instructions.items(.data)[inst].pl_node; | 1073 | const validate_inst = sema.code.instructions.items(.data)[inst].pl_node; |
| 1074 | const struct_init_src = validate_inst.src(); | 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 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; | 1076 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 1077 | | 1077 | |
| 1078 | const struct_obj: *Module.Struct = s: { | 1078 | const struct_obj: *Module.Struct = s: { |
| 1079 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; | 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 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); | 1081 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); |
| 1082 | break :s object_ptr.ty.elemType().castTag(.@"struct").?.data; | 1082 | break :s object_ptr.ty.elemType().castTag(.@"struct").?.data; |
| 1083 | }; | 1083 | }; |
| 1084 | | 1084 | |
| 1085 | // Maps field index to field_ptr index of where it was already initialized. | 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 | defer gpa.free(found_fields); | 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 | for (instrs) |field_ptr| { | 1091 | for (instrs) |field_ptr| { |
| 1092 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; | 1092 | const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node; |
| 1093 | const field_src: LazySrcLoc = .{ .node_offset_back2tok = field_ptr_data.src_node }; | 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 | const field_name = sema.code.nullTerminatedString(field_ptr_extra.field_name_start); | 1095 | const field_name = sema.code.nullTerminatedString(field_ptr_extra.field_name_start); |
| 1096 | const field_index = struct_obj.fields.getIndex(field_name) orelse | 1096 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 1097 | return sema.failWithBadFieldAccess(block, struct_obj, field_src, field_name); | 1097 | return sema.failWithBadFieldAccess(block, struct_obj, field_src, field_name); |
| ... | @@ -1164,7 +1164,7 @@ fn failWithBadFieldAccess( | ... | @@ -1164,7 +1164,7 @@ fn failWithBadFieldAccess( |
| 1164 | return mod.failWithOwnedErrorMsg(&block.base, msg); | 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 | const tracy = trace(@src()); | 1168 | const tracy = trace(@src()); |
| 1169 | defer tracy.end(); | 1169 | defer tracy.end(); |
| 1170 | | 1170 | |
| ... | @@ -1180,7 +1180,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In | ... | @@ -1180,7 +1180,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 1180 | return sema.storePtr(block, src, bitcasted_ptr, value); | 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 | const tracy = trace(@src()); | 1184 | const tracy = trace(@src()); |
| 1185 | defer tracy.end(); | 1185 | defer tracy.end(); |
| 1186 | | 1186 | |
| ... | @@ -1199,7 +1199,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) | ... | @@ -1199,7 +1199,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1199 | return sema.storePtr(block, src, bitcasted_ptr, value); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1203 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1204 | const src = inst_data.src(); | 1204 | const src = inst_data.src(); |
| 1205 | try sema.requireFunctionBlock(block, src); | 1205 | try sema.requireFunctionBlock(block, src); |
| ... | @@ -1208,7 +1208,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) | ... | @@ -1208,7 +1208,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1208 | sema.branch_quota = quota; | 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 | const tracy = trace(@src()); | 1212 | const tracy = trace(@src()); |
| 1213 | defer tracy.end(); | 1213 | defer tracy.end(); |
| 1214 | | 1214 | |
| ... | @@ -1218,19 +1218,19 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!v | ... | @@ -1218,19 +1218,19 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!v |
| 1218 | return sema.storePtr(block, sema.src, ptr, value); | 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 | const tracy = trace(@src()); | 1222 | const tracy = trace(@src()); |
| 1223 | defer tracy.end(); | 1223 | defer tracy.end(); |
| 1224 | | 1224 | |
| 1225 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1225 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1226 | const src = inst_data.src(); | 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 | const ptr = try sema.resolveInst(extra.lhs); | 1228 | const ptr = try sema.resolveInst(extra.lhs); |
| 1229 | const value = try sema.resolveInst(extra.rhs); | 1229 | const value = try sema.resolveInst(extra.rhs); |
| 1230 | return sema.storePtr(block, src, ptr, value); | 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 | const tracy = trace(@src()); | 1234 | const tracy = trace(@src()); |
| 1235 | defer tracy.end(); | 1235 | defer tracy.end(); |
| 1236 | | 1236 | |
| ... | @@ -1266,7 +1266,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr | ... | @@ -1266,7 +1266,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 1266 | return sema.mod.constType(sema.arena, src, param_type); | 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 | const tracy = trace(@src()); | 1270 | const tracy = trace(@src()); |
| 1271 | defer tracy.end(); | 1271 | defer tracy.end(); |
| 1272 | | 1272 | |
| ... | @@ -1292,7 +1292,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In | ... | @@ -1292,7 +1292,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 1292 | return sema.analyzeDeclRef(block, .unneeded, new_decl); | 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 | const tracy = trace(@src()); | 1296 | const tracy = trace(@src()); |
| 1297 | defer tracy.end(); | 1297 | defer tracy.end(); |
| 1298 | | 1298 | |
| ... | @@ -1300,7 +1300,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In | ... | @@ -1300,7 +1300,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 1300 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); | 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 | const arena = sema.arena; | 1304 | const arena = sema.arena; |
| 1305 | const inst_data = sema.code.instructions.items(.data)[inst].float; | 1305 | const inst_data = sema.code.instructions.items(.data)[inst].float; |
| 1306 | const src = inst_data.src(); | 1306 | const src = inst_data.src(); |
| ... | @@ -1312,10 +1312,10 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* | ... | @@ -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 | const arena = sema.arena; | 1316 | const arena = sema.arena; |
| 1317 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src = inst_data.src(); | 1319 | const src = inst_data.src(); |
| 1320 | const number = extra.get(); | 1320 | const number = extra.get(); |
| 1321 | | 1321 | |
| ... | @@ -1325,7 +1325,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro | ... | @@ -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 | const tracy = trace(@src()); | 1329 | const tracy = trace(@src()); |
| 1330 | defer tracy.end(); | 1330 | defer tracy.end(); |
| 1331 | | 1331 | |
| ... | @@ -1336,13 +1336,13 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner | ... | @@ -1336,13 +1336,13 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1336 | return sema.mod.fail(&block.base, src, "{s}", .{msg}); | 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 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); | 1340 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| 1341 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); | 1341 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); |
| 1342 | const writer = managed.writer(); | 1342 | const writer = managed.writer(); |
| 1343 | | 1343 | |
| 1344 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); | 1346 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); |
| 1347 | | 1347 | |
| 1348 | for (args) |arg_ref, i| { | 1348 | for (args) |arg_ref, i| { |
| ... | @@ -1363,7 +1363,7 @@ fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -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 | const tracy = trace(@src()); | 1367 | const tracy = trace(@src()); |
| 1368 | defer tracy.end(); | 1368 | defer tracy.end(); |
| 1369 | | 1369 | |
| ... | @@ -1373,13 +1373,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! | ... | @@ -1373,13 +1373,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 1373 | return always_noreturn; | 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 | const tracy = trace(@src()); | 1377 | const tracy = trace(@src()); |
| 1378 | defer tracy.end(); | 1378 | defer tracy.end(); |
| 1379 | | 1379 | |
| 1380 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1380 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1381 | const src = inst_data.src(); | 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 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 1383 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1384 | | 1384 | |
| 1385 | // TZIR expects a block outside the loop block too. | 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,13 +1434,13 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 1434 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); | 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 | const tracy = trace(@src()); | 1438 | const tracy = trace(@src()); |
| 1439 | defer tracy.end(); | 1439 | defer tracy.end(); |
| 1440 | | 1440 | |
| 1441 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1441 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1442 | const src = inst_data.src(); | 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 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 1444 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 1445 | | 1445 | |
| 1446 | // Reserve space for a Block instruction so that generated Break instructions can | 1446 | // Reserve space for a Block instruction so that generated Break instructions can |
| ... | @@ -1566,12 +1566,12 @@ fn analyzeBlockBody( | ... | @@ -1566,12 +1566,12 @@ fn analyzeBlockBody( |
| 1566 | return &merges.block_inst.base; | 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 | const tracy = trace(@src()); | 1570 | const tracy = trace(@src()); |
| 1571 | defer tracy.end(); | 1571 | defer tracy.end(); |
| 1572 | | 1572 | |
| 1573 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src = inst_data.src(); | 1575 | const src = inst_data.src(); |
| 1576 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 1576 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 1577 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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,7 +1588,7 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 1588 | try sema.mod.analyzeExport(&block.base, src, export_name, actual_fn.owner_decl); | 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 | const tracy = trace(@src()); | 1592 | const tracy = trace(@src()); |
| 1593 | defer tracy.end(); | 1593 | defer tracy.end(); |
| 1594 | | 1594 | |
| ... | @@ -1598,7 +1598,7 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -1598,7 +1598,7 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 1598 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); | 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 | const tracy = trace(@src()); | 1602 | const tracy = trace(@src()); |
| 1603 | defer tracy.end(); | 1603 | defer tracy.end(); |
| 1604 | | 1604 | |
| ... | @@ -1638,7 +1638,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: zir.Inst.Index) InnerE | ... | @@ -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 | const tracy = trace(@src()); | 1642 | const tracy = trace(@src()); |
| 1643 | defer tracy.end(); | 1643 | defer tracy.end(); |
| 1644 | | 1644 | |
| ... | @@ -1656,21 +1656,21 @@ fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE | ... | @@ -1656,21 +1656,21 @@ fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 1656 | _ = try block.addDbgStmt(src, abs_byte_off); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1660 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1661 | const src = inst_data.src(); | 1661 | const src = inst_data.src(); |
| 1662 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; | 1662 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; |
| 1663 | return sema.analyzeDeclRef(block, src, decl); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1667 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1668 | const src = inst_data.src(); | 1668 | const src = inst_data.src(); |
| 1669 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; | 1669 | const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key; |
| 1670 | return sema.analyzeDeclVal(block, src, decl); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 1674 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1675 | const src = inst_data.src(); | 1675 | const src = inst_data.src(); |
| 1676 | const decl_name = inst_data.get(sema.code); | 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,7 +1678,7 @@ fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1678 | return sema.analyzeDeclRef(block, src, decl); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 1682 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1683 | const src = inst_data.src(); | 1683 | const src = inst_data.src(); |
| 1684 | const decl_name = inst_data.get(sema.code); | 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,7 +1701,7 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c |
| 1701 | fn zirCallNone( | 1701 | fn zirCallNone( |
| 1702 | sema: *Sema, | 1702 | sema: *Sema, |
| 1703 | block: *Scope.Block, | 1703 | block: *Scope.Block, |
| 1704 | inst: zir.Inst.Index, | 1704 | inst: Zir.Inst.Index, |
| 1705 | ensure_result_used: bool, | 1705 | ensure_result_used: bool, |
| 1706 | ) InnerError!*Inst { | 1706 | ) InnerError!*Inst { |
| 1707 | const tracy = trace(@src()); | 1707 | const tracy = trace(@src()); |
| ... | @@ -1716,7 +1716,7 @@ fn zirCallNone( | ... | @@ -1716,7 +1716,7 @@ fn zirCallNone( |
| 1716 | fn zirCall( | 1716 | fn zirCall( |
| 1717 | sema: *Sema, | 1717 | sema: *Sema, |
| 1718 | block: *Scope.Block, | 1718 | block: *Scope.Block, |
| 1719 | inst: zir.Inst.Index, | 1719 | inst: Zir.Inst.Index, |
| 1720 | modifier: std.builtin.CallOptions.Modifier, | 1720 | modifier: std.builtin.CallOptions.Modifier, |
| 1721 | ensure_result_used: bool, | 1721 | ensure_result_used: bool, |
| 1722 | ) InnerError!*Inst { | 1722 | ) InnerError!*Inst { |
| ... | @@ -1726,7 +1726,7 @@ fn zirCall( | ... | @@ -1726,7 +1726,7 @@ fn zirCall( |
| 1726 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1726 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1727 | const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node }; | 1727 | const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node }; |
| 1728 | const call_src = inst_data.src(); | 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 | const args = sema.code.refSlice(extra.end, extra.data.args_len); | 1730 | const args = sema.code.refSlice(extra.end, extra.data.args_len); |
| 1731 | | 1731 | |
| 1732 | return sema.analyzeCall(block, extra.data.callee, func_src, call_src, modifier, ensure_result_used, args); | 1732 | return sema.analyzeCall(block, extra.data.callee, func_src, call_src, modifier, ensure_result_used, args); |
| ... | @@ -1735,12 +1735,12 @@ fn zirCall( | ... | @@ -1735,12 +1735,12 @@ fn zirCall( |
| 1735 | fn analyzeCall( | 1735 | fn analyzeCall( |
| 1736 | sema: *Sema, | 1736 | sema: *Sema, |
| 1737 | block: *Scope.Block, | 1737 | block: *Scope.Block, |
| 1738 | zir_func: zir.Inst.Ref, | 1738 | zir_func: Zir.Inst.Ref, |
| 1739 | func_src: LazySrcLoc, | 1739 | func_src: LazySrcLoc, |
| 1740 | call_src: LazySrcLoc, | 1740 | call_src: LazySrcLoc, |
| 1741 | modifier: std.builtin.CallOptions.Modifier, | 1741 | modifier: std.builtin.CallOptions.Modifier, |
| 1742 | ensure_result_used: bool, | 1742 | ensure_result_used: bool, |
| 1743 | zir_args: []const zir.Inst.Ref, | 1743 | zir_args: []const Zir.Inst.Ref, |
| 1744 | ) InnerError!*ir.Inst { | 1744 | ) InnerError!*ir.Inst { |
| 1745 | const func = try sema.resolveInst(zir_func); | 1745 | const func = try sema.resolveInst(zir_func); |
| 1746 | | 1746 | |
| ... | @@ -1886,7 +1886,7 @@ fn analyzeCall( | ... | @@ -1886,7 +1886,7 @@ fn analyzeCall( |
| 1886 | return result; | 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 | const tracy = trace(@src()); | 1890 | const tracy = trace(@src()); |
| 1891 | defer tracy.end(); | 1891 | defer tracy.end(); |
| 1892 | | 1892 | |
| ... | @@ -1897,7 +1897,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -1897,7 +1897,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 1897 | return sema.mod.constType(sema.arena, src, ty); | 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 | const tracy = trace(@src()); | 1901 | const tracy = trace(@src()); |
| 1902 | defer tracy.end(); | 1902 | defer tracy.end(); |
| 1903 | | 1903 | |
| ... | @@ -1909,7 +1909,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner | ... | @@ -1909,7 +1909,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 1909 | return sema.mod.constType(sema.arena, src, opt_type); | 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 | const tracy = trace(@src()); | 1913 | const tracy = trace(@src()); |
| 1914 | defer tracy.end(); | 1914 | defer tracy.end(); |
| 1915 | | 1915 | |
| ... | @@ -1921,7 +1921,7 @@ fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.I | ... | @@ -1921,7 +1921,7 @@ fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.I |
| 1921 | return sema.mod.constType(sema.arena, inst_data.src(), opt_ty); | 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 | const tracy = trace(@src()); | 1925 | const tracy = trace(@src()); |
| 1926 | defer tracy.end(); | 1926 | defer tracy.end(); |
| 1927 | | 1927 | |
| ... | @@ -1934,14 +1934,14 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr | ... | @@ -1934,14 +1934,14 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 1934 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 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 | const tracy = trace(@src()); | 1938 | const tracy = trace(@src()); |
| 1939 | defer tracy.end(); | 1939 | defer tracy.end(); |
| 1940 | | 1940 | |
| 1941 | // TODO these should be lazily evaluated | 1941 | // TODO these should be lazily evaluated |
| 1942 | const inst_data = sema.code.instructions.items(.data)[inst].array_type_sentinel; | 1942 | const inst_data = sema.code.instructions.items(.data)[inst].array_type_sentinel; |
| 1943 | const len = try sema.resolveInstConst(block, .unneeded, inst_data.len); | 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 | const sentinel = try sema.resolveInstConst(block, .unneeded, extra.sentinel); | 1945 | const sentinel = try sema.resolveInstConst(block, .unneeded, extra.sentinel); |
| 1946 | const elem_type = try sema.resolveType(block, .unneeded, extra.elem_type); | 1946 | const elem_type = try sema.resolveType(block, .unneeded, extra.elem_type); |
| 1947 | const array_ty = try sema.mod.arrayType(sema.arena, len.val.toUnsignedInt(), sentinel.val, elem_type); | 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,12 +1949,12 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) |
| 1949 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 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 | const tracy = trace(@src()); | 1953 | const tracy = trace(@src()); |
| 1954 | defer tracy.end(); | 1954 | defer tracy.end(); |
| 1955 | | 1955 | |
| 1956 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 1958 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 1959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 1959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 1960 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 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,7 +1970,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inn |
| 1970 | return sema.mod.constType(sema.arena, src, err_union_ty); | 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 | const tracy = trace(@src()); | 1974 | const tracy = trace(@src()); |
| 1975 | defer tracy.end(); | 1975 | defer tracy.end(); |
| 1976 | | 1976 | |
| ... | @@ -1988,7 +1988,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -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 | const tracy = trace(@src()); | 1992 | const tracy = trace(@src()); |
| 1993 | defer tracy.end(); | 1993 | defer tracy.end(); |
| 1994 | | 1994 | |
| ... | @@ -2014,7 +2014,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -2014,7 +2014,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 2014 | return block.addUnOp(src, Type.initTag(.u16), .error_to_int, op_coerced); | 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 | const tracy = trace(@src()); | 2018 | const tracy = trace(@src()); |
| 2019 | defer tracy.end(); | 2019 | defer tracy.end(); |
| 2020 | | 2020 | |
| ... | @@ -2047,12 +2047,12 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -2047,12 +2047,12 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 2047 | return block.addUnOp(src, Type.initTag(.anyerror), .int_to_error, op); | 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 | const tracy = trace(@src()); | 2051 | const tracy = trace(@src()); |
| 2052 | defer tracy.end(); | 2052 | defer tracy.end(); |
| 2053 | | 2053 | |
| 2054 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 2056 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 2057 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 2057 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 2058 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 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,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 | const tracy = trace(@src()); | 2130 | const tracy = trace(@src()); |
| 2131 | defer tracy.end(); | 2131 | defer tracy.end(); |
| 2132 | | 2132 | |
| ... | @@ -2139,7 +2139,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE | ... | @@ -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 | const tracy = trace(@src()); | 2143 | const tracy = trace(@src()); |
| 2144 | defer tracy.end(); | 2144 | defer tracy.end(); |
| 2145 | | 2145 | |
| ... | @@ -2152,7 +2152,7 @@ fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) I | ... | @@ -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 | const mod = sema.mod; | 2156 | const mod = sema.mod; |
| 2157 | const arena = sema.arena; | 2157 | const arena = sema.arena; |
| 2158 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 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,12 +2234,12 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2234 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); | 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 | const mod = sema.mod; | 2238 | const mod = sema.mod; |
| 2239 | const target = mod.getTarget(); | 2239 | const target = mod.getTarget(); |
| 2240 | const arena = sema.arena; | 2240 | const arena = sema.arena; |
| 2241 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src = inst_data.src(); | 2243 | const src = inst_data.src(); |
| 2244 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2244 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2245 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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,7 +2293,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2293 | fn zirOptionalPayloadPtr( | 2293 | fn zirOptionalPayloadPtr( |
| 2294 | sema: *Sema, | 2294 | sema: *Sema, |
| 2295 | block: *Scope.Block, | 2295 | block: *Scope.Block, |
| 2296 | inst: zir.Inst.Index, | 2296 | inst: Zir.Inst.Index, |
| 2297 | safety_check: bool, | 2297 | safety_check: bool, |
| 2298 | ) InnerError!*Inst { | 2298 | ) InnerError!*Inst { |
| 2299 | const tracy = trace(@src()); | 2299 | const tracy = trace(@src()); |
| ... | @@ -2336,7 +2336,7 @@ fn zirOptionalPayloadPtr( | ... | @@ -2336,7 +2336,7 @@ fn zirOptionalPayloadPtr( |
| 2336 | fn zirOptionalPayload( | 2336 | fn zirOptionalPayload( |
| 2337 | sema: *Sema, | 2337 | sema: *Sema, |
| 2338 | block: *Scope.Block, | 2338 | block: *Scope.Block, |
| 2339 | inst: zir.Inst.Index, | 2339 | inst: Zir.Inst.Index, |
| 2340 | safety_check: bool, | 2340 | safety_check: bool, |
| 2341 | ) InnerError!*Inst { | 2341 | ) InnerError!*Inst { |
| 2342 | const tracy = trace(@src()); | 2342 | const tracy = trace(@src()); |
| ... | @@ -2374,7 +2374,7 @@ fn zirOptionalPayload( | ... | @@ -2374,7 +2374,7 @@ fn zirOptionalPayload( |
| 2374 | fn zirErrUnionPayload( | 2374 | fn zirErrUnionPayload( |
| 2375 | sema: *Sema, | 2375 | sema: *Sema, |
| 2376 | block: *Scope.Block, | 2376 | block: *Scope.Block, |
| 2377 | inst: zir.Inst.Index, | 2377 | inst: Zir.Inst.Index, |
| 2378 | safety_check: bool, | 2378 | safety_check: bool, |
| 2379 | ) InnerError!*Inst { | 2379 | ) InnerError!*Inst { |
| 2380 | const tracy = trace(@src()); | 2380 | const tracy = trace(@src()); |
| ... | @@ -2408,7 +2408,7 @@ fn zirErrUnionPayload( | ... | @@ -2408,7 +2408,7 @@ fn zirErrUnionPayload( |
| 2408 | fn zirErrUnionPayloadPtr( | 2408 | fn zirErrUnionPayloadPtr( |
| 2409 | sema: *Sema, | 2409 | sema: *Sema, |
| 2410 | block: *Scope.Block, | 2410 | block: *Scope.Block, |
| 2411 | inst: zir.Inst.Index, | 2411 | inst: Zir.Inst.Index, |
| 2412 | safety_check: bool, | 2412 | safety_check: bool, |
| 2413 | ) InnerError!*Inst { | 2413 | ) InnerError!*Inst { |
| 2414 | const tracy = trace(@src()); | 2414 | const tracy = trace(@src()); |
| ... | @@ -2449,7 +2449,7 @@ fn zirErrUnionPayloadPtr( | ... | @@ -2449,7 +2449,7 @@ fn zirErrUnionPayloadPtr( |
| 2449 | } | 2449 | } |
| 2450 | | 2450 | |
| 2451 | /// Value in, value out | 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 | const tracy = trace(@src()); | 2453 | const tracy = trace(@src()); |
| 2454 | defer tracy.end(); | 2454 | defer tracy.end(); |
| 2455 | | 2455 | |
| ... | @@ -2473,7 +2473,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner | ... | @@ -2473,7 +2473,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner |
| 2473 | } | 2473 | } |
| 2474 | | 2474 | |
| 2475 | /// Pointer in, value out | 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 | const tracy = trace(@src()); | 2477 | const tracy = trace(@src()); |
| 2478 | defer tracy.end(); | 2478 | defer tracy.end(); |
| 2479 | | 2479 | |
| ... | @@ -2499,7 +2499,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In | ... | @@ -2499,7 +2499,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In |
| 2499 | return block.addUnOp(src, operand.ty.castTag(.error_union).?.data.payload, .unwrap_errunion_err_ptr, operand); | 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 | const tracy = trace(@src()); | 2503 | const tracy = trace(@src()); |
| 2504 | defer tracy.end(); | 2504 | defer tracy.end(); |
| 2505 | | 2505 | |
| ... | @@ -2513,13 +2513,13 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde | ... | @@ -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 | const tracy = trace(@src()); | 2517 | const tracy = trace(@src()); |
| 2518 | defer tracy.end(); | 2518 | defer tracy.end(); |
| 2519 | | 2519 | |
| 2520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2521 | const src = inst_data.src(); | 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 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); | 2523 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); |
| 2524 | | 2524 | |
| 2525 | return sema.fnTypeCommon( | 2525 | return sema.fnTypeCommon( |
| ... | @@ -2532,14 +2532,14 @@ fn zirFnType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: b | ... | @@ -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 | const tracy = trace(@src()); | 2536 | const tracy = trace(@src()); |
| 2537 | defer tracy.end(); | 2537 | defer tracy.end(); |
| 2538 | | 2538 | |
| 2539 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2539 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2540 | const src = inst_data.src(); | 2540 | const src = inst_data.src(); |
| 2541 | const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = inst_data.src_node }; | 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 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); | 2543 | const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len); |
| 2544 | | 2544 | |
| 2545 | const cc_tv = try sema.resolveInstConst(block, cc_src, extra.data.cc); | 2545 | const cc_tv = try sema.resolveInstConst(block, cc_src, extra.data.cc); |
| ... | @@ -2562,8 +2562,8 @@ fn fnTypeCommon( | ... | @@ -2562,8 +2562,8 @@ fn fnTypeCommon( |
| 2562 | sema: *Sema, | 2562 | sema: *Sema, |
| 2563 | block: *Scope.Block, | 2563 | block: *Scope.Block, |
| 2564 | src_node_offset: i32, | 2564 | src_node_offset: i32, |
| 2565 | zir_param_types: []const zir.Inst.Ref, | 2565 | zir_param_types: []const Zir.Inst.Ref, |
| 2566 | zir_return_type: zir.Inst.Ref, | 2566 | zir_return_type: Zir.Inst.Ref, |
| 2567 | cc: std.builtin.CallingConvention, | 2567 | cc: std.builtin.CallingConvention, |
| 2568 | var_args: bool, | 2568 | var_args: bool, |
| 2569 | ) InnerError!*Inst { | 2569 | ) InnerError!*Inst { |
| ... | @@ -2608,7 +2608,7 @@ fn fnTypeCommon( | ... | @@ -2608,7 +2608,7 @@ fn fnTypeCommon( |
| 2608 | return sema.mod.constType(sema.arena, src, fn_ty); | 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 | const tracy = trace(@src()); | 2612 | const tracy = trace(@src()); |
| 2613 | defer tracy.end(); | 2613 | defer tracy.end(); |
| 2614 | | 2614 | |
| ... | @@ -2616,13 +2616,13 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Ins | ... | @@ -2616,13 +2616,13 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Ins |
| 2616 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); | 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 | const tracy = trace(@src()); | 2620 | const tracy = trace(@src()); |
| 2621 | defer tracy.end(); | 2621 | defer tracy.end(); |
| 2622 | | 2622 | |
| 2623 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2623 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2624 | const src = inst_data.src(); | 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 | return sema.analyzeAs(block, src, extra.dest_type, extra.operand); | 2626 | return sema.analyzeAs(block, src, extra.dest_type, extra.operand); |
| 2627 | } | 2627 | } |
| 2628 | | 2628 | |
| ... | @@ -2630,15 +2630,15 @@ fn analyzeAs( | ... | @@ -2630,15 +2630,15 @@ fn analyzeAs( |
| 2630 | sema: *Sema, | 2630 | sema: *Sema, |
| 2631 | block: *Scope.Block, | 2631 | block: *Scope.Block, |
| 2632 | src: LazySrcLoc, | 2632 | src: LazySrcLoc, |
| 2633 | zir_dest_type: zir.Inst.Ref, | 2633 | zir_dest_type: Zir.Inst.Ref, |
| 2634 | zir_operand: zir.Inst.Ref, | 2634 | zir_operand: Zir.Inst.Ref, |
| 2635 | ) InnerError!*Inst { | 2635 | ) InnerError!*Inst { |
| 2636 | const dest_type = try sema.resolveType(block, src, zir_dest_type); | 2636 | const dest_type = try sema.resolveType(block, src, zir_dest_type); |
| 2637 | const operand = try sema.resolveInst(zir_operand); | 2637 | const operand = try sema.resolveInst(zir_operand); |
| 2638 | return sema.coerce(block, dest_type, operand, src); | 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 | const tracy = trace(@src()); | 2642 | const tracy = trace(@src()); |
| 2643 | defer tracy.end(); | 2643 | defer tracy.end(); |
| 2644 | | 2644 | |
| ... | @@ -2655,14 +2655,14 @@ fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro | ... | @@ -2655,14 +2655,14 @@ fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2655 | return block.addUnOp(src, ty, .ptrtoint, ptr); | 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 | const tracy = trace(@src()); | 2659 | const tracy = trace(@src()); |
| 2660 | defer tracy.end(); | 2660 | defer tracy.end(); |
| 2661 | | 2661 | |
| 2662 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2662 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2663 | const src = inst_data.src(); | 2663 | const src = inst_data.src(); |
| 2664 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 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 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 2666 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 2667 | const object = try sema.resolveInst(extra.lhs); | 2667 | const object = try sema.resolveInst(extra.lhs); |
| 2668 | const object_ptr = if (object.ty.zigTypeTag() == .Pointer) | 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,27 +2673,27 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2673 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); | 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 | const tracy = trace(@src()); | 2677 | const tracy = trace(@src()); |
| 2678 | defer tracy.end(); | 2678 | defer tracy.end(); |
| 2679 | | 2679 | |
| 2680 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2680 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2681 | const src = inst_data.src(); | 2681 | const src = inst_data.src(); |
| 2682 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 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 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 2684 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 2685 | const object_ptr = try sema.resolveInst(extra.lhs); | 2685 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 2686 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 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 | const tracy = trace(@src()); | 2690 | const tracy = trace(@src()); |
| 2691 | defer tracy.end(); | 2691 | defer tracy.end(); |
| 2692 | | 2692 | |
| 2693 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2693 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2694 | const src = inst_data.src(); | 2694 | const src = inst_data.src(); |
| 2695 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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 | const object = try sema.resolveInst(extra.lhs); | 2697 | const object = try sema.resolveInst(extra.lhs); |
| 2698 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 2698 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 2699 | const object_ptr = try sema.analyzeRef(block, src, object); | 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,20 +2701,20 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 2701 | return sema.analyzeLoad(block, src, result_ptr, src); | 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 | const tracy = trace(@src()); | 2705 | const tracy = trace(@src()); |
| 2706 | defer tracy.end(); | 2706 | defer tracy.end(); |
| 2707 | | 2707 | |
| 2708 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2708 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2709 | const src = inst_data.src(); | 2709 | const src = inst_data.src(); |
| 2710 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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 | const object_ptr = try sema.resolveInst(extra.lhs); | 2712 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 2713 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 2713 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 2714 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 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 | const tracy = trace(@src()); | 2718 | const tracy = trace(@src()); |
| 2719 | defer tracy.end(); | 2719 | defer tracy.end(); |
| 2720 | | 2720 | |
| ... | @@ -2722,7 +2722,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -2722,7 +2722,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2722 | const src = inst_data.src(); | 2722 | const src = inst_data.src(); |
| 2723 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2723 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2724 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 2727 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2728 | const operand = try sema.resolveInst(extra.rhs); | 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,7 +2757,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2757 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); | 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 | const tracy = trace(@src()); | 2761 | const tracy = trace(@src()); |
| 2762 | defer tracy.end(); | 2762 | defer tracy.end(); |
| 2763 | | 2763 | |
| ... | @@ -2765,14 +2765,14 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -2765,14 +2765,14 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2765 | const src = inst_data.src(); | 2765 | const src = inst_data.src(); |
| 2766 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2766 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2767 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 2770 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2771 | const operand = try sema.resolveInst(extra.rhs); | 2771 | const operand = try sema.resolveInst(extra.rhs); |
| 2772 | return sema.bitcast(block, dest_type, operand); | 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 | const tracy = trace(@src()); | 2776 | const tracy = trace(@src()); |
| 2777 | defer tracy.end(); | 2777 | defer tracy.end(); |
| 2778 | | 2778 | |
| ... | @@ -2780,7 +2780,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr | ... | @@ -2780,7 +2780,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2780 | const src = inst_data.src(); | 2780 | const src = inst_data.src(); |
| 2781 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2781 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2782 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 2785 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2786 | const operand = try sema.resolveInst(extra.rhs); | 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,7 +2815,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 2815 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); | 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 | const tracy = trace(@src()); | 2819 | const tracy = trace(@src()); |
| 2820 | defer tracy.end(); | 2820 | defer tracy.end(); |
| 2821 | | 2821 | |
| ... | @@ -2830,14 +2830,14 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -2830,14 +2830,14 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2830 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); | 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 | const tracy = trace(@src()); | 2834 | const tracy = trace(@src()); |
| 2835 | defer tracy.end(); | 2835 | defer tracy.end(); |
| 2836 | | 2836 | |
| 2837 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2837 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2838 | const src = inst_data.src(); | 2838 | const src = inst_data.src(); |
| 2839 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 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 | const array = try sema.resolveInst(extra.lhs); | 2841 | const array = try sema.resolveInst(extra.lhs); |
| 2842 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) | 2842 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) |
| 2843 | array | 2843 | array |
| ... | @@ -2848,7 +2848,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE | ... | @@ -2848,7 +2848,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 2848 | return sema.analyzeLoad(block, src, result_ptr, src); | 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 | const tracy = trace(@src()); | 2852 | const tracy = trace(@src()); |
| 2853 | defer tracy.end(); | 2853 | defer tracy.end(); |
| 2854 | | 2854 | |
| ... | @@ -2858,39 +2858,39 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -2858,39 +2858,39 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 2858 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); | 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 | const tracy = trace(@src()); | 2862 | const tracy = trace(@src()); |
| 2863 | defer tracy.end(); | 2863 | defer tracy.end(); |
| 2864 | | 2864 | |
| 2865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2865 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2866 | const src = inst_data.src(); | 2866 | const src = inst_data.src(); |
| 2867 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 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 | const array_ptr = try sema.resolveInst(extra.lhs); | 2869 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2870 | const elem_index = try sema.resolveInst(extra.rhs); | 2870 | const elem_index = try sema.resolveInst(extra.rhs); |
| 2871 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); | 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 | const tracy = trace(@src()); | 2875 | const tracy = trace(@src()); |
| 2876 | defer tracy.end(); | 2876 | defer tracy.end(); |
| 2877 | | 2877 | |
| 2878 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2878 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2879 | const src = inst_data.src(); | 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 | const array_ptr = try sema.resolveInst(extra.lhs); | 2881 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2882 | const start = try sema.resolveInst(extra.start); | 2882 | const start = try sema.resolveInst(extra.start); |
| 2883 | | 2883 | |
| 2884 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); | 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 | const tracy = trace(@src()); | 2888 | const tracy = trace(@src()); |
| 2889 | defer tracy.end(); | 2889 | defer tracy.end(); |
| 2890 | | 2890 | |
| 2891 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2891 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2892 | const src = inst_data.src(); | 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 | const array_ptr = try sema.resolveInst(extra.lhs); | 2894 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2895 | const start = try sema.resolveInst(extra.start); | 2895 | const start = try sema.resolveInst(extra.start); |
| 2896 | const end = try sema.resolveInst(extra.end); | 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,14 +2898,14 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 2898 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); | 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 | const tracy = trace(@src()); | 2902 | const tracy = trace(@src()); |
| 2903 | defer tracy.end(); | 2903 | defer tracy.end(); |
| 2904 | | 2904 | |
| 2905 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2905 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2906 | const src = inst_data.src(); | 2906 | const src = inst_data.src(); |
| 2907 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; | 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 | const array_ptr = try sema.resolveInst(extra.lhs); | 2909 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 2910 | const start = try sema.resolveInst(extra.start); | 2910 | const start = try sema.resolveInst(extra.start); |
| 2911 | const end = try sema.resolveInst(extra.end); | 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,7 +2917,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 2917 | fn zirSwitchCapture( | 2917 | fn zirSwitchCapture( |
| 2918 | sema: *Sema, | 2918 | sema: *Sema, |
| 2919 | block: *Scope.Block, | 2919 | block: *Scope.Block, |
| 2920 | inst: zir.Inst.Index, | 2920 | inst: Zir.Inst.Index, |
| 2921 | is_multi: bool, | 2921 | is_multi: bool, |
| 2922 | is_ref: bool, | 2922 | is_ref: bool, |
| 2923 | ) InnerError!*Inst { | 2923 | ) InnerError!*Inst { |
| ... | @@ -2935,7 +2935,7 @@ fn zirSwitchCapture( | ... | @@ -2935,7 +2935,7 @@ fn zirSwitchCapture( |
| 2935 | fn zirSwitchCaptureElse( | 2935 | fn zirSwitchCaptureElse( |
| 2936 | sema: *Sema, | 2936 | sema: *Sema, |
| 2937 | block: *Scope.Block, | 2937 | block: *Scope.Block, |
| 2938 | inst: zir.Inst.Index, | 2938 | inst: Zir.Inst.Index, |
| 2939 | is_ref: bool, | 2939 | is_ref: bool, |
| 2940 | ) InnerError!*Inst { | 2940 | ) InnerError!*Inst { |
| 2941 | const tracy = trace(@src()); | 2941 | const tracy = trace(@src()); |
| ... | @@ -2952,9 +2952,9 @@ fn zirSwitchCaptureElse( | ... | @@ -2952,9 +2952,9 @@ fn zirSwitchCaptureElse( |
| 2952 | fn zirSwitchBlock( | 2952 | fn zirSwitchBlock( |
| 2953 | sema: *Sema, | 2953 | sema: *Sema, |
| 2954 | block: *Scope.Block, | 2954 | block: *Scope.Block, |
| 2955 | inst: zir.Inst.Index, | 2955 | inst: Zir.Inst.Index, |
| 2956 | is_ref: bool, | 2956 | is_ref: bool, |
| 2957 | special_prong: zir.SpecialProng, | 2957 | special_prong: Zir.SpecialProng, |
| 2958 | ) InnerError!*Inst { | 2958 | ) InnerError!*Inst { |
| 2959 | const tracy = trace(@src()); | 2959 | const tracy = trace(@src()); |
| 2960 | defer tracy.end(); | 2960 | defer tracy.end(); |
| ... | @@ -2962,7 +2962,7 @@ fn zirSwitchBlock( | ... | @@ -2962,7 +2962,7 @@ fn zirSwitchBlock( |
| 2962 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2962 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2963 | const src = inst_data.src(); | 2963 | const src = inst_data.src(); |
| 2964 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; | 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 | const operand_ptr = try sema.resolveInst(extra.data.operand); | 2967 | const operand_ptr = try sema.resolveInst(extra.data.operand); |
| 2968 | const operand = if (is_ref) | 2968 | const operand = if (is_ref) |
| ... | @@ -2985,9 +2985,9 @@ fn zirSwitchBlock( | ... | @@ -2985,9 +2985,9 @@ fn zirSwitchBlock( |
| 2985 | fn zirSwitchBlockMulti( | 2985 | fn zirSwitchBlockMulti( |
| 2986 | sema: *Sema, | 2986 | sema: *Sema, |
| 2987 | block: *Scope.Block, | 2987 | block: *Scope.Block, |
| 2988 | inst: zir.Inst.Index, | 2988 | inst: Zir.Inst.Index, |
| 2989 | is_ref: bool, | 2989 | is_ref: bool, |
| 2990 | special_prong: zir.SpecialProng, | 2990 | special_prong: Zir.SpecialProng, |
| 2991 | ) InnerError!*Inst { | 2991 | ) InnerError!*Inst { |
| 2992 | const tracy = trace(@src()); | 2992 | const tracy = trace(@src()); |
| 2993 | defer tracy.end(); | 2993 | defer tracy.end(); |
| ... | @@ -2995,7 +2995,7 @@ fn zirSwitchBlockMulti( | ... | @@ -2995,7 +2995,7 @@ fn zirSwitchBlockMulti( |
| 2995 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2995 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2996 | const src = inst_data.src(); | 2996 | const src = inst_data.src(); |
| 2997 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; | 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 | const operand_ptr = try sema.resolveInst(extra.data.operand); | 3000 | const operand_ptr = try sema.resolveInst(extra.data.operand); |
| 3001 | const operand = if (is_ref) | 3001 | const operand = if (is_ref) |
| ... | @@ -3020,16 +3020,16 @@ fn analyzeSwitch( | ... | @@ -3020,16 +3020,16 @@ fn analyzeSwitch( |
| 3020 | block: *Scope.Block, | 3020 | block: *Scope.Block, |
| 3021 | operand: *Inst, | 3021 | operand: *Inst, |
| 3022 | extra_end: usize, | 3022 | extra_end: usize, |
| 3023 | special_prong: zir.SpecialProng, | 3023 | special_prong: Zir.SpecialProng, |
| 3024 | scalar_cases_len: usize, | 3024 | scalar_cases_len: usize, |
| 3025 | multi_cases_len: usize, | 3025 | multi_cases_len: usize, |
| 3026 | switch_inst: zir.Inst.Index, | 3026 | switch_inst: Zir.Inst.Index, |
| 3027 | src_node_offset: i32, | 3027 | src_node_offset: i32, |
| 3028 | ) InnerError!*Inst { | 3028 | ) InnerError!*Inst { |
| 3029 | const gpa = sema.gpa; | 3029 | const gpa = sema.gpa; |
| 3030 | const mod = sema.mod; | 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 | .none => .{ .body = &.{}, .end = extra_end }, | 3033 | .none => .{ .body = &.{}, .end = extra_end }, |
| 3034 | .under, .@"else" => blk: { | 3034 | .under, .@"else" => blk: { |
| 3035 | const body_len = sema.code.extra[extra_end]; | 3035 | const body_len = sema.code.extra[extra_end]; |
| ... | @@ -3079,7 +3079,7 @@ fn analyzeSwitch( | ... | @@ -3079,7 +3079,7 @@ fn analyzeSwitch( |
| 3079 | { | 3079 | { |
| 3080 | var scalar_i: u32 = 0; | 3080 | var scalar_i: u32 = 0; |
| 3081 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3083 | extra_index += 1; |
| 3084 | const body_len = sema.code.extra[extra_index]; | 3084 | const body_len = sema.code.extra[extra_index]; |
| 3085 | extra_index += 1; | 3085 | extra_index += 1; |
| ... | @@ -3189,7 +3189,7 @@ fn analyzeSwitch( | ... | @@ -3189,7 +3189,7 @@ fn analyzeSwitch( |
| 3189 | { | 3189 | { |
| 3190 | var scalar_i: u32 = 0; | 3190 | var scalar_i: u32 = 0; |
| 3191 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3193 | extra_index += 1; |
| 3194 | const body_len = sema.code.extra[extra_index]; | 3194 | const body_len = sema.code.extra[extra_index]; |
| 3195 | extra_index += 1; | 3195 | extra_index += 1; |
| ... | @@ -3229,9 +3229,9 @@ fn analyzeSwitch( | ... | @@ -3229,9 +3229,9 @@ fn analyzeSwitch( |
| 3229 | | 3229 | |
| 3230 | var range_i: u32 = 0; | 3230 | var range_i: u32 = 0; |
| 3231 | while (range_i < ranges_len) : (range_i += 1) { | 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 | extra_index += 1; | 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 | extra_index += 1; | 3235 | extra_index += 1; |
| 3236 | | 3236 | |
| 3237 | try sema.validateSwitchRange( | 3237 | try sema.validateSwitchRange( |
| ... | @@ -3285,7 +3285,7 @@ fn analyzeSwitch( | ... | @@ -3285,7 +3285,7 @@ fn analyzeSwitch( |
| 3285 | { | 3285 | { |
| 3286 | var scalar_i: u32 = 0; | 3286 | var scalar_i: u32 = 0; |
| 3287 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3289 | extra_index += 1; |
| 3290 | const body_len = sema.code.extra[extra_index]; | 3290 | const body_len = sema.code.extra[extra_index]; |
| 3291 | extra_index += 1; | 3291 | extra_index += 1; |
| ... | @@ -3368,7 +3368,7 @@ fn analyzeSwitch( | ... | @@ -3368,7 +3368,7 @@ fn analyzeSwitch( |
| 3368 | { | 3368 | { |
| 3369 | var scalar_i: u32 = 0; | 3369 | var scalar_i: u32 = 0; |
| 3370 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3372 | extra_index += 1; |
| 3373 | const body_len = sema.code.extra[extra_index]; | 3373 | const body_len = sema.code.extra[extra_index]; |
| 3374 | extra_index += 1; | 3374 | extra_index += 1; |
| ... | @@ -3435,7 +3435,7 @@ fn analyzeSwitch( | ... | @@ -3435,7 +3435,7 @@ fn analyzeSwitch( |
| 3435 | { | 3435 | { |
| 3436 | var scalar_i: usize = 0; | 3436 | var scalar_i: usize = 0; |
| 3437 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3439 | extra_index += 1; |
| 3440 | const body_len = sema.code.extra[extra_index]; | 3440 | const body_len = sema.code.extra[extra_index]; |
| 3441 | extra_index += 1; | 3441 | extra_index += 1; |
| ... | @@ -3474,9 +3474,9 @@ fn analyzeSwitch( | ... | @@ -3474,9 +3474,9 @@ fn analyzeSwitch( |
| 3474 | | 3474 | |
| 3475 | var range_i: usize = 0; | 3475 | var range_i: usize = 0; |
| 3476 | while (range_i < ranges_len) : (range_i += 1) { | 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 | extra_index += 1; | 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 | extra_index += 1; | 3480 | extra_index += 1; |
| 3481 | | 3481 | |
| 3482 | // Validation above ensured these will succeed. | 3482 | // Validation above ensured these will succeed. |
| ... | @@ -3544,7 +3544,7 @@ fn analyzeSwitch( | ... | @@ -3544,7 +3544,7 @@ fn analyzeSwitch( |
| 3544 | | 3544 | |
| 3545 | var scalar_i: usize = 0; | 3545 | var scalar_i: usize = 0; |
| 3546 | while (scalar_i < scalar_cases_len) : (scalar_i += 1) { | 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 | extra_index += 1; | 3548 | extra_index += 1; |
| 3549 | const body_len = sema.code.extra[extra_index]; | 3549 | const body_len = sema.code.extra[extra_index]; |
| 3550 | extra_index += 1; | 3550 | extra_index += 1; |
| ... | @@ -3597,9 +3597,9 @@ fn analyzeSwitch( | ... | @@ -3597,9 +3597,9 @@ fn analyzeSwitch( |
| 3597 | | 3597 | |
| 3598 | var range_i: usize = 0; | 3598 | var range_i: usize = 0; |
| 3599 | while (range_i < ranges_len) : (range_i += 1) { | 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 | extra_index += 1; | 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 | extra_index += 1; | 3603 | extra_index += 1; |
| 3604 | | 3604 | |
| 3605 | const item_first = try sema.resolveInst(first_ref); | 3605 | const item_first = try sema.resolveInst(first_ref); |
| ... | @@ -3696,7 +3696,7 @@ fn analyzeSwitch( | ... | @@ -3696,7 +3696,7 @@ fn analyzeSwitch( |
| 3696 | fn resolveSwitchItemVal( | 3696 | fn resolveSwitchItemVal( |
| 3697 | sema: *Sema, | 3697 | sema: *Sema, |
| 3698 | block: *Scope.Block, | 3698 | block: *Scope.Block, |
| 3699 | item_ref: zir.Inst.Ref, | 3699 | item_ref: Zir.Inst.Ref, |
| 3700 | switch_node_offset: i32, | 3700 | switch_node_offset: i32, |
| 3701 | switch_prong_src: AstGen.SwitchProngSrc, | 3701 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3702 | range_expand: AstGen.SwitchProngSrc.RangeExpand, | 3702 | range_expand: AstGen.SwitchProngSrc.RangeExpand, |
| ... | @@ -3720,8 +3720,8 @@ fn validateSwitchRange( | ... | @@ -3720,8 +3720,8 @@ fn validateSwitchRange( |
| 3720 | sema: *Sema, | 3720 | sema: *Sema, |
| 3721 | block: *Scope.Block, | 3721 | block: *Scope.Block, |
| 3722 | range_set: *RangeSet, | 3722 | range_set: *RangeSet, |
| 3723 | first_ref: zir.Inst.Ref, | 3723 | first_ref: Zir.Inst.Ref, |
| 3724 | last_ref: zir.Inst.Ref, | 3724 | last_ref: Zir.Inst.Ref, |
| 3725 | src_node_offset: i32, | 3725 | src_node_offset: i32, |
| 3726 | switch_prong_src: AstGen.SwitchProngSrc, | 3726 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3727 | ) InnerError!void { | 3727 | ) InnerError!void { |
| ... | @@ -3735,7 +3735,7 @@ fn validateSwitchItem( | ... | @@ -3735,7 +3735,7 @@ fn validateSwitchItem( |
| 3735 | sema: *Sema, | 3735 | sema: *Sema, |
| 3736 | block: *Scope.Block, | 3736 | block: *Scope.Block, |
| 3737 | range_set: *RangeSet, | 3737 | range_set: *RangeSet, |
| 3738 | item_ref: zir.Inst.Ref, | 3738 | item_ref: Zir.Inst.Ref, |
| 3739 | src_node_offset: i32, | 3739 | src_node_offset: i32, |
| 3740 | switch_prong_src: AstGen.SwitchProngSrc, | 3740 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3741 | ) InnerError!void { | 3741 | ) InnerError!void { |
| ... | @@ -3748,7 +3748,7 @@ fn validateSwitchItemEnum( | ... | @@ -3748,7 +3748,7 @@ fn validateSwitchItemEnum( |
| 3748 | sema: *Sema, | 3748 | sema: *Sema, |
| 3749 | block: *Scope.Block, | 3749 | block: *Scope.Block, |
| 3750 | seen_fields: []?AstGen.SwitchProngSrc, | 3750 | seen_fields: []?AstGen.SwitchProngSrc, |
| 3751 | item_ref: zir.Inst.Ref, | 3751 | item_ref: Zir.Inst.Ref, |
| 3752 | src_node_offset: i32, | 3752 | src_node_offset: i32, |
| 3753 | switch_prong_src: AstGen.SwitchProngSrc, | 3753 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3754 | ) InnerError!void { | 3754 | ) InnerError!void { |
| ... | @@ -3815,7 +3815,7 @@ fn validateSwitchItemBool( | ... | @@ -3815,7 +3815,7 @@ fn validateSwitchItemBool( |
| 3815 | block: *Scope.Block, | 3815 | block: *Scope.Block, |
| 3816 | true_count: *u8, | 3816 | true_count: *u8, |
| 3817 | false_count: *u8, | 3817 | false_count: *u8, |
| 3818 | item_ref: zir.Inst.Ref, | 3818 | item_ref: Zir.Inst.Ref, |
| 3819 | src_node_offset: i32, | 3819 | src_node_offset: i32, |
| 3820 | switch_prong_src: AstGen.SwitchProngSrc, | 3820 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3821 | ) InnerError!void { | 3821 | ) InnerError!void { |
| ... | @@ -3837,7 +3837,7 @@ fn validateSwitchItemSparse( | ... | @@ -3837,7 +3837,7 @@ fn validateSwitchItemSparse( |
| 3837 | sema: *Sema, | 3837 | sema: *Sema, |
| 3838 | block: *Scope.Block, | 3838 | block: *Scope.Block, |
| 3839 | seen_values: *ValueSrcMap, | 3839 | seen_values: *ValueSrcMap, |
| 3840 | item_ref: zir.Inst.Ref, | 3840 | item_ref: Zir.Inst.Ref, |
| 3841 | src_node_offset: i32, | 3841 | src_node_offset: i32, |
| 3842 | switch_prong_src: AstGen.SwitchProngSrc, | 3842 | switch_prong_src: AstGen.SwitchProngSrc, |
| 3843 | ) InnerError!void { | 3843 | ) InnerError!void { |
| ... | @@ -3879,12 +3879,12 @@ fn validateSwitchNoRange( | ... | @@ -3879,12 +3879,12 @@ fn validateSwitchNoRange( |
| 3879 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); | 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 | const tracy = trace(@src()); | 3883 | const tracy = trace(@src()); |
| 3884 | defer tracy.end(); | 3884 | defer tracy.end(); |
| 3885 | | 3885 | |
| 3886 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src = inst_data.src(); | 3888 | const src = inst_data.src(); |
| 3889 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 3889 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 3890 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 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,7 +3907,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 3907 | return mod.constBool(arena, src, false); | 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 | const tracy = trace(@src()); | 3911 | const tracy = trace(@src()); |
| 3912 | defer tracy.end(); | 3912 | defer tracy.end(); |
| 3913 | | 3913 | |
| ... | @@ -3933,13 +3933,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! | ... | @@ -3933,13 +3933,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 3933 | return mod.constType(sema.arena, src, file.namespace.ty); | 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 | const tracy = trace(@src()); | 3937 | const tracy = trace(@src()); |
| 3938 | defer tracy.end(); | 3938 | defer tracy.end(); |
| 3939 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); | 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 | const tracy = trace(@src()); | 3943 | const tracy = trace(@src()); |
| 3944 | defer tracy.end(); | 3944 | defer tracy.end(); |
| 3945 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{}); | 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,7 +3948,7 @@ fn zirShr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In |
| 3948 | fn zirBitwise( | 3948 | fn zirBitwise( |
| 3949 | sema: *Sema, | 3949 | sema: *Sema, |
| 3950 | block: *Scope.Block, | 3950 | block: *Scope.Block, |
| 3951 | inst: zir.Inst.Index, | 3951 | inst: Zir.Inst.Index, |
| 3952 | ir_tag: ir.Inst.Tag, | 3952 | ir_tag: ir.Inst.Tag, |
| 3953 | ) InnerError!*Inst { | 3953 | ) InnerError!*Inst { |
| 3954 | const tracy = trace(@src()); | 3954 | const tracy = trace(@src()); |
| ... | @@ -3958,7 +3958,7 @@ fn zirBitwise( | ... | @@ -3958,7 +3958,7 @@ fn zirBitwise( |
| 3958 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 3958 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 3959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 3959 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 3960 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 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 | const lhs = try sema.resolveInst(extra.lhs); | 3962 | const lhs = try sema.resolveInst(extra.lhs); |
| 3963 | const rhs = try sema.resolveInst(extra.rhs); | 3963 | const rhs = try sema.resolveInst(extra.rhs); |
| 3964 | | 3964 | |
| ... | @@ -4011,19 +4011,19 @@ fn zirBitwise( | ... | @@ -4011,19 +4011,19 @@ fn zirBitwise( |
| 4011 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 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 | const tracy = trace(@src()); | 4015 | const tracy = trace(@src()); |
| 4016 | defer tracy.end(); | 4016 | defer tracy.end(); |
| 4017 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); | 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 | const tracy = trace(@src()); | 4021 | const tracy = trace(@src()); |
| 4022 | defer tracy.end(); | 4022 | defer tracy.end(); |
| 4023 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); | 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 | const tracy = trace(@src()); | 4027 | const tracy = trace(@src()); |
| 4028 | defer tracy.end(); | 4028 | defer tracy.end(); |
| 4029 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{}); | 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,8 +4032,8 @@ fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 4032 | fn zirNegate( | 4032 | fn zirNegate( |
| 4033 | sema: *Sema, | 4033 | sema: *Sema, |
| 4034 | block: *Scope.Block, | 4034 | block: *Scope.Block, |
| 4035 | inst: zir.Inst.Index, | 4035 | inst: Zir.Inst.Index, |
| 4036 | tag_override: zir.Inst.Tag, | 4036 | tag_override: Zir.Inst.Tag, |
| 4037 | ) InnerError!*Inst { | 4037 | ) InnerError!*Inst { |
| 4038 | const tracy = trace(@src()); | 4038 | const tracy = trace(@src()); |
| 4039 | defer tracy.end(); | 4039 | defer tracy.end(); |
| ... | @@ -4048,7 +4048,7 @@ fn zirNegate( | ... | @@ -4048,7 +4048,7 @@ fn zirNegate( |
| 4048 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); | 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 | const tracy = trace(@src()); | 4052 | const tracy = trace(@src()); |
| 4053 | defer tracy.end(); | 4053 | defer tracy.end(); |
| 4054 | | 4054 | |
| ... | @@ -4057,7 +4057,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr | ... | @@ -4057,7 +4057,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4057 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 4057 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 4058 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4058 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4059 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 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 | const lhs = try sema.resolveInst(extra.lhs); | 4061 | const lhs = try sema.resolveInst(extra.lhs); |
| 4062 | const rhs = try sema.resolveInst(extra.rhs); | 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,7 +4067,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4067 | fn analyzeArithmetic( | 4067 | fn analyzeArithmetic( |
| 4068 | sema: *Sema, | 4068 | sema: *Sema, |
| 4069 | block: *Scope.Block, | 4069 | block: *Scope.Block, |
| 4070 | zir_tag: zir.Inst.Tag, | 4070 | zir_tag: Zir.Inst.Tag, |
| 4071 | lhs: *Inst, | 4071 | lhs: *Inst, |
| 4072 | rhs: *Inst, | 4072 | rhs: *Inst, |
| 4073 | src: LazySrcLoc, | 4073 | src: LazySrcLoc, |
| ... | @@ -4174,7 +4174,7 @@ fn analyzeArithmetic( | ... | @@ -4174,7 +4174,7 @@ fn analyzeArithmetic( |
| 4174 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 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 | const tracy = trace(@src()); | 4178 | const tracy = trace(@src()); |
| 4179 | defer tracy.end(); | 4179 | defer tracy.end(); |
| 4180 | | 4180 | |
| ... | @@ -4188,7 +4188,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*I | ... | @@ -4188,7 +4188,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*I |
| 4188 | fn zirAsm( | 4188 | fn zirAsm( |
| 4189 | sema: *Sema, | 4189 | sema: *Sema, |
| 4190 | block: *Scope.Block, | 4190 | block: *Scope.Block, |
| 4191 | inst: zir.Inst.Index, | 4191 | inst: Zir.Inst.Index, |
| 4192 | is_volatile: bool, | 4192 | is_volatile: bool, |
| 4193 | ) InnerError!*Inst { | 4193 | ) InnerError!*Inst { |
| 4194 | const tracy = trace(@src()); | 4194 | const tracy = trace(@src()); |
| ... | @@ -4198,7 +4198,7 @@ fn zirAsm( | ... | @@ -4198,7 +4198,7 @@ fn zirAsm( |
| 4198 | const src = inst_data.src(); | 4198 | const src = inst_data.src(); |
| 4199 | const asm_source_src: LazySrcLoc = .{ .node_offset_asm_source = inst_data.src_node }; | 4199 | const asm_source_src: LazySrcLoc = .{ .node_offset_asm_source = inst_data.src_node }; |
| 4200 | const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = inst_data.src_node }; | 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 | const return_type = try sema.resolveType(block, ret_ty_src, extra.data.return_type); | 4202 | const return_type = try sema.resolveType(block, ret_ty_src, extra.data.return_type); |
| 4203 | const asm_source = try sema.resolveConstString(block, asm_source_src, extra.data.asm_source); | 4203 | const asm_source = try sema.resolveConstString(block, asm_source_src, extra.data.asm_source); |
| 4204 | | 4204 | |
| ... | @@ -4218,7 +4218,7 @@ fn zirAsm( | ... | @@ -4218,7 +4218,7 @@ fn zirAsm( |
| 4218 | const clobbers = try sema.arena.alloc([]const u8, extra.data.clobbers_len); | 4218 | const clobbers = try sema.arena.alloc([]const u8, extra.data.clobbers_len); |
| 4219 | | 4219 | |
| 4220 | for (args) |*arg| { | 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 | extra_i += 1; | 4222 | extra_i += 1; |
| 4223 | } | 4223 | } |
| 4224 | for (inputs) |*name| { | 4224 | for (inputs) |*name| { |
| ... | @@ -4253,7 +4253,7 @@ fn zirAsm( | ... | @@ -4253,7 +4253,7 @@ fn zirAsm( |
| 4253 | fn zirCmp( | 4253 | fn zirCmp( |
| 4254 | sema: *Sema, | 4254 | sema: *Sema, |
| 4255 | block: *Scope.Block, | 4255 | block: *Scope.Block, |
| 4256 | inst: zir.Inst.Index, | 4256 | inst: Zir.Inst.Index, |
| 4257 | op: std.math.CompareOperator, | 4257 | op: std.math.CompareOperator, |
| 4258 | ) InnerError!*Inst { | 4258 | ) InnerError!*Inst { |
| 4259 | const tracy = trace(@src()); | 4259 | const tracy = trace(@src()); |
| ... | @@ -4262,7 +4262,7 @@ fn zirCmp( | ... | @@ -4262,7 +4262,7 @@ fn zirCmp( |
| 4262 | const mod = sema.mod; | 4262 | const mod = sema.mod; |
| 4263 | | 4263 | |
| 4264 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 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 | const src: LazySrcLoc = inst_data.src(); | 4266 | const src: LazySrcLoc = inst_data.src(); |
| 4267 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4267 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4268 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 4268 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| ... | @@ -4356,7 +4356,7 @@ fn zirCmp( | ... | @@ -4356,7 +4356,7 @@ fn zirCmp( |
| 4356 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4360 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4361 | const src = inst_data.src(); | 4361 | const src = inst_data.src(); |
| 4362 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 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,7 +4366,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError! |
| 4366 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4370 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4371 | const src = inst_data.src(); | 4371 | const src = inst_data.src(); |
| 4372 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 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,20 +4376,20 @@ fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr |
| 4376 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), bit_size); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4380 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4381 | const src = inst_data.src(); | 4381 | const src = inst_data.src(); |
| 4382 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeInfo", .{}); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4386 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4387 | const src = inst_data.src(); | 4387 | const src = inst_data.src(); |
| 4388 | const operand = try sema.resolveInst(inst_data.operand); | 4388 | const operand = try sema.resolveInst(inst_data.operand); |
| 4389 | return sema.mod.constType(sema.arena, src, operand.ty); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4393 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4394 | const src = inst_data.src(); | 4394 | const src = inst_data.src(); |
| 4395 | const operand_ptr = try sema.resolveInst(inst_data.operand); | 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,13 +4397,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4397 | return sema.mod.constType(sema.arena, src, elem_ty); | 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 | const tracy = trace(@src()); | 4401 | const tracy = trace(@src()); |
| 4402 | defer tracy.end(); | 4402 | defer tracy.end(); |
| 4403 | | 4403 | |
| 4404 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4404 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4405 | const src = inst_data.src(); | 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 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); | 4407 | const args = sema.code.refSlice(extra.end, extra.data.operands_len); |
| 4408 | | 4408 | |
| 4409 | const inst_list = try sema.gpa.alloc(*ir.Inst, extra.data.operands_len); | 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,7 +4417,7 @@ fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr |
| 4417 | return sema.mod.constType(sema.arena, src, result_type); | 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 | const tracy = trace(@src()); | 4421 | const tracy = trace(@src()); |
| 4422 | defer tracy.end(); | 4422 | defer tracy.end(); |
| 4423 | | 4423 | |
| ... | @@ -4437,7 +4437,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -4437,7 +4437,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 4437 | fn zirBoolOp( | 4437 | fn zirBoolOp( |
| 4438 | sema: *Sema, | 4438 | sema: *Sema, |
| 4439 | block: *Scope.Block, | 4439 | block: *Scope.Block, |
| 4440 | inst: zir.Inst.Index, | 4440 | inst: Zir.Inst.Index, |
| 4441 | comptime is_bool_or: bool, | 4441 | comptime is_bool_or: bool, |
| 4442 | ) InnerError!*Inst { | 4442 | ) InnerError!*Inst { |
| 4443 | const tracy = trace(@src()); | 4443 | const tracy = trace(@src()); |
| ... | @@ -4468,7 +4468,7 @@ fn zirBoolOp( | ... | @@ -4468,7 +4468,7 @@ fn zirBoolOp( |
| 4468 | fn zirBoolBr( | 4468 | fn zirBoolBr( |
| 4469 | sema: *Sema, | 4469 | sema: *Sema, |
| 4470 | parent_block: *Scope.Block, | 4470 | parent_block: *Scope.Block, |
| 4471 | inst: zir.Inst.Index, | 4471 | inst: Zir.Inst.Index, |
| 4472 | is_bool_or: bool, | 4472 | is_bool_or: bool, |
| 4473 | ) InnerError!*Inst { | 4473 | ) InnerError!*Inst { |
| 4474 | const tracy = trace(@src()); | 4474 | const tracy = trace(@src()); |
| ... | @@ -4478,7 +4478,7 @@ fn zirBoolBr( | ... | @@ -4478,7 +4478,7 @@ fn zirBoolBr( |
| 4478 | const inst_data = datas[inst].bool_br; | 4478 | const inst_data = datas[inst].bool_br; |
| 4479 | const src: LazySrcLoc = .unneeded; | 4479 | const src: LazySrcLoc = .unneeded; |
| 4480 | const lhs = try sema.resolveInst(inst_data.lhs); | 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 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 4482 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 4483 | | 4483 | |
| 4484 | if (try sema.resolveDefinedValue(parent_block, src, lhs)) |lhs_val| { | 4484 | if (try sema.resolveDefinedValue(parent_block, src, lhs)) |lhs_val| { |
| ... | @@ -4536,7 +4536,7 @@ fn zirBoolBr( | ... | @@ -4536,7 +4536,7 @@ fn zirBoolBr( |
| 4536 | fn zirIsNull( | 4536 | fn zirIsNull( |
| 4537 | sema: *Sema, | 4537 | sema: *Sema, |
| 4538 | block: *Scope.Block, | 4538 | block: *Scope.Block, |
| 4539 | inst: zir.Inst.Index, | 4539 | inst: Zir.Inst.Index, |
| 4540 | invert_logic: bool, | 4540 | invert_logic: bool, |
| 4541 | ) InnerError!*Inst { | 4541 | ) InnerError!*Inst { |
| 4542 | const tracy = trace(@src()); | 4542 | const tracy = trace(@src()); |
| ... | @@ -4551,7 +4551,7 @@ fn zirIsNull( | ... | @@ -4551,7 +4551,7 @@ fn zirIsNull( |
| 4551 | fn zirIsNullPtr( | 4551 | fn zirIsNullPtr( |
| 4552 | sema: *Sema, | 4552 | sema: *Sema, |
| 4553 | block: *Scope.Block, | 4553 | block: *Scope.Block, |
| 4554 | inst: zir.Inst.Index, | 4554 | inst: Zir.Inst.Index, |
| 4555 | invert_logic: bool, | 4555 | invert_logic: bool, |
| 4556 | ) InnerError!*Inst { | 4556 | ) InnerError!*Inst { |
| 4557 | const tracy = trace(@src()); | 4557 | const tracy = trace(@src()); |
| ... | @@ -4564,7 +4564,7 @@ fn zirIsNullPtr( | ... | @@ -4564,7 +4564,7 @@ fn zirIsNullPtr( |
| 4564 | return sema.analyzeIsNull(block, src, loaded, invert_logic); | 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 | const tracy = trace(@src()); | 4568 | const tracy = trace(@src()); |
| 4569 | defer tracy.end(); | 4569 | defer tracy.end(); |
| 4570 | | 4570 | |
| ... | @@ -4573,7 +4573,7 @@ fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* | ... | @@ -4573,7 +4573,7 @@ fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!* |
| 4573 | return sema.analyzeIsErr(block, inst_data.src(), operand); | 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 | const tracy = trace(@src()); | 4577 | const tracy = trace(@src()); |
| 4578 | defer tracy.end(); | 4578 | defer tracy.end(); |
| 4579 | | 4579 | |
| ... | @@ -4587,15 +4587,15 @@ fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro | ... | @@ -4587,15 +4587,15 @@ fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro |
| 4587 | fn zirCondbr( | 4587 | fn zirCondbr( |
| 4588 | sema: *Sema, | 4588 | sema: *Sema, |
| 4589 | parent_block: *Scope.Block, | 4589 | parent_block: *Scope.Block, |
| 4590 | inst: zir.Inst.Index, | 4590 | inst: Zir.Inst.Index, |
| 4591 | ) InnerError!zir.Inst.Index { | 4591 | ) InnerError!Zir.Inst.Index { |
| 4592 | const tracy = trace(@src()); | 4592 | const tracy = trace(@src()); |
| 4593 | defer tracy.end(); | 4593 | defer tracy.end(); |
| 4594 | | 4594 | |
| 4595 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4595 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4596 | const src = inst_data.src(); | 4596 | const src = inst_data.src(); |
| 4597 | const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node }; | 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 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; | 4600 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 4601 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; | 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,7 +4628,7 @@ fn zirCondbr( |
| 4628 | return always_noreturn; | 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 | const tracy = trace(@src()); | 4632 | const tracy = trace(@src()); |
| 4633 | defer tracy.end(); | 4633 | defer tracy.end(); |
| 4634 | | 4634 | |
| ... | @@ -4648,9 +4648,9 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE | ... | @@ -4648,9 +4648,9 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE |
| 4648 | fn zirRetTok( | 4648 | fn zirRetTok( |
| 4649 | sema: *Sema, | 4649 | sema: *Sema, |
| 4650 | block: *Scope.Block, | 4650 | block: *Scope.Block, |
| 4651 | inst: zir.Inst.Index, | 4651 | inst: Zir.Inst.Index, |
| 4652 | need_coercion: bool, | 4652 | need_coercion: bool, |
| 4653 | ) InnerError!zir.Inst.Index { | 4653 | ) InnerError!Zir.Inst.Index { |
| 4654 | const tracy = trace(@src()); | 4654 | const tracy = trace(@src()); |
| 4655 | defer tracy.end(); | 4655 | defer tracy.end(); |
| 4656 | | 4656 | |
| ... | @@ -4661,7 +4661,7 @@ fn zirRetTok( | ... | @@ -4661,7 +4661,7 @@ fn zirRetTok( |
| 4661 | return sema.analyzeRet(block, operand, src, need_coercion); | 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 | const tracy = trace(@src()); | 4665 | const tracy = trace(@src()); |
| 4666 | defer tracy.end(); | 4666 | defer tracy.end(); |
| 4667 | | 4667 | |
| ... | @@ -4678,7 +4678,7 @@ fn analyzeRet( | ... | @@ -4678,7 +4678,7 @@ fn analyzeRet( |
| 4678 | operand: *Inst, | 4678 | operand: *Inst, |
| 4679 | src: LazySrcLoc, | 4679 | src: LazySrcLoc, |
| 4680 | need_coercion: bool, | 4680 | need_coercion: bool, |
| 4681 | ) InnerError!zir.Inst.Index { | 4681 | ) InnerError!Zir.Inst.Index { |
| 4682 | if (block.inlining) |inlining| { | 4682 | if (block.inlining) |inlining| { |
| 4683 | // We are inlining a function call; rewrite the `ret` as a `break`. | 4683 | // We are inlining a function call; rewrite the `ret` as a `break`. |
| 4684 | try inlining.merges.results.append(sema.gpa, operand); | 4684 | try inlining.merges.results.append(sema.gpa, operand); |
| ... | @@ -4702,7 +4702,7 @@ fn analyzeRet( | ... | @@ -4702,7 +4702,7 @@ fn analyzeRet( |
| 4702 | return always_noreturn; | 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 | // extend this swich as additional operators are implemented | 4706 | // extend this swich as additional operators are implemented |
| 4707 | return switch (tag) { | 4707 | return switch (tag) { |
| 4708 | .add, .sub => true, | 4708 | .add, .sub => true, |
| ... | @@ -4710,7 +4710,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool { | ... | @@ -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 | const tracy = trace(@src()); | 4714 | const tracy = trace(@src()); |
| 4715 | defer tracy.end(); | 4715 | defer tracy.end(); |
| 4716 | | 4716 | |
| ... | @@ -4731,36 +4731,36 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne | ... | @@ -4731,36 +4731,36 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne |
| 4731 | return sema.mod.constType(sema.arena, .unneeded, ty); | 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 | const tracy = trace(@src()); | 4735 | const tracy = trace(@src()); |
| 4736 | defer tracy.end(); | 4736 | defer tracy.end(); |
| 4737 | | 4737 | |
| 4738 | const src: LazySrcLoc = .unneeded; | 4738 | const src: LazySrcLoc = .unneeded; |
| 4739 | const inst_data = sema.code.instructions.items(.data)[inst].ptr_type; | 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 | var extra_i = extra.end; | 4742 | var extra_i = extra.end; |
| 4743 | | 4743 | |
| 4744 | const sentinel = if (inst_data.flags.has_sentinel) blk: { | 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 | extra_i += 1; | 4746 | extra_i += 1; |
| 4747 | break :blk (try sema.resolveInstConst(block, .unneeded, ref)).val; | 4747 | break :blk (try sema.resolveInstConst(block, .unneeded, ref)).val; |
| 4748 | } else null; | 4748 | } else null; |
| 4749 | | 4749 | |
| 4750 | const abi_align = if (inst_data.flags.has_align) blk: { | 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 | extra_i += 1; | 4752 | extra_i += 1; |
| 4753 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u32); | 4753 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u32); |
| 4754 | } else 0; | 4754 | } else 0; |
| 4755 | | 4755 | |
| 4756 | const bit_start = if (inst_data.flags.has_bit_range) blk: { | 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 | extra_i += 1; | 4758 | extra_i += 1; |
| 4759 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); | 4759 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 4760 | } else 0; | 4760 | } else 0; |
| 4761 | | 4761 | |
| 4762 | const bit_end = if (inst_data.flags.has_bit_range) blk: { | 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 | extra_i += 1; | 4764 | extra_i += 1; |
| 4765 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); | 4765 | break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16); |
| 4766 | } else 0; | 4766 | } else 0; |
| ... | @@ -4785,7 +4785,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError | ... | @@ -4785,7 +4785,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError |
| 4785 | return sema.mod.constType(sema.arena, src, ty); | 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 | const tracy = trace(@src()); | 4789 | const tracy = trace(@src()); |
| 4790 | defer tracy.end(); | 4790 | defer tracy.end(); |
| 4791 | | 4791 | |
| ... | @@ -4799,13 +4799,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In | ... | @@ -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 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4803 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4804 | const src = inst_data.src(); | 4804 | const src = inst_data.src(); |
| 4805 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInit", .{}); | 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 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4809 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4810 | const src = inst_data.src(); | 4810 | const src = inst_data.src(); |
| 4811 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldType", .{}); | 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,7 +4895,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 4895 | try parent_block.instructions.append(sema.gpa, &block_inst.base); | 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 | // TODO Once we have a panic function to call, call it here instead of breakpoint. | 4899 | // TODO Once we have a panic function to call, call it here instead of breakpoint. |
| 4900 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); | 4900 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); |
| 4901 | _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); | 4901 | _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); |