authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-14 12:16:48-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-20 12:19:16-07:00
log3c5927fb87034affd6af56ecd5d9ae07fe23d690
treeda0d37df4e9379632b44ac2fc3145db5ee49cf1f
parentdbd3529d1fa02d5e720df0fbf2436d646f5a4f57

Sema: add a strategy for handling costly source locations

Now you can pass `.unneeded` for a `LazySrcLoc` and if there ended up being a compile error that needed it, you'll get `error.NeededSourceLocation`. Callsites can now exploit this error to do the expensive computation to produce a source location object and then repeat the operation.

3 files changed, 317 insertions(+), 306 deletions(-)

src/Compilation.zig+3-3
...@@ -148,7 +148,7 @@ emit_docs: ?EmitLoc,...@@ -148,7 +148,7 @@ emit_docs: ?EmitLoc,
148work_queue_wait_group: WaitGroup,148work_queue_wait_group: WaitGroup,
149astgen_wait_group: WaitGroup,149astgen_wait_group: WaitGroup,
150150
151pub const InnerError = Module.InnerError;151pub const SemaError = Module.SemaError;
152152
153pub const CRTFile = struct {153pub const CRTFile = struct {
154 lock: Cache.Lock,154 lock: Cache.Lock,
...@@ -3170,7 +3170,7 @@ pub fn addCCArgs(...@@ -3170,7 +3170,7 @@ pub fn addCCArgs(
3170 try argv.appendSlice(comp.clang_argv);3170 try argv.appendSlice(comp.clang_argv);
3171}3171}
31723172
3173fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) InnerError {3173fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) SemaError {
3174 @setCold(true);3174 @setCold(true);
3175 const err_msg = blk: {3175 const err_msg = blk: {
3176 const msg = try std.fmt.allocPrint(comp.gpa, format, args);3176 const msg = try std.fmt.allocPrint(comp.gpa, format, args);
...@@ -3191,7 +3191,7 @@ fn failCObjWithOwnedErrorMsg(...@@ -3191,7 +3191,7 @@ fn failCObjWithOwnedErrorMsg(
3191 comp: *Compilation,3191 comp: *Compilation,
3192 c_object: *CObject,3192 c_object: *CObject,
3193 err_msg: *CObject.ErrorMsg,3193 err_msg: *CObject.ErrorMsg,
3194) InnerError {3194) SemaError {
3195 @setCold(true);3195 @setCold(true);
3196 {3196 {
3197 const lock = comp.mutex.acquire();3197 const lock = comp.mutex.acquire();
src/Module.zig+18-14
...@@ -1996,7 +1996,8 @@ pub const LazySrcLoc = union(enum) {...@@ -1996,7 +1996,8 @@ pub const LazySrcLoc = union(enum) {
1996 }1996 }
1997};1997};
19981998
1999pub const InnerError = error{ OutOfMemory, AnalysisFail };1999pub const SemaError = error{ OutOfMemory, AnalysisFail };
2000pub const CompileError = error{ OutOfMemory, AnalysisFail, NeededSourceLocation };
20002001
2001pub fn deinit(mod: *Module) void {2002pub fn deinit(mod: *Module) void {
2002 const gpa = mod.gpa;2003 const gpa = mod.gpa;
...@@ -2635,7 +2636,7 @@ pub fn mapOldZirToNew(...@@ -2635,7 +2636,7 @@ pub fn mapOldZirToNew(
2635 }2636 }
2636}2637}
26372638
2638pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) InnerError!void {2639pub fn ensureDeclAnalyzed(mod: *Module, decl: *Decl) SemaError!void {
2639 const tracy = trace(@src());2640 const tracy = trace(@src());
2640 defer tracy.end();2641 defer tracy.end();
26412642
...@@ -2735,7 +2736,7 @@ pub fn semaPkg(mod: *Module, pkg: *Package) !void {...@@ -2735,7 +2736,7 @@ pub fn semaPkg(mod: *Module, pkg: *Package) !void {
27352736
2736/// Regardless of the file status, will create a `Decl` so that we2737/// Regardless of the file status, will create a `Decl` so that we
2737/// can track dependencies and re-analyze when the file becomes outdated.2738/// can track dependencies and re-analyze when the file becomes outdated.
2738pub fn semaFile(mod: *Module, file: *Scope.File) InnerError!void {2739pub fn semaFile(mod: *Module, file: *Scope.File) SemaError!void {
2739 const tracy = trace(@src());2740 const tracy = trace(@src());
2740 defer tracy.end();2741 defer tracy.end();
27412742
...@@ -3150,7 +3151,7 @@ pub fn scanNamespace(...@@ -3150,7 +3151,7 @@ pub fn scanNamespace(
3150 extra_start: usize,3151 extra_start: usize,
3151 decls_len: u32,3152 decls_len: u32,
3152 parent_decl: *Decl,3153 parent_decl: *Decl,
3153) InnerError!usize {3154) SemaError!usize {
3154 const tracy = trace(@src());3155 const tracy = trace(@src());
3155 defer tracy.end();3156 defer tracy.end();
31563157
...@@ -3197,7 +3198,7 @@ const ScanDeclIter = struct {...@@ -3197,7 +3198,7 @@ const ScanDeclIter = struct {
3197 unnamed_test_index: usize = 0,3198 unnamed_test_index: usize = 0,
3198};3199};
31993200
3200fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!void {3201fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) SemaError!void {
3201 const tracy = trace(@src());3202 const tracy = trace(@src());
3202 defer tracy.end();3203 defer tracy.end();
32033204
...@@ -3451,7 +3452,7 @@ fn deleteDeclExports(mod: *Module, decl: *Decl) void {...@@ -3451,7 +3452,7 @@ fn deleteDeclExports(mod: *Module, decl: *Decl) void {
3451 mod.gpa.free(kv.value);3452 mod.gpa.free(kv.value);
3452}3453}
34533454
3454pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !Air {3455pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {
3455 const tracy = trace(@src());3456 const tracy = trace(@src());
3456 defer tracy.end();3457 defer tracy.end();
34573458
...@@ -3804,7 +3805,7 @@ pub fn fail(...@@ -3804,7 +3805,7 @@ pub fn fail(
3804 src: LazySrcLoc,3805 src: LazySrcLoc,
3805 comptime format: []const u8,3806 comptime format: []const u8,
3806 args: anytype,3807 args: anytype,
3807) InnerError {3808) CompileError {
3808 const err_msg = try mod.errMsg(scope, src, format, args);3809 const err_msg = try mod.errMsg(scope, src, format, args);
3809 return mod.failWithOwnedErrorMsg(scope, err_msg);3810 return mod.failWithOwnedErrorMsg(scope, err_msg);
3810}3811}
...@@ -3817,7 +3818,7 @@ pub fn failTok(...@@ -3817,7 +3818,7 @@ pub fn failTok(
3817 token_index: ast.TokenIndex,3818 token_index: ast.TokenIndex,
3818 comptime format: []const u8,3819 comptime format: []const u8,
3819 args: anytype,3820 args: anytype,
3820) InnerError {3821) CompileError {
3821 const src = scope.srcDecl().?.tokSrcLoc(token_index);3822 const src = scope.srcDecl().?.tokSrcLoc(token_index);
3822 return mod.fail(scope, src, format, args);3823 return mod.fail(scope, src, format, args);
3823}3824}
...@@ -3830,18 +3831,21 @@ pub fn failNode(...@@ -3830,18 +3831,21 @@ pub fn failNode(
3830 node_index: ast.Node.Index,3831 node_index: ast.Node.Index,
3831 comptime format: []const u8,3832 comptime format: []const u8,
3832 args: anytype,3833 args: anytype,
3833) InnerError {3834) CompileError {
3834 const src = scope.srcDecl().?.nodeSrcLoc(node_index);3835 const src = scope.srcDecl().?.nodeSrcLoc(node_index);
3835 return mod.fail(scope, src, format, args);3836 return mod.fail(scope, src, format, args);
3836}3837}
38373838
3838pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) InnerError {3839pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) CompileError {
3839 @setCold(true);3840 @setCold(true);
38403841
3841 {3842 {
3842 errdefer err_msg.destroy(mod.gpa);3843 errdefer err_msg.destroy(mod.gpa);
3843 try mod.failed_decls.ensureCapacity(mod.gpa, mod.failed_decls.count() + 1);3844 if (err_msg.src_loc.lazy == .unneeded) {
3844 try mod.failed_files.ensureCapacity(mod.gpa, mod.failed_files.count() + 1);3845 return error.NeededSourceLocation;
3846 }
3847 try mod.failed_decls.ensureUnusedCapacity(mod.gpa, 1);
3848 try mod.failed_files.ensureUnusedCapacity(mod.gpa, 1);
3845 }3849 }
3846 switch (scope.tag) {3850 switch (scope.tag) {
3847 .block => {3851 .block => {
...@@ -4340,7 +4344,7 @@ pub const SwitchProngSrc = union(enum) {...@@ -4340,7 +4344,7 @@ pub const SwitchProngSrc = union(enum) {
4340 }4344 }
4341};4345};
43424346
4343pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void {4347pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) CompileError!void {
4344 const tracy = trace(@src());4348 const tracy = trace(@src());
4345 defer tracy.end();4349 defer tracy.end();
43464350
...@@ -4490,7 +4494,7 @@ pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void {...@@ -4490,7 +4494,7 @@ pub fn analyzeStructFields(mod: *Module, struct_obj: *Struct) InnerError!void {
4490 }4494 }
4491}4495}
44924496
4493pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {4497pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) CompileError!void {
4494 const tracy = trace(@src());4498 const tracy = trace(@src());
4495 defer tracy.end();4499 defer tracy.end();
44964500
src/Sema.zig+296-289
...@@ -61,7 +61,8 @@ const Zir = @import("Zir.zig");...@@ -61,7 +61,8 @@ const Zir = @import("Zir.zig");
61const Module = @import("Module.zig");61const Module = @import("Module.zig");
62const trace = @import("tracy.zig").trace;62const trace = @import("tracy.zig").trace;
63const Scope = Module.Scope;63const Scope = Module.Scope;
64const InnerError = Module.InnerError;64const CompileError = Module.CompileError;
65const SemaError = Module.SemaError;
65const Decl = Module.Decl;66const Decl = Module.Decl;
66const LazySrcLoc = Module.LazySrcLoc;67const LazySrcLoc = Module.LazySrcLoc;
67const RangeSet = @import("RangeSet.zig");68const RangeSet = @import("RangeSet.zig");
...@@ -83,7 +84,7 @@ pub fn analyzeFnBody(...@@ -83,7 +84,7 @@ pub fn analyzeFnBody(
83 sema: *Sema,84 sema: *Sema,
84 block: *Scope.Block,85 block: *Scope.Block,
85 fn_body_inst: Zir.Inst.Index,86 fn_body_inst: Zir.Inst.Index,
86) InnerError!void {87) SemaError!void {
87 const tags = sema.code.instructions.items(.tag);88 const tags = sema.code.instructions.items(.tag);
88 const datas = sema.code.instructions.items(.data);89 const datas = sema.code.instructions.items(.data);
89 const body: []const Zir.Inst.Index = switch (tags[fn_body_inst]) {90 const body: []const Zir.Inst.Index = switch (tags[fn_body_inst]) {
...@@ -109,13 +110,16 @@ pub fn analyzeFnBody(...@@ -109,13 +110,16 @@ pub fn analyzeFnBody(
109 },110 },
110 else => unreachable,111 else => unreachable,
111 };112 };
112 _ = try sema.analyzeBody(block, body);113 _ = sema.analyzeBody(block, body) catch |err| switch (err) {
114 error.NeededSourceLocation => unreachable,
115 else => |e| return e,
116 };
113}117}
114118
115/// Returns only the result from the body that is specified.119/// Returns only the result from the body that is specified.
116/// Only appropriate to call when it is determined at comptime that this body120/// Only appropriate to call when it is determined at comptime that this body
117/// has no peers.121/// has no peers.
118fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!Air.Inst.Ref {122fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) CompileError!Air.Inst.Ref {
119 const break_inst = try sema.analyzeBody(block, body);123 const break_inst = try sema.analyzeBody(block, body);
120 const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand;124 const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand;
121 return sema.resolveInst(operand_ref);125 return sema.resolveInst(operand_ref);
...@@ -125,7 +129,7 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) I...@@ -125,7 +129,7 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) I
125/// return type of `analyzeBody` so that we can tail call them.129/// return type of `analyzeBody` so that we can tail call them.
126/// Only appropriate to return when the instruction is known to be NoReturn130/// Only appropriate to return when the instruction is known to be NoReturn
127/// solely based on the ZIR tag.131/// solely based on the ZIR tag.
128const always_noreturn: InnerError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined);132const always_noreturn: CompileError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined);
129133
130/// This function is the main loop of `Sema` and it can be used in two different ways:134/// This function is the main loop of `Sema` and it can be used in two different ways:
131/// * The traditional way where there are N breaks out of the block and peer type135/// * The traditional way where there are N breaks out of the block and peer type
...@@ -140,7 +144,7 @@ pub fn analyzeBody(...@@ -140,7 +144,7 @@ pub fn analyzeBody(
140 sema: *Sema,144 sema: *Sema,
141 block: *Scope.Block,145 block: *Scope.Block,
142 body: []const Zir.Inst.Index,146 body: []const Zir.Inst.Index,
143) InnerError!Zir.Inst.Index {147) CompileError!Zir.Inst.Index {
144 // No tracy calls here, to avoid interfering with the tail call mechanism.148 // No tracy calls here, to avoid interfering with the tail call mechanism.
145149
146 const map = &block.sema.inst_map;150 const map = &block.sema.inst_map;
...@@ -541,7 +545,7 @@ pub fn analyzeBody(...@@ -541,7 +545,7 @@ pub fn analyzeBody(
541 }545 }
542}546}
543547
544fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {548fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
545 const extended = sema.code.instructions.items(.data)[inst].extended;549 const extended = sema.code.instructions.items(.data)[inst].extended;
546 switch (extended.opcode) {550 switch (extended.opcode) {
547 // zig fmt: off551 // zig fmt: off
...@@ -638,7 +642,7 @@ fn resolveConstValue(...@@ -638,7 +642,7 @@ fn resolveConstValue(
638 block: *Scope.Block,642 block: *Scope.Block,
639 src: LazySrcLoc,643 src: LazySrcLoc,
640 air_ref: Air.Inst.Ref,644 air_ref: Air.Inst.Ref,
641) !Value {645) CompileError!Value {
642 return (try sema.resolveDefinedValue(block, src, air_ref)) orelse646 return (try sema.resolveDefinedValue(block, src, air_ref)) orelse
643 return sema.failWithNeededComptime(block, src);647 return sema.failWithNeededComptime(block, src);
644}648}
...@@ -648,7 +652,7 @@ fn resolveDefinedValue(...@@ -648,7 +652,7 @@ fn resolveDefinedValue(
648 block: *Scope.Block,652 block: *Scope.Block,
649 src: LazySrcLoc,653 src: LazySrcLoc,
650 air_ref: Air.Inst.Ref,654 air_ref: Air.Inst.Ref,
651) !?Value {655) CompileError!?Value {
652 if (try sema.resolvePossiblyUndefinedValue(block, src, air_ref)) |val| {656 if (try sema.resolvePossiblyUndefinedValue(block, src, air_ref)) |val| {
653 if (val.isUndef()) {657 if (val.isUndef()) {
654 return sema.failWithUseOfUndef(block, src);658 return sema.failWithUseOfUndef(block, src);
...@@ -663,7 +667,7 @@ fn resolvePossiblyUndefinedValue(...@@ -663,7 +667,7 @@ fn resolvePossiblyUndefinedValue(
663 block: *Scope.Block,667 block: *Scope.Block,
664 src: LazySrcLoc,668 src: LazySrcLoc,
665 air_ref: Air.Inst.Ref,669 air_ref: Air.Inst.Ref,
666) !?Value {670) CompileError!?Value {
667 const ty = sema.getTypeOf(air_ref);671 const ty = sema.getTypeOf(air_ref);
668 if (try sema.typeHasOnePossibleValue(block, src, ty)) |opv| {672 if (try sema.typeHasOnePossibleValue(block, src, ty)) |opv| {
669 return opv;673 return opv;
...@@ -687,11 +691,11 @@ fn resolvePossiblyUndefinedValue(...@@ -687,11 +691,11 @@ fn resolvePossiblyUndefinedValue(
687 }691 }
688}692}
689693
690fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError {694fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
691 return sema.mod.fail(&block.base, src, "unable to resolve comptime value", .{});695 return sema.mod.fail(&block.base, src, "unable to resolve comptime value", .{});
692}696}
693697
694fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError {698fn failWithUseOfUndef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) CompileError {
695 return sema.mod.fail(&block.base, src, "use of undefined value here causes undefined behavior", .{});699 return sema.mod.fail(&block.base, src, "use of undefined value here causes undefined behavior", .{});
696}700}
697701
...@@ -733,7 +737,7 @@ pub fn resolveInstConst(...@@ -733,7 +737,7 @@ pub fn resolveInstConst(
733 block: *Scope.Block,737 block: *Scope.Block,
734 src: LazySrcLoc,738 src: LazySrcLoc,
735 zir_ref: Zir.Inst.Ref,739 zir_ref: Zir.Inst.Ref,
736) InnerError!TypedValue {740) CompileError!TypedValue {
737 const air_ref = sema.resolveInst(zir_ref);741 const air_ref = sema.resolveInst(zir_ref);
738 const val = try sema.resolveConstValue(block, src, air_ref);742 const val = try sema.resolveConstValue(block, src, air_ref);
739 return TypedValue{743 return TypedValue{
...@@ -742,13 +746,13 @@ pub fn resolveInstConst(...@@ -742,13 +746,13 @@ pub fn resolveInstConst(
742 };746 };
743}747}
744748
745fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {749fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
746 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;750 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
747 const src = inst_data.src();751 const src = inst_data.src();
748 return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{});752 return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{});
749}753}
750754
751fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {755fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
752 _ = inst;756 _ = inst;
753 const tracy = trace(@src());757 const tracy = trace(@src());
754 defer tracy.end();758 defer tracy.end();
...@@ -760,7 +764,7 @@ pub fn analyzeStructDecl(...@@ -760,7 +764,7 @@ pub fn analyzeStructDecl(
760 new_decl: *Decl,764 new_decl: *Decl,
761 inst: Zir.Inst.Index,765 inst: Zir.Inst.Index,
762 struct_obj: *Module.Struct,766 struct_obj: *Module.Struct,
763) InnerError!void {767) SemaError!void {
764 const extended = sema.code.instructions.items(.data)[inst].extended;768 const extended = sema.code.instructions.items(.data)[inst].extended;
765 assert(extended.opcode == .struct_decl);769 assert(extended.opcode == .struct_decl);
766 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);770 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);
...@@ -783,7 +787,7 @@ fn zirStructDecl(...@@ -783,7 +787,7 @@ fn zirStructDecl(
783 block: *Scope.Block,787 block: *Scope.Block,
784 extended: Zir.Inst.Extended.InstData,788 extended: Zir.Inst.Extended.InstData,
785 inst: Zir.Inst.Index,789 inst: Zir.Inst.Index,
786) InnerError!Air.Inst.Ref {790) CompileError!Air.Inst.Ref {
787 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);791 const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small);
788 const src: LazySrcLoc = if (small.has_src_node) blk: {792 const src: LazySrcLoc = if (small.has_src_node) blk: {
789 const node_offset = @bitCast(i32, sema.code.extra[extended.operand]);793 const node_offset = @bitCast(i32, sema.code.extra[extended.operand]);
...@@ -854,7 +858,7 @@ fn zirEnumDecl(...@@ -854,7 +858,7 @@ fn zirEnumDecl(
854 sema: *Sema,858 sema: *Sema,
855 block: *Scope.Block,859 block: *Scope.Block,
856 extended: Zir.Inst.Extended.InstData,860 extended: Zir.Inst.Extended.InstData,
857) InnerError!Air.Inst.Ref {861) CompileError!Air.Inst.Ref {
858 const tracy = trace(@src());862 const tracy = trace(@src());
859 defer tracy.end();863 defer tracy.end();
860864
...@@ -1051,7 +1055,7 @@ fn zirUnionDecl(...@@ -1051,7 +1055,7 @@ fn zirUnionDecl(
1051 block: *Scope.Block,1055 block: *Scope.Block,
1052 extended: Zir.Inst.Extended.InstData,1056 extended: Zir.Inst.Extended.InstData,
1053 inst: Zir.Inst.Index,1057 inst: Zir.Inst.Index,
1054) InnerError!Air.Inst.Ref {1058) CompileError!Air.Inst.Ref {
1055 const tracy = trace(@src());1059 const tracy = trace(@src());
1056 defer tracy.end();1060 defer tracy.end();
10571061
...@@ -1115,7 +1119,7 @@ fn zirOpaqueDecl(...@@ -1115,7 +1119,7 @@ fn zirOpaqueDecl(
1115 block: *Scope.Block,1119 block: *Scope.Block,
1116 inst: Zir.Inst.Index,1120 inst: Zir.Inst.Index,
1117 name_strategy: Zir.Inst.NameStrategy,1121 name_strategy: Zir.Inst.NameStrategy,
1118) InnerError!Air.Inst.Ref {1122) CompileError!Air.Inst.Ref {
1119 const tracy = trace(@src());1123 const tracy = trace(@src());
1120 defer tracy.end();1124 defer tracy.end();
11211125
...@@ -1135,7 +1139,7 @@ fn zirErrorSetDecl(...@@ -1135,7 +1139,7 @@ fn zirErrorSetDecl(
1135 block: *Scope.Block,1139 block: *Scope.Block,
1136 inst: Zir.Inst.Index,1140 inst: Zir.Inst.Index,
1137 name_strategy: Zir.Inst.NameStrategy,1141 name_strategy: Zir.Inst.NameStrategy,
1138) InnerError!Air.Inst.Ref {1142) CompileError!Air.Inst.Ref {
1139 const tracy = trace(@src());1143 const tracy = trace(@src());
1140 defer tracy.end();1144 defer tracy.end();
11411145
...@@ -1175,7 +1179,7 @@ fn zirRetPtr(...@@ -1175,7 +1179,7 @@ fn zirRetPtr(
1175 sema: *Sema,1179 sema: *Sema,
1176 block: *Scope.Block,1180 block: *Scope.Block,
1177 extended: Zir.Inst.Extended.InstData,1181 extended: Zir.Inst.Extended.InstData,
1178) InnerError!Air.Inst.Ref {1182) CompileError!Air.Inst.Ref {
1179 const tracy = trace(@src());1183 const tracy = trace(@src());
1180 defer tracy.end();1184 defer tracy.end();
11811185
...@@ -1187,7 +1191,7 @@ fn zirRetPtr(...@@ -1187,7 +1191,7 @@ fn zirRetPtr(
1187 return block.addNoOp(src, ptr_type, .alloc);1191 return block.addNoOp(src, ptr_type, .alloc);
1188}1192}
11891193
1190fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1194fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1191 const tracy = trace(@src());1195 const tracy = trace(@src());
1192 defer tracy.end();1196 defer tracy.end();
11931197
...@@ -1200,7 +1204,7 @@ fn zirRetType(...@@ -1200,7 +1204,7 @@ fn zirRetType(
1200 sema: *Sema,1204 sema: *Sema,
1201 block: *Scope.Block,1205 block: *Scope.Block,
1202 extended: Zir.Inst.Extended.InstData,1206 extended: Zir.Inst.Extended.InstData,
1203) InnerError!Air.Inst.Ref {1207) CompileError!Air.Inst.Ref {
1204 const tracy = trace(@src());1208 const tracy = trace(@src());
1205 defer tracy.end();1209 defer tracy.end();
12061210
...@@ -1211,7 +1215,7 @@ fn zirRetType(...@@ -1211,7 +1215,7 @@ fn zirRetType(
1211 return sema.addType(ret_type);1215 return sema.addType(ret_type);
1212}1216}
12131217
1214fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1218fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1215 const tracy = trace(@src());1219 const tracy = trace(@src());
1216 defer tracy.end();1220 defer tracy.end();
12171221
...@@ -1227,14 +1231,14 @@ fn ensureResultUsed(...@@ -1227,14 +1231,14 @@ fn ensureResultUsed(
1227 block: *Scope.Block,1231 block: *Scope.Block,
1228 operand: Air.Inst.Ref,1232 operand: Air.Inst.Ref,
1229 src: LazySrcLoc,1233 src: LazySrcLoc,
1230) InnerError!void {1234) CompileError!void {
1231 switch (operand.ty.zigTypeTag()) {1235 switch (operand.ty.zigTypeTag()) {
1232 .Void, .NoReturn => return,1236 .Void, .NoReturn => return,
1233 else => return sema.mod.fail(&block.base, src, "expression value is ignored", .{}),1237 else => return sema.mod.fail(&block.base, src, "expression value is ignored", .{}),
1234 }1238 }
1235}1239}
12361240
1237fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1241fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1238 const tracy = trace(@src());1242 const tracy = trace(@src());
1239 defer tracy.end();1243 defer tracy.end();
12401244
...@@ -1247,7 +1251,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde...@@ -1247,7 +1251,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
1247 }1251 }
1248}1252}
12491253
1250fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1254fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1251 const tracy = trace(@src());1255 const tracy = trace(@src());
1252 defer tracy.end();1256 defer tracy.end();
12531257
...@@ -1281,7 +1285,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -1281,7 +1285,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
1281 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);1285 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
1282}1286}
12831287
1284fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1288fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1285 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;1289 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
1286 const arg_name = inst_data.get(sema.code);1290 const arg_name = inst_data.get(sema.code);
1287 const arg_index = sema.next_arg_index;1291 const arg_index = sema.next_arg_index;
...@@ -1304,13 +1308,13 @@ fn zirAllocExtended(...@@ -1304,13 +1308,13 @@ fn zirAllocExtended(
1304 sema: *Sema,1308 sema: *Sema,
1305 block: *Scope.Block,1309 block: *Scope.Block,
1306 extended: Zir.Inst.Extended.InstData,1310 extended: Zir.Inst.Extended.InstData,
1307) InnerError!Air.Inst.Ref {1311) CompileError!Air.Inst.Ref {
1308 const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand);1312 const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand);
1309 const src: LazySrcLoc = .{ .node_offset = extra.data.src_node };1313 const src: LazySrcLoc = .{ .node_offset = extra.data.src_node };
1310 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{});1314 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{});
1311}1315}
13121316
1313fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1317fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1314 const tracy = trace(@src());1318 const tracy = trace(@src());
1315 defer tracy.end();1319 defer tracy.end();
13161320
...@@ -1333,13 +1337,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne...@@ -1333,13 +1337,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
1333 });1337 });
1334}1338}
13351339
1336fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1340fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1337 const src_node = sema.code.instructions.items(.data)[inst].node;1341 const src_node = sema.code.instructions.items(.data)[inst].node;
1338 const src: LazySrcLoc = .{ .node_offset = src_node };1342 const src: LazySrcLoc = .{ .node_offset = src_node };
1339 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{});1343 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{});
1340}1344}
13411345
1342fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1346fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1343 const tracy = trace(@src());1347 const tracy = trace(@src());
1344 defer tracy.end();1348 defer tracy.end();
13451349
...@@ -1352,7 +1356,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A...@@ -1352,7 +1356,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A
1352 return block.addNoOp(var_decl_src, ptr_type, .alloc);1356 return block.addNoOp(var_decl_src, ptr_type, .alloc);
1353}1357}
13541358
1355fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1359fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1356 const tracy = trace(@src());1360 const tracy = trace(@src());
1357 defer tracy.end();1361 defer tracy.end();
13581362
...@@ -1371,7 +1375,7 @@ fn zirAllocInferred(...@@ -1371,7 +1375,7 @@ fn zirAllocInferred(
1371 block: *Scope.Block,1375 block: *Scope.Block,
1372 inst: Zir.Inst.Index,1376 inst: Zir.Inst.Index,
1373 inferred_alloc_ty: Type,1377 inferred_alloc_ty: Type,
1374) InnerError!Air.Inst.Ref {1378) CompileError!Air.Inst.Ref {
1375 const tracy = trace(@src());1379 const tracy = trace(@src());
1376 defer tracy.end();1380 defer tracy.end();
13771381
...@@ -1395,7 +1399,7 @@ fn zirAllocInferred(...@@ -1395,7 +1399,7 @@ fn zirAllocInferred(
1395 return result;1399 return result;
1396}1400}
13971401
1398fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1402fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1399 const tracy = trace(@src());1403 const tracy = trace(@src());
1400 defer tracy.end();1404 defer tracy.end();
14011405
...@@ -1421,7 +1425,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde...@@ -1421,7 +1425,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde
1421 ptr.tag = .alloc;1425 ptr.tag = .alloc;
1422}1426}
14231427
1424fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1428fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1425 const tracy = trace(@src());1429 const tracy = trace(@src());
1426 defer tracy.end();1430 defer tracy.end();
14271431
...@@ -1494,7 +1498,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind...@@ -1494,7 +1498,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind
1494 }1498 }
1495}1499}
14961500
1497fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1501fn zirValidateArrayInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1498 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;1502 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1499 const src = inst_data.src();1503 const src = inst_data.src();
1500 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirValidateArrayInitPtr", .{});1504 return sema.mod.fail(&block.base, src, "TODO implement Sema.zirValidateArrayInitPtr", .{});
...@@ -1506,7 +1510,7 @@ fn failWithBadFieldAccess(...@@ -1506,7 +1510,7 @@ fn failWithBadFieldAccess(
1506 struct_obj: *Module.Struct,1510 struct_obj: *Module.Struct,
1507 field_src: LazySrcLoc,1511 field_src: LazySrcLoc,
1508 field_name: []const u8,1512 field_name: []const u8,
1509) InnerError {1513) CompileError {
1510 const mod = sema.mod;1514 const mod = sema.mod;
1511 const gpa = sema.gpa;1515 const gpa = sema.gpa;
15121516
...@@ -1533,7 +1537,7 @@ fn failWithBadUnionFieldAccess(...@@ -1533,7 +1537,7 @@ fn failWithBadUnionFieldAccess(
1533 union_obj: *Module.Union,1537 union_obj: *Module.Union,
1534 field_src: LazySrcLoc,1538 field_src: LazySrcLoc,
1535 field_name: []const u8,1539 field_name: []const u8,
1536) InnerError {1540) CompileError {
1537 const mod = sema.mod;1541 const mod = sema.mod;
1538 const gpa = sema.gpa;1542 const gpa = sema.gpa;
15391543
...@@ -1554,7 +1558,7 @@ fn failWithBadUnionFieldAccess(...@@ -1554,7 +1558,7 @@ fn failWithBadUnionFieldAccess(
1554 return mod.failWithOwnedErrorMsg(&block.base, msg);1558 return mod.failWithOwnedErrorMsg(&block.base, msg);
1555}1559}
15561560
1557fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1561fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1558 const tracy = trace(@src());1562 const tracy = trace(@src());
1559 defer tracy.end();1563 defer tracy.end();
15601564
...@@ -1575,7 +1579,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -1575,7 +1579,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
1575 return sema.storePtr(block, src, bitcasted_ptr, value);1579 return sema.storePtr(block, src, bitcasted_ptr, value);
1576}1580}
15771581
1578fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1582fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1579 const tracy = trace(@src());1583 const tracy = trace(@src());
1580 defer tracy.end();1584 defer tracy.end();
15811585
...@@ -1594,7 +1598,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)...@@ -1594,7 +1598,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
1594 return sema.storePtr(block, src, bitcasted_ptr, value);1598 return sema.storePtr(block, src, bitcasted_ptr, value);
1595}1599}
15961600
1597fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1601fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1598 const inst_data = sema.code.instructions.items(.data)[inst].un_node;1602 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1599 const src = inst_data.src();1603 const src = inst_data.src();
1600 const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32);1604 const quota = try sema.resolveAlreadyCoercedInt(block, src, inst_data.operand, u32);
...@@ -1602,7 +1606,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)...@@ -1602,7 +1606,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
1602 sema.branch_quota = quota;1606 sema.branch_quota = quota;
1603}1607}
16041608
1605fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1609fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1606 const tracy = trace(@src());1610 const tracy = trace(@src());
1607 defer tracy.end();1611 defer tracy.end();
16081612
...@@ -1612,7 +1616,7 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!v...@@ -1612,7 +1616,7 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!v
1612 return sema.storePtr(block, sema.src, ptr, value);1616 return sema.storePtr(block, sema.src, ptr, value);
1613}1617}
16141618
1615fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {1619fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
1616 const tracy = trace(@src());1620 const tracy = trace(@src());
1617 defer tracy.end();1621 defer tracy.end();
16181622
...@@ -1624,7 +1628,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -1624,7 +1628,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
1624 return sema.storePtr(block, src, ptr, value);1628 return sema.storePtr(block, src, ptr, value);
1625}1629}
16261630
1627fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1631fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1628 const tracy = trace(@src());1632 const tracy = trace(@src());
1629 defer tracy.end();1633 defer tracy.end();
16301634
...@@ -1660,7 +1664,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -1660,7 +1664,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
1660 return sema.addType(param_type);1664 return sema.addType(param_type);
1661}1665}
16621666
1663fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1667fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1664 const tracy = trace(@src());1668 const tracy = trace(@src());
1665 defer tracy.end();1669 defer tracy.end();
16661670
...@@ -1688,7 +1692,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air...@@ -1688,7 +1692,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
1688 return sema.analyzeDeclRef(block, .unneeded, new_decl);1692 return sema.analyzeDeclRef(block, .unneeded, new_decl);
1689}1693}
16901694
1691fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1695fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1692 _ = block;1696 _ = block;
1693 const tracy = trace(@src());1697 const tracy = trace(@src());
1694 defer tracy.end();1698 defer tracy.end();
...@@ -1697,7 +1701,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air...@@ -1697,7 +1701,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
1697 return sema.addIntUnsigned(Type.initTag(.comptime_int), int);1701 return sema.addIntUnsigned(Type.initTag(.comptime_int), int);
1698}1702}
16991703
1700fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1704fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1701 _ = block;1705 _ = block;
1702 const tracy = trace(@src());1706 const tracy = trace(@src());
1703 defer tracy.end();1707 defer tracy.end();
...@@ -1715,7 +1719,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -1715,7 +1719,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
1715 });1719 });
1716}1720}
17171721
1718fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1722fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1719 _ = block;1723 _ = block;
1720 const arena = sema.arena;1724 const arena = sema.arena;
1721 const inst_data = sema.code.instructions.items(.data)[inst].float;1725 const inst_data = sema.code.instructions.items(.data)[inst].float;
...@@ -1728,7 +1732,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A...@@ -1728,7 +1732,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A
1728 });1732 });
1729}1733}
17301734
1731fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1735fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1732 _ = block;1736 _ = block;
1733 const arena = sema.arena;1737 const arena = sema.arena;
1734 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;1738 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
...@@ -1742,7 +1746,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -1742,7 +1746,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
1742 });1746 });
1743}1747}
17441748
1745fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {1749fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
1746 const tracy = trace(@src());1750 const tracy = trace(@src());
1747 defer tracy.end();1751 defer tracy.end();
17481752
...@@ -1757,7 +1761,7 @@ fn zirCompileLog(...@@ -1757,7 +1761,7 @@ fn zirCompileLog(
1757 sema: *Sema,1761 sema: *Sema,
1758 block: *Scope.Block,1762 block: *Scope.Block,
1759 extended: Zir.Inst.Extended.InstData,1763 extended: Zir.Inst.Extended.InstData,
1760) InnerError!Air.Inst.Ref {1764) CompileError!Air.Inst.Ref {
1761 var managed = sema.mod.compile_log_text.toManaged(sema.gpa);1765 var managed = sema.mod.compile_log_text.toManaged(sema.gpa);
1762 defer sema.mod.compile_log_text = managed.moveToUnmanaged();1766 defer sema.mod.compile_log_text = managed.moveToUnmanaged();
1763 const writer = managed.writer();1767 const writer = managed.writer();
...@@ -1789,7 +1793,7 @@ fn zirCompileLog(...@@ -1789,7 +1793,7 @@ fn zirCompileLog(
1789 });1793 });
1790}1794}
17911795
1792fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {1796fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
1793 const tracy = trace(@src());1797 const tracy = trace(@src());
1794 defer tracy.end();1798 defer tracy.end();
17951799
...@@ -1799,7 +1803,7 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -1799,7 +1803,7 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
1799 return always_noreturn;1803 return always_noreturn;
1800}1804}
18011805
1802fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {1806fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
1803 const inst_data = sema.code.instructions.items(.data)[inst].un_node;1807 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1804 const src: LazySrcLoc = inst_data.src();1808 const src: LazySrcLoc = inst_data.src();
1805 const msg_inst = sema.resolveInst(inst_data.operand);1809 const msg_inst = sema.resolveInst(inst_data.operand);
...@@ -1807,7 +1811,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z...@@ -1807,7 +1811,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z
1807 return sema.panicWithMsg(block, src, msg_inst);1811 return sema.panicWithMsg(block, src, msg_inst);
1808}1812}
18091813
1810fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1814fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1811 const tracy = trace(@src());1815 const tracy = trace(@src());
1812 defer tracy.end();1816 defer tracy.end();
18131817
...@@ -1872,7 +1876,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -1872,7 +1876,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE
1872 return sema.analyzeBlockBody(parent_block, src, &child_block, merges);1876 return sema.analyzeBlockBody(parent_block, src, &child_block, merges);
1873}1877}
18741878
1875fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1879fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1876 const tracy = trace(@src());1880 const tracy = trace(@src());
1877 defer tracy.end();1881 defer tracy.end();
18781882
...@@ -1882,13 +1886,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn...@@ -1882,13 +1886,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn
1882 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{});1886 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{});
1883}1887}
18841888
1885fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1889fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1886 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;1890 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1887 const src = inst_data.src();1891 const src = inst_data.src();
1888 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{});1892 return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{});
1889}1893}
18901894
1891fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {1895fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1892 const tracy = trace(@src());1896 const tracy = trace(@src());
1893 defer tracy.end();1897 defer tracy.end();
18941898
...@@ -1946,7 +1950,7 @@ fn resolveBlockBody(...@@ -1946,7 +1950,7 @@ fn resolveBlockBody(
1946 child_block: *Scope.Block,1950 child_block: *Scope.Block,
1947 body: []const Zir.Inst.Index,1951 body: []const Zir.Inst.Index,
1948 merges: *Scope.Block.Merges,1952 merges: *Scope.Block.Merges,
1949) InnerError!Air.Inst.Ref {1953) CompileError!Air.Inst.Ref {
1950 _ = try sema.analyzeBody(child_block, body);1954 _ = try sema.analyzeBody(child_block, body);
1951 return sema.analyzeBlockBody(parent_block, src, child_block, merges);1955 return sema.analyzeBlockBody(parent_block, src, child_block, merges);
1952}1956}
...@@ -1957,7 +1961,7 @@ fn analyzeBlockBody(...@@ -1957,7 +1961,7 @@ fn analyzeBlockBody(
1957 src: LazySrcLoc,1961 src: LazySrcLoc,
1958 child_block: *Scope.Block,1962 child_block: *Scope.Block,
1959 merges: *Scope.Block.Merges,1963 merges: *Scope.Block.Merges,
1960) InnerError!Air.Inst.Ref {1964) CompileError!Air.Inst.Ref {
1961 const tracy = trace(@src());1965 const tracy = trace(@src());
1962 defer tracy.end();1966 defer tracy.end();
19631967
...@@ -2033,7 +2037,7 @@ fn analyzeBlockBody(...@@ -2033,7 +2037,7 @@ fn analyzeBlockBody(
2033 return &merges.block_inst.base;2037 return &merges.block_inst.base;
2034}2038}
20352039
2036fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2040fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2037 const tracy = trace(@src());2041 const tracy = trace(@src());
2038 defer tracy.end();2042 defer tracy.end();
20392043
...@@ -2069,13 +2073,13 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -2069,13 +2073,13 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
2069 try sema.mod.analyzeExport(&block.base, src, export_name, decl);2073 try sema.mod.analyzeExport(&block.base, src, export_name, decl);
2070}2074}
20712075
2072fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2076fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2073 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2077 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2074 const src: LazySrcLoc = inst_data.src();2078 const src: LazySrcLoc = inst_data.src();
2075 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetAlignStack", .{});2079 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetAlignStack", .{});
2076}2080}
20772081
2078fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2082fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2079 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2083 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2080 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };2084 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2081 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand);2085 const is_cold = try sema.resolveConstBool(block, operand_src, inst_data.operand);
...@@ -2083,19 +2087,19 @@ fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -2083,19 +2087,19 @@ fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
2083 func.is_cold = is_cold;2087 func.is_cold = is_cold;
2084}2088}
20852089
2086fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2090fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2087 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2091 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2088 const src: LazySrcLoc = inst_data.src();2092 const src: LazySrcLoc = inst_data.src();
2089 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetFloatMode", .{});2093 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetFloatMode", .{});
2090}2094}
20912095
2092fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2096fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2093 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2097 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2094 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };2098 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2095 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand);2099 block.want_safety = try sema.resolveConstBool(block, operand_src, inst_data.operand);
2096}2100}
20972101
2098fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2102fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2099 const tracy = trace(@src());2103 const tracy = trace(@src());
2100 defer tracy.end();2104 defer tracy.end();
21012105
...@@ -2105,13 +2109,13 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -2105,13 +2109,13 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
2105 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);2109 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
2106}2110}
21072111
2108fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2112fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2109 const src_node = sema.code.instructions.items(.data)[inst].node;2113 const src_node = sema.code.instructions.items(.data)[inst].node;
2110 const src: LazySrcLoc = .{ .node_offset = src_node };2114 const src: LazySrcLoc = .{ .node_offset = src_node };
2111 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirFence", .{});2115 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirFence", .{});
2112}2116}
21132117
2114fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {2118fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
2115 const tracy = trace(@src());2119 const tracy = trace(@src());
2116 defer tracy.end();2120 defer tracy.end();
21172121
...@@ -2151,7 +2155,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -2151,7 +2155,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerE
2151 }2155 }
2152}2156}
21532157
2154fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {2158fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
2155 const tracy = trace(@src());2159 const tracy = trace(@src());
2156 defer tracy.end();2160 defer tracy.end();
21572161
...@@ -2165,7 +2169,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -2165,7 +2169,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
2165 _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column);2169 _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column);
2166}2170}
21672171
2168fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2172fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2169 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;2173 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
2170 const src = inst_data.src();2174 const src = inst_data.src();
2171 const decl_name = inst_data.get(sema.code);2175 const decl_name = inst_data.get(sema.code);
...@@ -2173,7 +2177,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -2173,7 +2177,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
2173 return sema.analyzeDeclRef(block, src, decl);2177 return sema.analyzeDeclRef(block, src, decl);
2174}2178}
21752179
2176fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2180fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2177 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;2181 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
2178 const src = inst_data.src();2182 const src = inst_data.src();
2179 const decl_name = inst_data.get(sema.code);2183 const decl_name = inst_data.get(sema.code);
...@@ -2199,7 +2203,7 @@ fn lookupInNamespace(...@@ -2199,7 +2203,7 @@ fn lookupInNamespace(
2199 sema: *Sema,2203 sema: *Sema,
2200 namespace: *Scope.Namespace,2204 namespace: *Scope.Namespace,
2201 ident_name: []const u8,2205 ident_name: []const u8,
2202) InnerError!?*Decl {2206) CompileError!?*Decl {
2203 const namespace_decl = namespace.getDecl();2207 const namespace_decl = namespace.getDecl();
2204 if (namespace_decl.analysis == .file_failure) {2208 if (namespace_decl.analysis == .file_failure) {
2205 try sema.mod.declareDeclDependency(sema.owner_decl, namespace_decl);2209 try sema.mod.declareDeclDependency(sema.owner_decl, namespace_decl);
...@@ -2227,7 +2231,7 @@ fn zirCall(...@@ -2227,7 +2231,7 @@ fn zirCall(
2227 inst: Zir.Inst.Index,2231 inst: Zir.Inst.Index,
2228 modifier: std.builtin.CallOptions.Modifier,2232 modifier: std.builtin.CallOptions.Modifier,
2229 ensure_result_used: bool,2233 ensure_result_used: bool,
2230) InnerError!Air.Inst.Ref {2234) CompileError!Air.Inst.Ref {
2231 const tracy = trace(@src());2235 const tracy = trace(@src());
2232 defer tracy.end();2236 defer tracy.end();
22332237
...@@ -2257,7 +2261,7 @@ fn analyzeCall(...@@ -2257,7 +2261,7 @@ fn analyzeCall(
2257 modifier: std.builtin.CallOptions.Modifier,2261 modifier: std.builtin.CallOptions.Modifier,
2258 ensure_result_used: bool,2262 ensure_result_used: bool,
2259 args: []const Air.Inst.Ref,2263 args: []const Air.Inst.Ref,
2260) InnerError!Air.Inst.Ref {2264) CompileError!Air.Inst.Ref {
2261 if (func.ty.zigTypeTag() != .Fn)2265 if (func.ty.zigTypeTag() != .Fn)
2262 return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty});2266 return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty});
22632267
...@@ -2412,7 +2416,7 @@ fn analyzeCall(...@@ -2412,7 +2416,7 @@ fn analyzeCall(
2412 return result;2416 return result;
2413}2417}
24142418
2415fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2419fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2416 _ = block;2420 _ = block;
2417 const tracy = trace(@src());2421 const tracy = trace(@src());
2418 defer tracy.end();2422 defer tracy.end();
...@@ -2423,7 +2427,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -2423,7 +2427,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
2423 return sema.addType(ty);2427 return sema.addType(ty);
2424}2428}
24252429
2426fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2430fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2427 const tracy = trace(@src());2431 const tracy = trace(@src());
2428 defer tracy.end();2432 defer tracy.end();
24292433
...@@ -2435,7 +2439,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner...@@ -2435,7 +2439,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
2435 return sema.addType(opt_type);2439 return sema.addType(opt_type);
2436}2440}
24372441
2438fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2442fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2439 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2443 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
2440 const src = inst_data.src();2444 const src = inst_data.src();
2441 const array_type = try sema.resolveType(block, src, inst_data.operand);2445 const array_type = try sema.resolveType(block, src, inst_data.operand);
...@@ -2443,7 +2447,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -2443,7 +2447,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
2443 return sema.addType(elem_type);2447 return sema.addType(elem_type);
2444}2448}
24452449
2446fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2450fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2447 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;2451 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2448 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };2452 const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2449 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };2453 const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
...@@ -2457,7 +2461,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -2457,7 +2461,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
2457 return sema.addType(vector_type);2461 return sema.addType(vector_type);
2458}2462}
24592463
2460fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2464fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2461 const tracy = trace(@src());2465 const tracy = trace(@src());
2462 defer tracy.end();2466 defer tracy.end();
24632467
...@@ -2470,7 +2474,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -2470,7 +2474,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
2470 return sema.addType(array_ty);2474 return sema.addType(array_ty);
2471}2475}
24722476
2473fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2477fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2474 const tracy = trace(@src());2478 const tracy = trace(@src());
2475 defer tracy.end();2479 defer tracy.end();
24762480
...@@ -2485,7 +2489,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)...@@ -2485,7 +2489,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index)
2485 return sema.addType(array_ty);2489 return sema.addType(array_ty);
2486}2490}
24872491
2488fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2492fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2489 const tracy = trace(@src());2493 const tracy = trace(@src());
2490 defer tracy.end();2494 defer tracy.end();
24912495
...@@ -2497,7 +2501,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner...@@ -2497,7 +2501,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
2497 return sema.addType(anyframe_type);2501 return sema.addType(anyframe_type);
2498}2502}
24992503
2500fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2504fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2501 const tracy = trace(@src());2505 const tracy = trace(@src());
2502 defer tracy.end();2506 defer tracy.end();
25032507
...@@ -2517,7 +2521,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn...@@ -2517,7 +2521,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
2517 return sema.addType(err_union_ty);2521 return sema.addType(err_union_ty);
2518}2522}
25192523
2520fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2524fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2521 _ = block;2525 _ = block;
2522 const tracy = trace(@src());2526 const tracy = trace(@src());
2523 defer tracy.end();2527 defer tracy.end();
...@@ -2536,7 +2540,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -2536,7 +2540,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
2536 });2540 });
2537}2541}
25382542
2539fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2543fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2540 const tracy = trace(@src());2544 const tracy = trace(@src());
2541 defer tracy.end();2545 defer tracy.end();
25422546
...@@ -2566,7 +2570,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -2566,7 +2570,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
2566 return block.addTyOp(.bitcast, result_ty, op_coerced);2570 return block.addTyOp(.bitcast, result_ty, op_coerced);
2567}2571}
25682572
2569fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2573fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2570 const tracy = trace(@src());2574 const tracy = trace(@src());
2571 defer tracy.end();2575 defer tracy.end();
25722576
...@@ -2599,7 +2603,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -2599,7 +2603,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
2599 return block.addTyOp(.bitcast, Type.initTag(.anyerror), op);2603 return block.addTyOp(.bitcast, Type.initTag(.anyerror), op);
2600}2604}
26012605
2602fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2606fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2603 const tracy = trace(@src());2607 const tracy = trace(@src());
2604 defer tracy.end();2608 defer tracy.end();
26052609
...@@ -2689,7 +2693,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn...@@ -2689,7 +2693,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
2689 });2693 });
2690}2694}
26912695
2692fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2696fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2693 _ = block;2697 _ = block;
2694 const tracy = trace(@src());2698 const tracy = trace(@src());
2695 defer tracy.end();2699 defer tracy.end();
...@@ -2703,7 +2707,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -2703,7 +2707,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
2703 });2707 });
2704}2708}
27052709
2706fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2710fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2707 const mod = sema.mod;2711 const mod = sema.mod;
2708 const arena = sema.arena;2712 const arena = sema.arena;
2709 const inst_data = sema.code.instructions.items(.data)[inst].un_node;2713 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
...@@ -2741,7 +2745,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -2741,7 +2745,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
2741 });2745 });
2742 }2746 }
27432747
2744 if (enum_tag.value()) |enum_tag_val| {2748 if (try sema.resolvePossiblyUndefinedValue(block, operand_src, enum_tag)) |enum_tag_val| {
2745 if (enum_tag_val.castTag(.enum_field_index)) |enum_field_payload| {2749 if (enum_tag_val.castTag(.enum_field_index)) |enum_field_payload| {
2746 const field_index = enum_field_payload.data;2750 const field_index = enum_field_payload.data;
2747 switch (enum_tag.ty.tag()) {2751 switch (enum_tag.ty.tag()) {
...@@ -2785,7 +2789,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -2785,7 +2789,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
2785 return block.addTyOp(.bitcast, int_tag_ty, enum_tag);2789 return block.addTyOp(.bitcast, int_tag_ty, enum_tag);
2786}2790}
27872791
2788fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {2792fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2789 const mod = sema.mod;2793 const mod = sema.mod;
2790 const target = mod.getTarget();2794 const target = mod.getTarget();
2791 const arena = sema.arena;2795 const arena = sema.arena;
...@@ -2801,16 +2805,16 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -2801,16 +2805,16 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
2801 return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty});2805 return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty});
2802 }2806 }
28032807
2804 if (dest_ty.isNonexhaustiveEnum()) {2808 if (try sema.resolvePossiblyUndefinedValue(block, operand_src, operand)) |int_val| {
2805 if (operand.value()) |int_val| {2809 if (dest_ty.isNonexhaustiveEnum()) {
2806 return mod.constInst(arena, src, .{2810 return mod.constInst(arena, src, .{
2807 .ty = dest_ty,2811 .ty = dest_ty,
2808 .val = int_val,2812 .val = int_val,
2809 });2813 });
2810 }2814 }
2811 }2815 if (int_val.isUndef()) {
28122816 return sema.failWithUseOfUndef(block, operand_src);
2813 if (try sema.resolveDefinedValue(block, operand_src, operand)) |int_val| {2817 }
2814 if (!dest_ty.enumHasInt(int_val, target)) {2818 if (!dest_ty.enumHasInt(int_val, target)) {
2815 const msg = msg: {2819 const msg = msg: {
2816 const msg = try mod.errMsg(2820 const msg = try mod.errMsg(
...@@ -2846,7 +2850,7 @@ fn zirOptionalPayloadPtr(...@@ -2846,7 +2850,7 @@ fn zirOptionalPayloadPtr(
2846 block: *Scope.Block,2850 block: *Scope.Block,
2847 inst: Zir.Inst.Index,2851 inst: Zir.Inst.Index,
2848 safety_check: bool,2852 safety_check: bool,
2849) InnerError!Air.Inst.Ref {2853) CompileError!Air.Inst.Ref {
2850 const tracy = trace(@src());2854 const tracy = trace(@src());
2851 defer tracy.end();2855 defer tracy.end();
28522856
...@@ -2863,7 +2867,7 @@ fn zirOptionalPayloadPtr(...@@ -2863,7 +2867,7 @@ fn zirOptionalPayloadPtr(
2863 const child_type = try opt_type.optionalChildAlloc(sema.arena);2867 const child_type = try opt_type.optionalChildAlloc(sema.arena);
2864 const child_pointer = try Module.simplePtrType(sema.arena, child_type, !optional_ptr.ty.isConstPtr(), .One);2868 const child_pointer = try Module.simplePtrType(sema.arena, child_type, !optional_ptr.ty.isConstPtr(), .One);
28652869
2866 if (optional_ptr.value()) |pointer_val| {2870 if (try sema.resolveDefinedValue(block, src, optional_ptr)) |pointer_val| {
2867 const val = try pointer_val.pointerDeref(sema.arena);2871 const val = try pointer_val.pointerDeref(sema.arena);
2868 if (val.isNull()) {2872 if (val.isNull()) {
2869 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});2873 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});
...@@ -2889,7 +2893,7 @@ fn zirOptionalPayload(...@@ -2889,7 +2893,7 @@ fn zirOptionalPayload(
2889 block: *Scope.Block,2893 block: *Scope.Block,
2890 inst: Zir.Inst.Index,2894 inst: Zir.Inst.Index,
2891 safety_check: bool,2895 safety_check: bool,
2892) InnerError!Air.Inst.Ref {2896) CompileError!Air.Inst.Ref {
2893 const tracy = trace(@src());2897 const tracy = trace(@src());
2894 defer tracy.end();2898 defer tracy.end();
28952899
...@@ -2903,7 +2907,7 @@ fn zirOptionalPayload(...@@ -2903,7 +2907,7 @@ fn zirOptionalPayload(
29032907
2904 const child_type = try opt_type.optionalChildAlloc(sema.arena);2908 const child_type = try opt_type.optionalChildAlloc(sema.arena);
29052909
2906 if (operand.value()) |val| {2910 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
2907 if (val.isNull()) {2911 if (val.isNull()) {
2908 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});2912 return sema.mod.fail(&block.base, src, "unable to unwrap null", .{});
2909 }2913 }
...@@ -2927,7 +2931,7 @@ fn zirErrUnionPayload(...@@ -2927,7 +2931,7 @@ fn zirErrUnionPayload(
2927 block: *Scope.Block,2931 block: *Scope.Block,
2928 inst: Zir.Inst.Index,2932 inst: Zir.Inst.Index,
2929 safety_check: bool,2933 safety_check: bool,
2930) InnerError!Air.Inst.Ref {2934) CompileError!Air.Inst.Ref {
2931 const tracy = trace(@src());2935 const tracy = trace(@src());
2932 defer tracy.end();2936 defer tracy.end();
29332937
...@@ -2937,7 +2941,7 @@ fn zirErrUnionPayload(...@@ -2937,7 +2941,7 @@ fn zirErrUnionPayload(
2937 if (operand.ty.zigTypeTag() != .ErrorUnion)2941 if (operand.ty.zigTypeTag() != .ErrorUnion)
2938 return sema.mod.fail(&block.base, operand.src, "expected error union type, found '{}'", .{operand.ty});2942 return sema.mod.fail(&block.base, operand.src, "expected error union type, found '{}'", .{operand.ty});
29392943
2940 if (operand.value()) |val| {2944 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
2941 if (val.getError()) |name| {2945 if (val.getError()) |name| {
2942 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});2946 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});
2943 }2947 }
...@@ -2962,7 +2966,7 @@ fn zirErrUnionPayloadPtr(...@@ -2962,7 +2966,7 @@ fn zirErrUnionPayloadPtr(
2962 block: *Scope.Block,2966 block: *Scope.Block,
2963 inst: Zir.Inst.Index,2967 inst: Zir.Inst.Index,
2964 safety_check: bool,2968 safety_check: bool,
2965) InnerError!Air.Inst.Ref {2969) CompileError!Air.Inst.Ref {
2966 const tracy = trace(@src());2970 const tracy = trace(@src());
2967 defer tracy.end();2971 defer tracy.end();
29682972
...@@ -2976,7 +2980,7 @@ fn zirErrUnionPayloadPtr(...@@ -2976,7 +2980,7 @@ fn zirErrUnionPayloadPtr(
29762980
2977 const operand_pointer_ty = try Module.simplePtrType(sema.arena, operand.ty.elemType().castTag(.error_union).?.data.payload, !operand.ty.isConstPtr(), .One);2981 const operand_pointer_ty = try Module.simplePtrType(sema.arena, operand.ty.elemType().castTag(.error_union).?.data.payload, !operand.ty.isConstPtr(), .One);
29782982
2979 if (operand.value()) |pointer_val| {2983 if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| {
2980 const val = try pointer_val.pointerDeref(sema.arena);2984 const val = try pointer_val.pointerDeref(sema.arena);
2981 if (val.getError()) |name| {2985 if (val.getError()) |name| {
2982 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});2986 return sema.mod.fail(&block.base, src, "caught unexpected error '{s}'", .{name});
...@@ -3001,7 +3005,7 @@ fn zirErrUnionPayloadPtr(...@@ -3001,7 +3005,7 @@ fn zirErrUnionPayloadPtr(
3001}3005}
30023006
3003/// Value in, value out3007/// Value in, value out
3004fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3008fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3005 const tracy = trace(@src());3009 const tracy = trace(@src());
3006 defer tracy.end();3010 defer tracy.end();
30073011
...@@ -3013,7 +3017,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner...@@ -3013,7 +3017,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
30133017
3014 const result_ty = operand.ty.castTag(.error_union).?.data.error_set;3018 const result_ty = operand.ty.castTag(.error_union).?.data.error_set;
30153019
3016 if (operand.value()) |val| {3020 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
3017 assert(val.getError() != null);3021 assert(val.getError() != null);
3018 const data = val.castTag(.error_union).?.data;3022 const data = val.castTag(.error_union).?.data;
3019 return sema.mod.constInst(sema.arena, src, .{3023 return sema.mod.constInst(sema.arena, src, .{
...@@ -3027,7 +3031,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner...@@ -3027,7 +3031,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
3027}3031}
30283032
3029/// Pointer in, value out3033/// Pointer in, value out
3030fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3034fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3031 const tracy = trace(@src());3035 const tracy = trace(@src());
3032 defer tracy.end();3036 defer tracy.end();
30333037
...@@ -3041,7 +3045,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -3041,7 +3045,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
30413045
3042 const result_ty = operand.ty.elemType().castTag(.error_union).?.data.error_set;3046 const result_ty = operand.ty.elemType().castTag(.error_union).?.data.error_set;
30433047
3044 if (operand.value()) |pointer_val| {3048 if (try sema.resolveDefinedValue(block, src, operand)) |pointer_val| {
3045 const val = try pointer_val.pointerDeref(sema.arena);3049 const val = try pointer_val.pointerDeref(sema.arena);
3046 assert(val.getError() != null);3050 assert(val.getError() != null);
3047 const data = val.castTag(.error_union).?.data;3051 const data = val.castTag(.error_union).?.data;
...@@ -3055,7 +3059,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -3055,7 +3059,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
3055 return block.addTyOp(.unwrap_errunion_err_ptr, result_ty, operand);3059 return block.addTyOp(.unwrap_errunion_err_ptr, result_ty, operand);
3056}3060}
30573061
3058fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {3062fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!void {
3059 const tracy = trace(@src());3063 const tracy = trace(@src());
3060 defer tracy.end();3064 defer tracy.end();
30613065
...@@ -3074,7 +3078,7 @@ fn zirFunc(...@@ -3074,7 +3078,7 @@ fn zirFunc(
3074 block: *Scope.Block,3078 block: *Scope.Block,
3075 inst: Zir.Inst.Index,3079 inst: Zir.Inst.Index,
3076 inferred_error_set: bool,3080 inferred_error_set: bool,
3077) InnerError!Air.Inst.Ref {3081) CompileError!Air.Inst.Ref {
3078 const tracy = trace(@src());3082 const tracy = trace(@src());
3079 defer tracy.end();3083 defer tracy.end();
30803084
...@@ -3125,7 +3129,7 @@ fn funcCommon(...@@ -3125,7 +3129,7 @@ fn funcCommon(
3125 is_extern: bool,3129 is_extern: bool,
3126 src_locs: Zir.Inst.Func.SrcLocs,3130 src_locs: Zir.Inst.Func.SrcLocs,
3127 opt_lib_name: ?[]const u8,3131 opt_lib_name: ?[]const u8,
3128) InnerError!Air.Inst.Ref {3132) CompileError!Air.Inst.Ref {
3129 const src: LazySrcLoc = .{ .node_offset = src_node_offset };3133 const src: LazySrcLoc = .{ .node_offset = src_node_offset };
3130 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };3134 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };
3131 const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);3135 const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);
...@@ -3266,7 +3270,7 @@ fn funcCommon(...@@ -3266,7 +3270,7 @@ fn funcCommon(
3266 return result;3270 return result;
3267}3271}
32683272
3269fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3273fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3270 const tracy = trace(@src());3274 const tracy = trace(@src());
3271 defer tracy.end();3275 defer tracy.end();
32723276
...@@ -3274,7 +3278,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air....@@ -3274,7 +3278,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.
3274 return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);3278 return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);
3275}3279}
32763280
3277fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3281fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3278 const tracy = trace(@src());3282 const tracy = trace(@src());
3279 defer tracy.end();3283 defer tracy.end();
32803284
...@@ -3290,13 +3294,13 @@ fn analyzeAs(...@@ -3290,13 +3294,13 @@ fn analyzeAs(
3290 src: LazySrcLoc,3294 src: LazySrcLoc,
3291 zir_dest_type: Zir.Inst.Ref,3295 zir_dest_type: Zir.Inst.Ref,
3292 zir_operand: Zir.Inst.Ref,3296 zir_operand: Zir.Inst.Ref,
3293) InnerError!Air.Inst.Ref {3297) CompileError!Air.Inst.Ref {
3294 const dest_type = try sema.resolveType(block, src, zir_dest_type);3298 const dest_type = try sema.resolveType(block, src, zir_dest_type);
3295 const operand = sema.resolveInst(zir_operand);3299 const operand = sema.resolveInst(zir_operand);
3296 return sema.coerce(block, dest_type, operand, src);3300 return sema.coerce(block, dest_type, operand, src);
3297}3301}
32983302
3299fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3303fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3300 const tracy = trace(@src());3304 const tracy = trace(@src());
3301 defer tracy.end();3305 defer tracy.end();
33023306
...@@ -3312,7 +3316,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -3312,7 +3316,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
3312 return block.addUnOp(.ptrtoint, ptr);3316 return block.addUnOp(.ptrtoint, ptr);
3313}3317}
33143318
3315fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3319fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3316 const tracy = trace(@src());3320 const tracy = trace(@src());
3317 defer tracy.end();3321 defer tracy.end();
33183322
...@@ -3330,7 +3334,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -3330,7 +3334,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
3330 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);3334 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
3331}3335}
33323336
3333fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3337fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3334 const tracy = trace(@src());3338 const tracy = trace(@src());
3335 defer tracy.end();3339 defer tracy.end();
33363340
...@@ -3343,7 +3347,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -3343,7 +3347,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
3343 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);3347 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
3344}3348}
33453349
3346fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3350fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3347 const tracy = trace(@src());3351 const tracy = trace(@src());
3348 defer tracy.end();3352 defer tracy.end();
33493353
...@@ -3358,7 +3362,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne...@@ -3358,7 +3362,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
3358 return sema.analyzeLoad(block, src, result_ptr, src);3362 return sema.analyzeLoad(block, src, result_ptr, src);
3359}3363}
33603364
3361fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3365fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3362 const tracy = trace(@src());3366 const tracy = trace(@src());
3363 defer tracy.end();3367 defer tracy.end();
33643368
...@@ -3371,7 +3375,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne...@@ -3371,7 +3375,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
3371 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);3375 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
3372}3376}
33733377
3374fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3378fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3375 const tracy = trace(@src());3379 const tracy = trace(@src());
3376 defer tracy.end();3380 defer tracy.end();
33773381
...@@ -3414,7 +3418,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -3414,7 +3418,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
3414 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{});3418 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{});
3415}3419}
34163420
3417fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3421fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3418 const tracy = trace(@src());3422 const tracy = trace(@src());
3419 defer tracy.end();3423 defer tracy.end();
34203424
...@@ -3428,7 +3432,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -3428,7 +3432,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
3428 return sema.bitcast(block, dest_type, operand, operand_src);3432 return sema.bitcast(block, dest_type, operand, operand_src);
3429}3433}
34303434
3431fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3435fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3432 const tracy = trace(@src());3436 const tracy = trace(@src());
3433 defer tracy.end();3437 defer tracy.end();
34343438
...@@ -3471,7 +3475,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr...@@ -3471,7 +3475,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr
3471 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{});3475 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{});
3472}3476}
34733477
3474fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3478fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3475 const tracy = trace(@src());3479 const tracy = trace(@src());
3476 defer tracy.end();3480 defer tracy.end();
34773481
...@@ -3486,7 +3490,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -3486,7 +3490,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
3486 return sema.analyzeLoad(block, sema.src, result_ptr, sema.src);3490 return sema.analyzeLoad(block, sema.src, result_ptr, sema.src);
3487}3491}
34883492
3489fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3493fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3490 const tracy = trace(@src());3494 const tracy = trace(@src());
3491 defer tracy.end();3495 defer tracy.end();
34923496
...@@ -3504,7 +3508,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -3504,7 +3508,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
3504 return sema.analyzeLoad(block, src, result_ptr, src);3508 return sema.analyzeLoad(block, src, result_ptr, src);
3505}3509}
35063510
3507fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3511fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3508 const tracy = trace(@src());3512 const tracy = trace(@src());
3509 defer tracy.end();3513 defer tracy.end();
35103514
...@@ -3514,7 +3518,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -3514,7 +3518,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
3514 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);3518 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);
3515}3519}
35163520
3517fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3521fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3518 const tracy = trace(@src());3522 const tracy = trace(@src());
3519 defer tracy.end();3523 defer tracy.end();
35203524
...@@ -3527,7 +3531,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE...@@ -3527,7 +3531,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
3527 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);3531 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);
3528}3532}
35293533
3530fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3534fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3531 const tracy = trace(@src());3535 const tracy = trace(@src());
3532 defer tracy.end();3536 defer tracy.end();
35333537
...@@ -3540,7 +3544,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -3540,7 +3544,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
3540 return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded);3544 return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded);
3541}3545}
35423546
3543fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3547fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3544 const tracy = trace(@src());3548 const tracy = trace(@src());
3545 defer tracy.end();3549 defer tracy.end();
35463550
...@@ -3554,7 +3558,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -3554,7 +3558,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
3554 return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded);3558 return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded);
3555}3559}
35563560
3557fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {3561fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
3558 const tracy = trace(@src());3562 const tracy = trace(@src());
3559 defer tracy.end();3563 defer tracy.end();
35603564
...@@ -3576,7 +3580,7 @@ fn zirSwitchCapture(...@@ -3576,7 +3580,7 @@ fn zirSwitchCapture(
3576 inst: Zir.Inst.Index,3580 inst: Zir.Inst.Index,
3577 is_multi: bool,3581 is_multi: bool,
3578 is_ref: bool,3582 is_ref: bool,
3579) InnerError!Air.Inst.Ref {3583) CompileError!Air.Inst.Ref {
3580 const tracy = trace(@src());3584 const tracy = trace(@src());
3581 defer tracy.end();3585 defer tracy.end();
35823586
...@@ -3595,7 +3599,7 @@ fn zirSwitchCaptureElse(...@@ -3595,7 +3599,7 @@ fn zirSwitchCaptureElse(
3595 block: *Scope.Block,3599 block: *Scope.Block,
3596 inst: Zir.Inst.Index,3600 inst: Zir.Inst.Index,
3597 is_ref: bool,3601 is_ref: bool,
3598) InnerError!Air.Inst.Ref {3602) CompileError!Air.Inst.Ref {
3599 const tracy = trace(@src());3603 const tracy = trace(@src());
3600 defer tracy.end();3604 defer tracy.end();
36013605
...@@ -3614,7 +3618,7 @@ fn zirSwitchBlock(...@@ -3614,7 +3618,7 @@ fn zirSwitchBlock(
3614 inst: Zir.Inst.Index,3618 inst: Zir.Inst.Index,
3615 is_ref: bool,3619 is_ref: bool,
3616 special_prong: Zir.SpecialProng,3620 special_prong: Zir.SpecialProng,
3617) InnerError!Air.Inst.Ref {3621) CompileError!Air.Inst.Ref {
3618 const tracy = trace(@src());3622 const tracy = trace(@src());
3619 defer tracy.end();3623 defer tracy.end();
36203624
...@@ -3647,7 +3651,7 @@ fn zirSwitchBlockMulti(...@@ -3647,7 +3651,7 @@ fn zirSwitchBlockMulti(
3647 inst: Zir.Inst.Index,3651 inst: Zir.Inst.Index,
3648 is_ref: bool,3652 is_ref: bool,
3649 special_prong: Zir.SpecialProng,3653 special_prong: Zir.SpecialProng,
3650) InnerError!Air.Inst.Ref {3654) CompileError!Air.Inst.Ref {
3651 const tracy = trace(@src());3655 const tracy = trace(@src());
3652 defer tracy.end();3656 defer tracy.end();
36533657
...@@ -3684,7 +3688,7 @@ fn analyzeSwitch(...@@ -3684,7 +3688,7 @@ fn analyzeSwitch(
3684 multi_cases_len: usize,3688 multi_cases_len: usize,
3685 switch_inst: Zir.Inst.Index,3689 switch_inst: Zir.Inst.Index,
3686 src_node_offset: i32,3690 src_node_offset: i32,
3687) InnerError!Air.Inst.Ref {3691) CompileError!Air.Inst.Ref {
3688 const gpa = sema.gpa;3692 const gpa = sema.gpa;
3689 const mod = sema.mod;3693 const mod = sema.mod;
36903694
...@@ -4350,20 +4354,23 @@ fn resolveSwitchItemVal(...@@ -4350,20 +4354,23 @@ fn resolveSwitchItemVal(
4350 switch_node_offset: i32,4354 switch_node_offset: i32,
4351 switch_prong_src: Module.SwitchProngSrc,4355 switch_prong_src: Module.SwitchProngSrc,
4352 range_expand: Module.SwitchProngSrc.RangeExpand,4356 range_expand: Module.SwitchProngSrc.RangeExpand,
4353) InnerError!TypedValue {4357) CompileError!TypedValue {
4354 const item = sema.resolveInst(item_ref);4358 const item = sema.resolveInst(item_ref);
4355 // We have to avoid the other helper functions here because we cannot construct a LazySrcLoc4359 // Constructing a LazySrcLoc is costly because we only have the switch AST node.
4356 // because we only have the switch AST node. Only if we know for sure we need to report4360 // Only if we know for sure we need to report a compile error do we resolve the
4357 // a compile error do we resolve the full source locations.4361 // full source locations.
4358 if (item.value()) |val| {4362 if (sema.resolveConstValue(block, .unneeded, item)) |val| {
4359 if (val.isUndef()) {
4360 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4361 return sema.failWithUseOfUndef(block, src);
4362 }
4363 return TypedValue{ .ty = item.ty, .val = val };4363 return TypedValue{ .ty = item.ty, .val = val };
4364 } else |err| switch (err) {
4365 error.NeededSourceLocation => {
4366 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4367 return TypedValue{
4368 .ty = item.ty,
4369 .val = try sema.resolveConstValue(block, src, item),
4370 };
4371 },
4372 else => |e| return e,
4364 }4373 }
4365 const src = switch_prong_src.resolve(sema.gpa, block.src_decl, switch_node_offset, range_expand);
4366 return sema.failWithNeededComptime(block, src);
4367}4374}
43684375
4369fn validateSwitchRange(4376fn validateSwitchRange(
...@@ -4374,7 +4381,7 @@ fn validateSwitchRange(...@@ -4374,7 +4381,7 @@ fn validateSwitchRange(
4374 last_ref: Zir.Inst.Ref,4381 last_ref: Zir.Inst.Ref,
4375 src_node_offset: i32,4382 src_node_offset: i32,
4376 switch_prong_src: Module.SwitchProngSrc,4383 switch_prong_src: Module.SwitchProngSrc,
4377) InnerError!void {4384) CompileError!void {
4378 const first_val = (try sema.resolveSwitchItemVal(block, first_ref, src_node_offset, switch_prong_src, .first)).val;4385 const first_val = (try sema.resolveSwitchItemVal(block, first_ref, src_node_offset, switch_prong_src, .first)).val;
4379 const last_val = (try sema.resolveSwitchItemVal(block, last_ref, src_node_offset, switch_prong_src, .last)).val;4386 const last_val = (try sema.resolveSwitchItemVal(block, last_ref, src_node_offset, switch_prong_src, .last)).val;
4380 const maybe_prev_src = try range_set.add(first_val, last_val, switch_prong_src);4387 const maybe_prev_src = try range_set.add(first_val, last_val, switch_prong_src);
...@@ -4388,7 +4395,7 @@ fn validateSwitchItem(...@@ -4388,7 +4395,7 @@ fn validateSwitchItem(
4388 item_ref: Zir.Inst.Ref,4395 item_ref: Zir.Inst.Ref,
4389 src_node_offset: i32,4396 src_node_offset: i32,
4390 switch_prong_src: Module.SwitchProngSrc,4397 switch_prong_src: Module.SwitchProngSrc,
4391) InnerError!void {4398) CompileError!void {
4392 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;4399 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
4393 const maybe_prev_src = try range_set.add(item_val, item_val, switch_prong_src);4400 const maybe_prev_src = try range_set.add(item_val, item_val, switch_prong_src);
4394 return sema.validateSwitchDupe(block, maybe_prev_src, switch_prong_src, src_node_offset);4401 return sema.validateSwitchDupe(block, maybe_prev_src, switch_prong_src, src_node_offset);
...@@ -4401,7 +4408,7 @@ fn validateSwitchItemEnum(...@@ -4401,7 +4408,7 @@ fn validateSwitchItemEnum(
4401 item_ref: Zir.Inst.Ref,4408 item_ref: Zir.Inst.Ref,
4402 src_node_offset: i32,4409 src_node_offset: i32,
4403 switch_prong_src: Module.SwitchProngSrc,4410 switch_prong_src: Module.SwitchProngSrc,
4404) InnerError!void {4411) CompileError!void {
4405 const mod = sema.mod;4412 const mod = sema.mod;
4406 const item_tv = try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none);4413 const item_tv = try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none);
4407 const field_index = item_tv.ty.enumTagFieldIndex(item_tv.val) orelse {4414 const field_index = item_tv.ty.enumTagFieldIndex(item_tv.val) orelse {
...@@ -4435,7 +4442,7 @@ fn validateSwitchDupe(...@@ -4435,7 +4442,7 @@ fn validateSwitchDupe(
4435 maybe_prev_src: ?Module.SwitchProngSrc,4442 maybe_prev_src: ?Module.SwitchProngSrc,
4436 switch_prong_src: Module.SwitchProngSrc,4443 switch_prong_src: Module.SwitchProngSrc,
4437 src_node_offset: i32,4444 src_node_offset: i32,
4438) InnerError!void {4445) CompileError!void {
4439 const prev_prong_src = maybe_prev_src orelse return;4446 const prev_prong_src = maybe_prev_src orelse return;
4440 const mod = sema.mod;4447 const mod = sema.mod;
4441 const gpa = sema.gpa;4448 const gpa = sema.gpa;
...@@ -4469,7 +4476,7 @@ fn validateSwitchItemBool(...@@ -4469,7 +4476,7 @@ fn validateSwitchItemBool(
4469 item_ref: Zir.Inst.Ref,4476 item_ref: Zir.Inst.Ref,
4470 src_node_offset: i32,4477 src_node_offset: i32,
4471 switch_prong_src: Module.SwitchProngSrc,4478 switch_prong_src: Module.SwitchProngSrc,
4472) InnerError!void {4479) CompileError!void {
4473 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;4480 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
4474 if (item_val.toBool()) {4481 if (item_val.toBool()) {
4475 true_count.* += 1;4482 true_count.* += 1;
...@@ -4491,7 +4498,7 @@ fn validateSwitchItemSparse(...@@ -4491,7 +4498,7 @@ fn validateSwitchItemSparse(
4491 item_ref: Zir.Inst.Ref,4498 item_ref: Zir.Inst.Ref,
4492 src_node_offset: i32,4499 src_node_offset: i32,
4493 switch_prong_src: Module.SwitchProngSrc,4500 switch_prong_src: Module.SwitchProngSrc,
4494) InnerError!void {4501) CompileError!void {
4495 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;4502 const item_val = (try sema.resolveSwitchItemVal(block, item_ref, src_node_offset, switch_prong_src, .none)).val;
4496 const kv = (try seen_values.fetchPut(item_val, switch_prong_src)) orelse return;4503 const kv = (try seen_values.fetchPut(item_val, switch_prong_src)) orelse return;
4497 return sema.validateSwitchDupe(block, kv.value, switch_prong_src, src_node_offset);4504 return sema.validateSwitchDupe(block, kv.value, switch_prong_src, src_node_offset);
...@@ -4503,7 +4510,7 @@ fn validateSwitchNoRange(...@@ -4503,7 +4510,7 @@ fn validateSwitchNoRange(
4503 ranges_len: u32,4510 ranges_len: u32,
4504 operand_ty: Type,4511 operand_ty: Type,
4505 src_node_offset: i32,4512 src_node_offset: i32,
4506) InnerError!void {4513) CompileError!void {
4507 if (ranges_len == 0)4514 if (ranges_len == 0)
4508 return;4515 return;
45094516
...@@ -4530,7 +4537,7 @@ fn validateSwitchNoRange(...@@ -4530,7 +4537,7 @@ fn validateSwitchNoRange(
4530 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);4537 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
4531}4538}
45324539
4533fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4540fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4534 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;4541 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
4535 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;4542 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4536 _ = extra;4543 _ = extra;
...@@ -4539,7 +4546,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -4539,7 +4546,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
4539 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});4546 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});
4540}4547}
45414548
4542fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4549fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4543 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;4550 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
4544 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;4551 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4545 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };4552 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
...@@ -4562,7 +4569,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -4562,7 +4569,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
4562 return Air.Inst.Ref.bool_false;4569 return Air.Inst.Ref.bool_false;
4563}4570}
45644571
4565fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4572fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4566 const tracy = trace(@src());4573 const tracy = trace(@src());
4567 defer tracy.end();4574 defer tracy.end();
45684575
...@@ -4587,13 +4594,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -4587,13 +4594,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
4587 return sema.addType(file_root_decl.ty);4594 return sema.addType(file_root_decl.ty);
4588}4595}
45894596
4590fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4597fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4591 _ = block;4598 _ = block;
4592 _ = inst;4599 _ = inst;
4593 return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{});4600 return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{});
4594}4601}
45954602
4596fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4603fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4597 const tracy = trace(@src());4604 const tracy = trace(@src());
4598 defer tracy.end();4605 defer tracy.end();
45994606
...@@ -4602,7 +4609,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air...@@ -4602,7 +4609,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air
4602 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});4609 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});
4603}4610}
46044611
4605fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4612fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4606 const tracy = trace(@src());4613 const tracy = trace(@src());
4607 defer tracy.end();4614 defer tracy.end();
46084615
...@@ -4615,7 +4622,7 @@ fn zirBitwise(...@@ -4615,7 +4622,7 @@ fn zirBitwise(
4615 block: *Scope.Block,4622 block: *Scope.Block,
4616 inst: Zir.Inst.Index,4623 inst: Zir.Inst.Index,
4617 air_tag: Air.Inst.Tag,4624 air_tag: Air.Inst.Tag,
4618) InnerError!Air.Inst.Ref {4625) CompileError!Air.Inst.Ref {
4619 const tracy = trace(@src());4626 const tracy = trace(@src());
4620 defer tracy.end();4627 defer tracy.end();
46214628
...@@ -4675,7 +4682,7 @@ fn zirBitwise(...@@ -4675,7 +4682,7 @@ fn zirBitwise(
4675 return block.addBinOp(air_tag, casted_lhs, casted_rhs);4682 return block.addBinOp(air_tag, casted_lhs, casted_rhs);
4676}4683}
46774684
4678fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4685fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4679 const tracy = trace(@src());4686 const tracy = trace(@src());
4680 defer tracy.end();4687 defer tracy.end();
46814688
...@@ -4683,7 +4690,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -4683,7 +4690,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
4683 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});4690 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});
4684}4691}
46854692
4686fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4693fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4687 const tracy = trace(@src());4694 const tracy = trace(@src());
4688 defer tracy.end();4695 defer tracy.end();
46894696
...@@ -4691,7 +4698,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -4691,7 +4698,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
4691 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});4698 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});
4692}4699}
46934700
4694fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4701fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4695 const tracy = trace(@src());4702 const tracy = trace(@src());
4696 defer tracy.end();4703 defer tracy.end();
46974704
...@@ -4704,7 +4711,7 @@ fn zirNegate(...@@ -4704,7 +4711,7 @@ fn zirNegate(
4704 block: *Scope.Block,4711 block: *Scope.Block,
4705 inst: Zir.Inst.Index,4712 inst: Zir.Inst.Index,
4706 tag_override: Zir.Inst.Tag,4713 tag_override: Zir.Inst.Tag,
4707) InnerError!Air.Inst.Ref {4714) CompileError!Air.Inst.Ref {
4708 const tracy = trace(@src());4715 const tracy = trace(@src());
4709 defer tracy.end();4716 defer tracy.end();
47104717
...@@ -4718,7 +4725,7 @@ fn zirNegate(...@@ -4718,7 +4725,7 @@ fn zirNegate(
4718 return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src);4725 return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src);
4719}4726}
47204727
4721fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4728fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4722 const tracy = trace(@src());4729 const tracy = trace(@src());
4723 defer tracy.end();4730 defer tracy.end();
47244731
...@@ -4738,7 +4745,7 @@ fn zirOverflowArithmetic(...@@ -4738,7 +4745,7 @@ fn zirOverflowArithmetic(
4738 sema: *Sema,4745 sema: *Sema,
4739 block: *Scope.Block,4746 block: *Scope.Block,
4740 extended: Zir.Inst.Extended.InstData,4747 extended: Zir.Inst.Extended.InstData,
4741) InnerError!Air.Inst.Ref {4748) CompileError!Air.Inst.Ref {
4742 const tracy = trace(@src());4749 const tracy = trace(@src());
4743 defer tracy.end();4750 defer tracy.end();
47444751
...@@ -4757,7 +4764,7 @@ fn analyzeArithmetic(...@@ -4757,7 +4764,7 @@ fn analyzeArithmetic(
4757 src: LazySrcLoc,4764 src: LazySrcLoc,
4758 lhs_src: LazySrcLoc,4765 lhs_src: LazySrcLoc,
4759 rhs_src: LazySrcLoc,4766 rhs_src: LazySrcLoc,
4760) InnerError!Air.Inst.Ref {4767) CompileError!Air.Inst.Ref {
4761 const instructions = &[_]Air.Inst.Index{ lhs, rhs };4768 const instructions = &[_]Air.Inst.Index{ lhs, rhs };
4762 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);4769 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
4763 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);4770 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
...@@ -4867,7 +4874,7 @@ fn analyzeArithmetic(...@@ -4867,7 +4874,7 @@ fn analyzeArithmetic(
4867 return block.addBinOp(air_tag, casted_lhs, casted_rhs);4874 return block.addBinOp(air_tag, casted_lhs, casted_rhs);
4868}4875}
48694876
4870fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {4877fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4871 const tracy = trace(@src());4878 const tracy = trace(@src());
4872 defer tracy.end();4879 defer tracy.end();
48734880
...@@ -4882,7 +4889,7 @@ fn zirAsm(...@@ -4882,7 +4889,7 @@ fn zirAsm(
4882 sema: *Sema,4889 sema: *Sema,
4883 block: *Scope.Block,4890 block: *Scope.Block,
4884 extended: Zir.Inst.Extended.InstData,4891 extended: Zir.Inst.Extended.InstData,
4885) InnerError!Air.Inst.Ref {4892) CompileError!Air.Inst.Ref {
4886 const tracy = trace(@src());4893 const tracy = trace(@src());
4887 defer tracy.end();4894 defer tracy.end();
48884895
...@@ -4966,7 +4973,7 @@ fn zirCmp(...@@ -4966,7 +4973,7 @@ fn zirCmp(
4966 block: *Scope.Block,4973 block: *Scope.Block,
4967 inst: Zir.Inst.Index,4974 inst: Zir.Inst.Index,
4968 op: std.math.CompareOperator,4975 op: std.math.CompareOperator,
4969) InnerError!Air.Inst.Ref {4976) CompileError!Air.Inst.Ref {
4970 const tracy = trace(@src());4977 const tracy = trace(@src());
4971 defer tracy.end();4978 defer tracy.end();
49724979
...@@ -5091,7 +5098,7 @@ fn zirCmp(...@@ -5091,7 +5098,7 @@ fn zirCmp(
5091 return block.addBinOp(tag, casted_lhs, casted_rhs);5098 return block.addBinOp(tag, casted_lhs, casted_rhs);
5092}5099}
50935100
5094fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5101fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5095 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5102 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5096 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5103 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5097 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);5104 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
...@@ -5100,7 +5107,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -5100,7 +5107,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
5100 return sema.addIntUnsigned(Type.initTag(.comptime_int), abi_size);5107 return sema.addIntUnsigned(Type.initTag(.comptime_int), abi_size);
5101}5108}
51025109
5103fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5110fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5104 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5111 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5105 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5112 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5106 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);5113 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
...@@ -5113,7 +5120,7 @@ fn zirThis(...@@ -5113,7 +5120,7 @@ fn zirThis(
5113 sema: *Sema,5120 sema: *Sema,
5114 block: *Scope.Block,5121 block: *Scope.Block,
5115 extended: Zir.Inst.Extended.InstData,5122 extended: Zir.Inst.Extended.InstData,
5116) InnerError!Air.Inst.Ref {5123) CompileError!Air.Inst.Ref {
5117 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5124 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5118 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{});5125 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{});
5119}5126}
...@@ -5122,7 +5129,7 @@ fn zirRetAddr(...@@ -5122,7 +5129,7 @@ fn zirRetAddr(
5122 sema: *Sema,5129 sema: *Sema,
5123 block: *Scope.Block,5130 block: *Scope.Block,
5124 extended: Zir.Inst.Extended.InstData,5131 extended: Zir.Inst.Extended.InstData,
5125) InnerError!Air.Inst.Ref {5132) CompileError!Air.Inst.Ref {
5126 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5133 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5127 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{});5134 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{});
5128}5135}
...@@ -5131,12 +5138,12 @@ fn zirBuiltinSrc(...@@ -5131,12 +5138,12 @@ fn zirBuiltinSrc(
5131 sema: *Sema,5138 sema: *Sema,
5132 block: *Scope.Block,5139 block: *Scope.Block,
5133 extended: Zir.Inst.Extended.InstData,5140 extended: Zir.Inst.Extended.InstData,
5134) InnerError!Air.Inst.Ref {5141) CompileError!Air.Inst.Ref {
5135 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5142 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5136 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{});5143 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{});
5137}5144}
51385145
5139fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5146fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5140 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5147 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5141 const src = inst_data.src();5148 const src = inst_data.src();
5142 const ty = try sema.resolveType(block, src, inst_data.operand);5149 const ty = try sema.resolveType(block, src, inst_data.operand);
...@@ -5179,7 +5186,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -5179,7 +5186,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
5179 }5186 }
5180}5187}
51815188
5182fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5189fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5183 _ = block;5190 _ = block;
5184 const zir_datas = sema.code.instructions.items(.data);5191 const zir_datas = sema.code.instructions.items(.data);
5185 const inst_data = zir_datas[inst].un_node;5192 const inst_data = zir_datas[inst].un_node;
...@@ -5187,7 +5194,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!...@@ -5187,7 +5194,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
5187 return sema.addType(operand.ty);5194 return sema.addType(operand.ty);
5188}5195}
51895196
5190fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5197fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5191 _ = block;5198 _ = block;
5192 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5199 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5193 const operand_ptr = sema.resolveInst(inst_data.operand);5200 const operand_ptr = sema.resolveInst(inst_data.operand);
...@@ -5195,13 +5202,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr...@@ -5195,13 +5202,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr
5195 return sema.addType(elem_ty);5202 return sema.addType(elem_ty);
5196}5203}
51975204
5198fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5205fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5199 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5206 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5200 const src = inst_data.src();5207 const src = inst_data.src();
5201 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{});5208 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{});
5202}5209}
52035210
5204fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5211fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5205 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5212 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5206 const src = inst_data.src();5213 const src = inst_data.src();
5207 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{});5214 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{});
...@@ -5211,7 +5218,7 @@ fn zirTypeofPeer(...@@ -5211,7 +5218,7 @@ fn zirTypeofPeer(
5211 sema: *Sema,5218 sema: *Sema,
5212 block: *Scope.Block,5219 block: *Scope.Block,
5213 extended: Zir.Inst.Extended.InstData,5220 extended: Zir.Inst.Extended.InstData,
5214) InnerError!Air.Inst.Ref {5221) CompileError!Air.Inst.Ref {
5215 const tracy = trace(@src());5222 const tracy = trace(@src());
5216 defer tracy.end();5223 defer tracy.end();
52175224
...@@ -5230,7 +5237,7 @@ fn zirTypeofPeer(...@@ -5230,7 +5237,7 @@ fn zirTypeofPeer(
5230 return sema.addType(result_type);5237 return sema.addType(result_type);
5231}5238}
52325239
5233fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5240fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5234 const tracy = trace(@src());5241 const tracy = trace(@src());
5235 defer tracy.end();5242 defer tracy.end();
52365243
...@@ -5256,7 +5263,7 @@ fn zirBoolOp(...@@ -5256,7 +5263,7 @@ fn zirBoolOp(
5256 block: *Scope.Block,5263 block: *Scope.Block,
5257 inst: Zir.Inst.Index,5264 inst: Zir.Inst.Index,
5258 is_bool_or: bool,5265 is_bool_or: bool,
5259) InnerError!Air.Inst.Ref {5266) CompileError!Air.Inst.Ref {
5260 const tracy = trace(@src());5267 const tracy = trace(@src());
5261 defer tracy.end();5268 defer tracy.end();
52625269
...@@ -5295,7 +5302,7 @@ fn zirBoolBr(...@@ -5295,7 +5302,7 @@ fn zirBoolBr(
5295 parent_block: *Scope.Block,5302 parent_block: *Scope.Block,
5296 inst: Zir.Inst.Index,5303 inst: Zir.Inst.Index,
5297 is_bool_or: bool,5304 is_bool_or: bool,
5298) InnerError!Air.Inst.Ref {5305) CompileError!Air.Inst.Ref {
5299 const tracy = trace(@src());5306 const tracy = trace(@src());
5300 defer tracy.end();5307 defer tracy.end();
53015308
...@@ -5369,7 +5376,7 @@ fn zirIsNonNull(...@@ -5369,7 +5376,7 @@ fn zirIsNonNull(
5369 sema: *Sema,5376 sema: *Sema,
5370 block: *Scope.Block,5377 block: *Scope.Block,
5371 inst: Zir.Inst.Index,5378 inst: Zir.Inst.Index,
5372) InnerError!Air.Inst.Ref {5379) CompileError!Air.Inst.Ref {
5373 const tracy = trace(@src());5380 const tracy = trace(@src());
5374 defer tracy.end();5381 defer tracy.end();
53755382
...@@ -5383,7 +5390,7 @@ fn zirIsNonNullPtr(...@@ -5383,7 +5390,7 @@ fn zirIsNonNullPtr(
5383 sema: *Sema,5390 sema: *Sema,
5384 block: *Scope.Block,5391 block: *Scope.Block,
5385 inst: Zir.Inst.Index,5392 inst: Zir.Inst.Index,
5386) InnerError!Air.Inst.Ref {5393) CompileError!Air.Inst.Ref {
5387 const tracy = trace(@src());5394 const tracy = trace(@src());
5388 defer tracy.end();5395 defer tracy.end();
53895396
...@@ -5394,7 +5401,7 @@ fn zirIsNonNullPtr(...@@ -5394,7 +5401,7 @@ fn zirIsNonNullPtr(
5394 return sema.analyzeIsNull(block, src, loaded, true);5401 return sema.analyzeIsNull(block, src, loaded, true);
5395}5402}
53965403
5397fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5404fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5398 const tracy = trace(@src());5405 const tracy = trace(@src());
5399 defer tracy.end();5406 defer tracy.end();
54005407
...@@ -5403,7 +5410,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -5403,7 +5410,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
5403 return sema.analyzeIsNonErr(block, inst_data.src(), operand);5410 return sema.analyzeIsNonErr(block, inst_data.src(), operand);
5404}5411}
54055412
5406fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5413fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5407 const tracy = trace(@src());5414 const tracy = trace(@src());
5408 defer tracy.end();5415 defer tracy.end();
54095416
...@@ -5418,7 +5425,7 @@ fn zirCondbr(...@@ -5418,7 +5425,7 @@ fn zirCondbr(
5418 sema: *Sema,5425 sema: *Sema,
5419 parent_block: *Scope.Block,5426 parent_block: *Scope.Block,
5420 inst: Zir.Inst.Index,5427 inst: Zir.Inst.Index,
5421) InnerError!Zir.Inst.Index {5428) CompileError!Zir.Inst.Index {
5422 const tracy = trace(@src());5429 const tracy = trace(@src());
5423 defer tracy.end();5430 defer tracy.end();
54245431
...@@ -5461,7 +5468,7 @@ fn zirCondbr(...@@ -5461,7 +5468,7 @@ fn zirCondbr(
5461 return always_noreturn;5468 return always_noreturn;
5462}5469}
54635470
5464fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {5471fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
5465 const tracy = trace(@src());5472 const tracy = trace(@src());
5466 defer tracy.end();5473 defer tracy.end();
54675474
...@@ -5482,7 +5489,7 @@ fn zirRetErrValue(...@@ -5482,7 +5489,7 @@ fn zirRetErrValue(
5482 sema: *Sema,5489 sema: *Sema,
5483 block: *Scope.Block,5490 block: *Scope.Block,
5484 inst: Zir.Inst.Index,5491 inst: Zir.Inst.Index,
5485) InnerError!Zir.Inst.Index {5492) CompileError!Zir.Inst.Index {
5486 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;5493 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
5487 const err_name = inst_data.get(sema.code);5494 const err_name = inst_data.get(sema.code);
5488 const src = inst_data.src();5495 const src = inst_data.src();
...@@ -5507,7 +5514,7 @@ fn zirRetCoerce(...@@ -5507,7 +5514,7 @@ fn zirRetCoerce(
5507 block: *Scope.Block,5514 block: *Scope.Block,
5508 inst: Zir.Inst.Index,5515 inst: Zir.Inst.Index,
5509 need_coercion: bool,5516 need_coercion: bool,
5510) InnerError!Zir.Inst.Index {5517) CompileError!Zir.Inst.Index {
5511 const tracy = trace(@src());5518 const tracy = trace(@src());
5512 defer tracy.end();5519 defer tracy.end();
55135520
...@@ -5518,7 +5525,7 @@ fn zirRetCoerce(...@@ -5518,7 +5525,7 @@ fn zirRetCoerce(
5518 return sema.analyzeRet(block, operand, src, need_coercion);5525 return sema.analyzeRet(block, operand, src, need_coercion);
5519}5526}
55205527
5521fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {5528fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index {
5522 const tracy = trace(@src());5529 const tracy = trace(@src());
5523 defer tracy.end();5530 defer tracy.end();
55245531
...@@ -5535,7 +5542,7 @@ fn analyzeRet(...@@ -5535,7 +5542,7 @@ fn analyzeRet(
5535 operand: Air.Inst.Ref,5542 operand: Air.Inst.Ref,
5536 src: LazySrcLoc,5543 src: LazySrcLoc,
5537 need_coercion: bool,5544 need_coercion: bool,
5538) InnerError!Zir.Inst.Index {5545) CompileError!Zir.Inst.Index {
5539 if (block.inlining) |inlining| {5546 if (block.inlining) |inlining| {
5540 // We are inlining a function call; rewrite the `ret` as a `break`.5547 // We are inlining a function call; rewrite the `ret` as a `break`.
5541 try inlining.merges.results.append(sema.gpa, operand);5548 try inlining.merges.results.append(sema.gpa, operand);
...@@ -5564,7 +5571,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool {...@@ -5564,7 +5571,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool {
5564 };5571 };
5565}5572}
55665573
5567fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5574fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5568 const tracy = trace(@src());5575 const tracy = trace(@src());
5569 defer tracy.end();5576 defer tracy.end();
55705577
...@@ -5585,7 +5592,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne...@@ -5585,7 +5592,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
5585 return sema.addType(ty);5592 return sema.addType(ty);
5586}5593}
55875594
5588fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5595fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5589 const tracy = trace(@src());5596 const tracy = trace(@src());
5590 defer tracy.end();5597 defer tracy.end();
55915598
...@@ -5639,7 +5646,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError...@@ -5639,7 +5646,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
5639 return sema.addType(ty);5646 return sema.addType(ty);
5640}5647}
56415648
5642fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5649fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5643 const tracy = trace(@src());5650 const tracy = trace(@src());
5644 defer tracy.end();5651 defer tracy.end();
56455652
...@@ -5653,13 +5660,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In...@@ -5653,13 +5660,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
5653 });5660 });
5654}5661}
56555662
5656fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5663fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5657 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5664 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5658 const src = inst_data.src();5665 const src = inst_data.src();
5659 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{});5666 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{});
5660}5667}
56615668
5662fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {5669fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
5663 const mod = sema.mod;5670 const mod = sema.mod;
5664 const gpa = sema.gpa;5671 const gpa = sema.gpa;
5665 const zir_datas = sema.code.instructions.items(.data);5672 const zir_datas = sema.code.instructions.items(.data);
...@@ -5772,7 +5779,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:...@@ -5772,7 +5779,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
5772 return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{});5779 return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{});
5773}5780}
57745781
5775fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {5782fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
5776 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5783 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5777 const src = inst_data.src();5784 const src = inst_data.src();
57785785
...@@ -5780,7 +5787,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_...@@ -5780,7 +5787,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_
5780 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});5787 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});
5781}5788}
57825789
5783fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {5790fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
5784 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5791 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5785 const src = inst_data.src();5792 const src = inst_data.src();
57865793
...@@ -5788,7 +5795,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:...@@ -5788,7 +5795,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref:
5788 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});5795 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});
5789}5796}
57905797
5791fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref {5798fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) CompileError!Air.Inst.Ref {
5792 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5799 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5793 const src = inst_data.src();5800 const src = inst_data.src();
57945801
...@@ -5796,13 +5803,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r...@@ -5796,13 +5803,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r
5796 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});5803 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});
5797}5804}
57985805
5799fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5806fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5800 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5807 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5801 const src = inst_data.src();5808 const src = inst_data.src();
5802 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{});5809 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{});
5803}5810}
58045811
5805fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5812fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5806 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5813 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5807 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;5814 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;
5808 const src = inst_data.src();5815 const src = inst_data.src();
...@@ -5824,7 +5831,7 @@ fn zirErrorReturnTrace(...@@ -5824,7 +5831,7 @@ fn zirErrorReturnTrace(
5824 sema: *Sema,5831 sema: *Sema,
5825 block: *Scope.Block,5832 block: *Scope.Block,
5826 extended: Zir.Inst.Extended.InstData,5833 extended: Zir.Inst.Extended.InstData,
5827) InnerError!Air.Inst.Ref {5834) CompileError!Air.Inst.Ref {
5828 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5835 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5829 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{});5836 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{});
5830}5837}
...@@ -5833,7 +5840,7 @@ fn zirFrame(...@@ -5833,7 +5840,7 @@ fn zirFrame(
5833 sema: *Sema,5840 sema: *Sema,
5834 block: *Scope.Block,5841 block: *Scope.Block,
5835 extended: Zir.Inst.Extended.InstData,5842 extended: Zir.Inst.Extended.InstData,
5836) InnerError!Air.Inst.Ref {5843) CompileError!Air.Inst.Ref {
5837 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5844 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5838 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{});5845 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{});
5839}5846}
...@@ -5842,84 +5849,84 @@ fn zirFrameAddress(...@@ -5842,84 +5849,84 @@ fn zirFrameAddress(
5842 sema: *Sema,5849 sema: *Sema,
5843 block: *Scope.Block,5850 block: *Scope.Block,
5844 extended: Zir.Inst.Extended.InstData,5851 extended: Zir.Inst.Extended.InstData,
5845) InnerError!Air.Inst.Ref {5852) CompileError!Air.Inst.Ref {
5846 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };5853 const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) };
5847 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});5854 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});
5848}5855}
58495856
5850fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5857fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5851 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5858 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5852 const src = inst_data.src();5859 const src = inst_data.src();
5853 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{});5860 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{});
5854}5861}
58555862
5856fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5863fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5857 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5864 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5858 const src = inst_data.src();5865 const src = inst_data.src();
5859 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{});5866 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{});
5860}5867}
58615868
5862fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5869fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5863 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5870 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5864 const src = inst_data.src();5871 const src = inst_data.src();
5865 return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{});5872 return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{});
5866}5873}
58675874
5868fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5875fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5869 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5876 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5870 const src = inst_data.src();5877 const src = inst_data.src();
5871 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{});5878 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{});
5872}5879}
58735880
5874fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5881fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5875 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5882 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5876 const src = inst_data.src();5883 const src = inst_data.src();
5877 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{});5884 return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{});
5878}5885}
58795886
5880fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5887fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5881 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5888 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5882 const src = inst_data.src();5889 const src = inst_data.src();
5883 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{});5890 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{});
5884}5891}
58855892
5886fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5893fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5887 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5894 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5888 const src = inst_data.src();5895 const src = inst_data.src();
5889 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{});5896 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{});
5890}5897}
58915898
5892fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5899fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5893 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5900 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5894 const src = inst_data.src();5901 const src = inst_data.src();
5895 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{});5902 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{});
5896}5903}
58975904
5898fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5905fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5899 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5906 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5900 const src = inst_data.src();5907 const src = inst_data.src();
5901 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{});5908 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{});
5902}5909}
59035910
5904fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5911fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5905 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5912 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5906 const src = inst_data.src();5913 const src = inst_data.src();
5907 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{});5914 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{});
5908}5915}
59095916
5910fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5917fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5911 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5918 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5912 const src = inst_data.src();5919 const src = inst_data.src();
5913 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{});5920 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{});
5914}5921}
59155922
5916fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5923fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5917 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5924 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5918 const src = inst_data.src();5925 const src = inst_data.src();
5919 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{});5926 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{});
5920}5927}
59215928
5922fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5929fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5923 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5930 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5924 const src = inst_data.src();5931 const src = inst_data.src();
59255932
...@@ -5982,199 +5989,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -5982,199 +5989,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
5982 return block.addTyOp(.bitcast, type_res, operand_coerced);5989 return block.addTyOp(.bitcast, type_res, operand_coerced);
5983}5990}
59845991
5985fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5992fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5986 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5993 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5987 const src = inst_data.src();5994 const src = inst_data.src();
5988 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{});5995 return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{});
5989}5996}
59905997
5991fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {5998fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5992 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5999 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5993 const src = inst_data.src();6000 const src = inst_data.src();
5994 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{});6001 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{});
5995}6002}
59966003
5997fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6004fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
5998 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6005 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5999 const src = inst_data.src();6006 const src = inst_data.src();
6000 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{});6007 return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{});
6001}6008}
60026009
6003fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6010fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6004 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6011 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6005 const src = inst_data.src();6012 const src = inst_data.src();
6006 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{});6013 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{});
6007}6014}
60086015
6009fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6016fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6010 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6017 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6011 const src = inst_data.src();6018 const src = inst_data.src();
6012 return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{});6019 return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{});
6013}6020}
60146021
6015fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6022fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6016 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6023 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6017 const src = inst_data.src();6024 const src = inst_data.src();
6018 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{});6025 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{});
6019}6026}
60206027
6021fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6028fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6022 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6029 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6023 const src = inst_data.src();6030 const src = inst_data.src();
6024 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{});6031 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{});
6025}6032}
60266033
6027fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6034fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6028 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6035 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6029 const src = inst_data.src();6036 const src = inst_data.src();
6030 return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{});6037 return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{});
6031}6038}
60326039
6033fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6040fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6034 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6041 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6035 const src = inst_data.src();6042 const src = inst_data.src();
6036 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{});6043 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{});
6037}6044}
60386045
6039fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6046fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6040 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6047 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6041 const src = inst_data.src();6048 const src = inst_data.src();
6042 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{});6049 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{});
6043}6050}
60446051
6045fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6052fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6046 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6053 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6047 const src = inst_data.src();6054 const src = inst_data.src();
6048 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{});6055 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{});
6049}6056}
60506057
6051fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6058fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6052 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6059 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6053 const src = inst_data.src();6060 const src = inst_data.src();
6054 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{});6061 return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{});
6055}6062}
60566063
6057fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6064fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6058 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6065 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6059 const src = inst_data.src();6066 const src = inst_data.src();
6060 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{});6067 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{});
6061}6068}
60626069
6063fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6070fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6064 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6071 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6065 const src = inst_data.src();6072 const src = inst_data.src();
6066 return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{});6073 return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{});
6067}6074}
60686075
6069fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6076fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6070 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6077 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6071 const src = inst_data.src();6078 const src = inst_data.src();
6072 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{});6079 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{});
6073}6080}
60746081
6075fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6082fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6076 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6083 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6077 const src = inst_data.src();6084 const src = inst_data.src();
6078 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{});6085 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{});
6079}6086}
60806087
6081fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6088fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6082 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6089 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6083 const src = inst_data.src();6090 const src = inst_data.src();
6084 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{});6091 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{});
6085}6092}
60866093
6087fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6094fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6088 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6095 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6089 const src = inst_data.src();6096 const src = inst_data.src();
6090 return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{});6097 return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{});
6091}6098}
60926099
6093fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6100fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6094 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6101 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6095 const src = inst_data.src();6102 const src = inst_data.src();
6096 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{});6103 return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{});
6097}6104}
60986105
6099fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6106fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6100 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6107 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6101 const src = inst_data.src();6108 const src = inst_data.src();
6102 return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{});6109 return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{});
6103}6110}
61046111
6105fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6112fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6106 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6113 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6107 const src = inst_data.src();6114 const src = inst_data.src();
6108 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{});6115 return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{});
6109}6116}
61106117
6111fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6118fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6112 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6119 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6113 const src = inst_data.src();6120 const src = inst_data.src();
6114 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{});6121 return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{});
6115}6122}
61166123
6117fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6124fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6118 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6125 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6119 const src = inst_data.src();6126 const src = inst_data.src();
6120 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{});6127 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{});
6121}6128}
61226129
6123fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6130fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6124 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6131 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6125 const src = inst_data.src();6132 const src = inst_data.src();
6126 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{});6133 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{});
6127}6134}
61286135
6129fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6136fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6130 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6137 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6131 const src = inst_data.src();6138 const src = inst_data.src();
6132 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{});6139 return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{});
6133}6140}
61346141
6135fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6142fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6136 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6143 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6137 const src = inst_data.src();6144 const src = inst_data.src();
6138 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{});6145 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{});
6139}6146}
61406147
6141fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6148fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6142 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6149 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6143 const src = inst_data.src();6150 const src = inst_data.src();
6144 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{});6151 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{});
6145}6152}
61466153
6147fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6154fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6148 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6155 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6149 const src = inst_data.src();6156 const src = inst_data.src();
6150 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{});6157 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{});
6151}6158}
61526159
6153fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6160fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6154 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6161 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6155 const src = inst_data.src();6162 const src = inst_data.src();
6156 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{});6163 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{});
6157}6164}
61586165
6159fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6166fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6160 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6167 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6161 const src = inst_data.src();6168 const src = inst_data.src();
6162 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{});6169 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{});
6163}6170}
61646171
6165fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6172fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6166 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6173 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6167 const src = inst_data.src();6174 const src = inst_data.src();
6168 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{});6175 return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{});
6169}6176}
61706177
6171fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6178fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6172 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;6179 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
6173 const src = inst_data.src();6180 const src = inst_data.src();
6174 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{});6181 return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{});
6175}6182}
61766183
6177fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref {6184fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6178 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6185 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6179 const src = inst_data.src();6186 const src = inst_data.src();
6180 return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{});6187 return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{});
...@@ -6185,7 +6192,7 @@ fn zirAwait(...@@ -6185,7 +6192,7 @@ fn zirAwait(
6185 block: *Scope.Block,6192 block: *Scope.Block,
6186 inst: Zir.Inst.Index,6193 inst: Zir.Inst.Index,
6187 is_nosuspend: bool,6194 is_nosuspend: bool,
6188) InnerError!Air.Inst.Ref {6195) CompileError!Air.Inst.Ref {
6189 const inst_data = sema.code.instructions.items(.data)[inst].un_node;6196 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
6190 const src = inst_data.src();6197 const src = inst_data.src();
61916198
...@@ -6197,7 +6204,7 @@ fn zirVarExtended(...@@ -6197,7 +6204,7 @@ fn zirVarExtended(
6197 sema: *Sema,6204 sema: *Sema,
6198 block: *Scope.Block,6205 block: *Scope.Block,
6199 extended: Zir.Inst.Extended.InstData,6206 extended: Zir.Inst.Extended.InstData,
6200) InnerError!Air.Inst.Ref {6207) CompileError!Air.Inst.Ref {
6201 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);6208 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
6202 const src = sema.src;6209 const src = sema.src;
6203 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type6210 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type
...@@ -6263,7 +6270,7 @@ fn zirFuncExtended(...@@ -6263,7 +6270,7 @@ fn zirFuncExtended(
6263 block: *Scope.Block,6270 block: *Scope.Block,
6264 extended: Zir.Inst.Extended.InstData,6271 extended: Zir.Inst.Extended.InstData,
6265 inst: Zir.Inst.Index,6272 inst: Zir.Inst.Index,
6266) InnerError!Air.Inst.Ref {6273) CompileError!Air.Inst.Ref {
6267 const tracy = trace(@src());6274 const tracy = trace(@src());
6268 defer tracy.end();6275 defer tracy.end();
62696276
...@@ -6330,7 +6337,7 @@ fn zirCUndef(...@@ -6330,7 +6337,7 @@ fn zirCUndef(
6330 sema: *Sema,6337 sema: *Sema,
6331 block: *Scope.Block,6338 block: *Scope.Block,
6332 extended: Zir.Inst.Extended.InstData,6339 extended: Zir.Inst.Extended.InstData,
6333) InnerError!Air.Inst.Ref {6340) CompileError!Air.Inst.Ref {
6334 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;6341 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6335 const src: LazySrcLoc = .{ .node_offset = extra.node };6342 const src: LazySrcLoc = .{ .node_offset = extra.node };
6336 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{});6343 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{});
...@@ -6340,7 +6347,7 @@ fn zirCInclude(...@@ -6340,7 +6347,7 @@ fn zirCInclude(
6340 sema: *Sema,6347 sema: *Sema,
6341 block: *Scope.Block,6348 block: *Scope.Block,
6342 extended: Zir.Inst.Extended.InstData,6349 extended: Zir.Inst.Extended.InstData,
6343) InnerError!Air.Inst.Ref {6350) CompileError!Air.Inst.Ref {
6344 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;6351 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6345 const src: LazySrcLoc = .{ .node_offset = extra.node };6352 const src: LazySrcLoc = .{ .node_offset = extra.node };
6346 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{});6353 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{});
...@@ -6350,7 +6357,7 @@ fn zirCDefine(...@@ -6350,7 +6357,7 @@ fn zirCDefine(
6350 sema: *Sema,6357 sema: *Sema,
6351 block: *Scope.Block,6358 block: *Scope.Block,
6352 extended: Zir.Inst.Extended.InstData,6359 extended: Zir.Inst.Extended.InstData,
6353) InnerError!Air.Inst.Ref {6360) CompileError!Air.Inst.Ref {
6354 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;6361 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
6355 const src: LazySrcLoc = .{ .node_offset = extra.node };6362 const src: LazySrcLoc = .{ .node_offset = extra.node };
6356 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{});6363 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{});
...@@ -6360,7 +6367,7 @@ fn zirWasmMemorySize(...@@ -6360,7 +6367,7 @@ fn zirWasmMemorySize(
6360 sema: *Sema,6367 sema: *Sema,
6361 block: *Scope.Block,6368 block: *Scope.Block,
6362 extended: Zir.Inst.Extended.InstData,6369 extended: Zir.Inst.Extended.InstData,
6363) InnerError!Air.Inst.Ref {6370) CompileError!Air.Inst.Ref {
6364 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;6371 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
6365 const src: LazySrcLoc = .{ .node_offset = extra.node };6372 const src: LazySrcLoc = .{ .node_offset = extra.node };
6366 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{});6373 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{});
...@@ -6370,7 +6377,7 @@ fn zirWasmMemoryGrow(...@@ -6370,7 +6377,7 @@ fn zirWasmMemoryGrow(
6370 sema: *Sema,6377 sema: *Sema,
6371 block: *Scope.Block,6378 block: *Scope.Block,
6372 extended: Zir.Inst.Extended.InstData,6379 extended: Zir.Inst.Extended.InstData,
6373) InnerError!Air.Inst.Ref {6380) CompileError!Air.Inst.Ref {
6374 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;6381 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
6375 const src: LazySrcLoc = .{ .node_offset = extra.node };6382 const src: LazySrcLoc = .{ .node_offset = extra.node };
6376 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{});6383 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{});
...@@ -6380,7 +6387,7 @@ fn zirBuiltinExtern(...@@ -6380,7 +6387,7 @@ fn zirBuiltinExtern(
6380 sema: *Sema,6387 sema: *Sema,
6381 block: *Scope.Block,6388 block: *Scope.Block,
6382 extended: Zir.Inst.Extended.InstData,6389 extended: Zir.Inst.Extended.InstData,
6383) InnerError!Air.Inst.Ref {6390) CompileError!Air.Inst.Ref {
6384 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;6391 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
6385 const src: LazySrcLoc = .{ .node_offset = extra.node };6392 const src: LazySrcLoc = .{ .node_offset = extra.node };
6386 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{});6393 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{});
...@@ -6556,7 +6563,7 @@ fn namedFieldPtr(...@@ -6556,7 +6563,7 @@ fn namedFieldPtr(
6556 object_ptr: Air.Inst.Ref,6563 object_ptr: Air.Inst.Ref,
6557 field_name: []const u8,6564 field_name: []const u8,
6558 field_name_src: LazySrcLoc,6565 field_name_src: LazySrcLoc,
6559) InnerError!Air.Inst.Ref {6566) CompileError!Air.Inst.Ref {
6560 const mod = sema.mod;6567 const mod = sema.mod;
6561 const arena = sema.arena;6568 const arena = sema.arena;
65626569
...@@ -6706,7 +6713,7 @@ fn analyzeNamespaceLookup(...@@ -6706,7 +6713,7 @@ fn analyzeNamespaceLookup(
6706 src: LazySrcLoc,6713 src: LazySrcLoc,
6707 namespace: *Scope.Namespace,6714 namespace: *Scope.Namespace,
6708 decl_name: []const u8,6715 decl_name: []const u8,
6709) InnerError!?Air.Inst.Ref {6716) CompileError!?Air.Inst.Ref {
6710 const mod = sema.mod;6717 const mod = sema.mod;
6711 const gpa = sema.gpa;6718 const gpa = sema.gpa;
6712 if (try sema.lookupInNamespace(namespace, decl_name)) |decl| {6719 if (try sema.lookupInNamespace(namespace, decl_name)) |decl| {
...@@ -6734,7 +6741,7 @@ fn analyzeStructFieldPtr(...@@ -6734,7 +6741,7 @@ fn analyzeStructFieldPtr(
6734 field_name: []const u8,6741 field_name: []const u8,
6735 field_name_src: LazySrcLoc,6742 field_name_src: LazySrcLoc,
6736 unresolved_struct_ty: Type,6743 unresolved_struct_ty: Type,
6737) InnerError!Air.Inst.Ref {6744) CompileError!Air.Inst.Ref {
6738 const mod = sema.mod;6745 const mod = sema.mod;
6739 const arena = sema.arena;6746 const arena = sema.arena;
6740 assert(unresolved_struct_ty.zigTypeTag() == .Struct);6747 assert(unresolved_struct_ty.zigTypeTag() == .Struct);
...@@ -6769,7 +6776,7 @@ fn analyzeUnionFieldPtr(...@@ -6769,7 +6776,7 @@ fn analyzeUnionFieldPtr(
6769 field_name: []const u8,6776 field_name: []const u8,
6770 field_name_src: LazySrcLoc,6777 field_name_src: LazySrcLoc,
6771 unresolved_union_ty: Type,6778 unresolved_union_ty: Type,
6772) InnerError!Air.Inst.Ref {6779) CompileError!Air.Inst.Ref {
6773 const mod = sema.mod;6780 const mod = sema.mod;
6774 const arena = sema.arena;6781 const arena = sema.arena;
6775 assert(unresolved_union_ty.zigTypeTag() == .Union);6782 assert(unresolved_union_ty.zigTypeTag() == .Union);
...@@ -6805,7 +6812,7 @@ fn elemPtr(...@@ -6805,7 +6812,7 @@ fn elemPtr(
6805 array_ptr: Air.Inst.Ref,6812 array_ptr: Air.Inst.Ref,
6806 elem_index: Air.Inst.Ref,6813 elem_index: Air.Inst.Ref,
6807 elem_index_src: LazySrcLoc,6814 elem_index_src: LazySrcLoc,
6808) InnerError!Air.Inst.Ref {6815) CompileError!Air.Inst.Ref {
6809 const array_ty = switch (array_ptr.ty.zigTypeTag()) {6816 const array_ty = switch (array_ptr.ty.zigTypeTag()) {
6810 .Pointer => array_ptr.ty.elemType(),6817 .Pointer => array_ptr.ty.elemType(),
6811 else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}),6818 else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}),
...@@ -6832,7 +6839,7 @@ fn elemPtrArray(...@@ -6832,7 +6839,7 @@ fn elemPtrArray(
6832 array_ptr: Air.Inst.Ref,6839 array_ptr: Air.Inst.Ref,
6833 elem_index: Air.Inst.Ref,6840 elem_index: Air.Inst.Ref,
6834 elem_index_src: LazySrcLoc,6841 elem_index_src: LazySrcLoc,
6835) InnerError!Air.Inst.Ref {6842) CompileError!Air.Inst.Ref {
6836 if (array_ptr.value()) |array_ptr_val| {6843 if (array_ptr.value()) |array_ptr_val| {
6837 if (elem_index.value()) |index_val| {6844 if (elem_index.value()) |index_val| {
6838 // Both array pointer and index are compile-time known.6845 // Both array pointer and index are compile-time known.
...@@ -6859,7 +6866,7 @@ fn coerce(...@@ -6859,7 +6866,7 @@ fn coerce(
6859 dest_type: Type,6866 dest_type: Type,
6860 inst: Air.Inst.Ref,6867 inst: Air.Inst.Ref,
6861 inst_src: LazySrcLoc,6868 inst_src: LazySrcLoc,
6862) InnerError!Air.Inst.Ref {6869) CompileError!Air.Inst.Ref {
6863 if (dest_type.tag() == .var_args_param) {6870 if (dest_type.tag() == .var_args_param) {
6864 return sema.coerceVarArgParam(block, inst, inst_src);6871 return sema.coerceVarArgParam(block, inst, inst_src);
6865 }6872 }
...@@ -7041,7 +7048,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult...@@ -7041,7 +7048,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult
7041 return .no_match;7048 return .no_match;
7042}7049}
70437050
7044fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!?Air.Inst.Index {7051fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) CompileError!?Air.Inst.Index {
7045 const val = inst.value() orelse return null;7052 const val = inst.value() orelse return null;
7046 const src_zig_tag = inst.ty.zigTypeTag();7053 const src_zig_tag = inst.ty.zigTypeTag();
7047 const dst_zig_tag = dest_type.zigTypeTag();7054 const dst_zig_tag = dest_type.zigTypeTag();
...@@ -7153,7 +7160,7 @@ fn bitcast(...@@ -7153,7 +7160,7 @@ fn bitcast(
7153 dest_type: Type,7160 dest_type: Type,
7154 inst: Air.Inst.Ref,7161 inst: Air.Inst.Ref,
7155 inst_src: LazySrcLoc,7162 inst_src: LazySrcLoc,
7156) InnerError!Air.Inst.Ref {7163) CompileError!Air.Inst.Ref {
7157 if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| {7164 if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| {
7158 // Keep the comptime Value representation; take the new type.7165 // Keep the comptime Value representation; take the new type.
7159 return sema.addConstant(dest_type, val);7166 return sema.addConstant(dest_type, val);
...@@ -7163,7 +7170,7 @@ fn bitcast(...@@ -7163,7 +7170,7 @@ fn bitcast(
7163 return block.addTyOp(.bitcast, dest_type, inst);7170 return block.addTyOp(.bitcast, dest_type, inst);
7164}7171}
71657172
7166fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!Air.Inst.Ref {7173fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) CompileError!Air.Inst.Ref {
7167 if (inst.value()) |val| {7174 if (inst.value()) |val| {
7168 // The comptime Value representation is compatible with both types.7175 // The comptime Value representation is compatible with both types.
7169 return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val });7176 return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val });
...@@ -7179,12 +7186,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst:...@@ -7179,12 +7186,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst:
7179 return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{});7186 return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{});
7180}7187}
71817188
7182fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref {7189fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) CompileError!Air.Inst.Ref {
7183 const decl_ref = try sema.analyzeDeclRef(block, src, decl);7190 const decl_ref = try sema.analyzeDeclRef(block, src, decl);
7184 return sema.analyzeLoad(block, src, decl_ref, src);7191 return sema.analyzeLoad(block, src, decl_ref, src);
7185}7192}
71867193
7187fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref {7194fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) CompileError!Air.Inst.Ref {
7188 try sema.mod.declareDeclDependency(sema.owner_decl, decl);7195 try sema.mod.declareDeclDependency(sema.owner_decl, decl);
7189 sema.mod.ensureDeclAnalyzed(decl) catch |err| {7196 sema.mod.ensureDeclAnalyzed(decl) catch |err| {
7190 if (sema.func) |func| {7197 if (sema.func) |func| {
...@@ -7205,7 +7212,7 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl...@@ -7205,7 +7212,7 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl
7205 );7212 );
7206}7213}
72077214
7208fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!Air.Inst.Ref {7215fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) CompileError!Air.Inst.Ref {
7209 const variable = tv.val.castTag(.variable).?.data;7216 const variable = tv.val.castTag(.variable).?.data;
72107217
7211 const ty = try Module.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One);7218 const ty = try Module.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One);
...@@ -7233,7 +7240,7 @@ fn analyzeRef(...@@ -7233,7 +7240,7 @@ fn analyzeRef(
7233 block: *Scope.Block,7240 block: *Scope.Block,
7234 src: LazySrcLoc,7241 src: LazySrcLoc,
7235 operand: Air.Inst.Ref,7242 operand: Air.Inst.Ref,
7236) InnerError!Air.Inst.Ref {7243) CompileError!Air.Inst.Ref {
7237 const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One);7244 const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One);
72387245
7239 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| {7246 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| {
...@@ -7253,7 +7260,7 @@ fn analyzeLoad(...@@ -7253,7 +7260,7 @@ fn analyzeLoad(
7253 src: LazySrcLoc,7260 src: LazySrcLoc,
7254 ptr: Air.Inst.Ref,7261 ptr: Air.Inst.Ref,
7255 ptr_src: LazySrcLoc,7262 ptr_src: LazySrcLoc,
7256) InnerError!Air.Inst.Ref {7263) CompileError!Air.Inst.Ref {
7257 const ptr_ty = sema.getTypeOf(ptr);7264 const ptr_ty = sema.getTypeOf(ptr);
7258 const elem_ty = switch (ptr_ty.zigTypeTag()) {7265 const elem_ty = switch (ptr_ty.zigTypeTag()) {
7259 .Pointer => ptr_ty.elemType(),7266 .Pointer => ptr_ty.elemType(),
...@@ -7276,7 +7283,7 @@ fn analyzeIsNull(...@@ -7276,7 +7283,7 @@ fn analyzeIsNull(
7276 src: LazySrcLoc,7283 src: LazySrcLoc,
7277 operand: Air.Inst.Ref,7284 operand: Air.Inst.Ref,
7278 invert_logic: bool,7285 invert_logic: bool,
7279) InnerError!Air.Inst.Ref {7286) CompileError!Air.Inst.Ref {
7280 const result_ty = Type.initTag(.bool);7287 const result_ty = Type.initTag(.bool);
7281 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| {7288 if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| {
7282 if (opt_val.isUndef()) {7289 if (opt_val.isUndef()) {
...@@ -7300,7 +7307,7 @@ fn analyzeIsNonErr(...@@ -7300,7 +7307,7 @@ fn analyzeIsNonErr(
7300 block: *Scope.Block,7307 block: *Scope.Block,
7301 src: LazySrcLoc,7308 src: LazySrcLoc,
7302 operand: Air.Inst.Ref,7309 operand: Air.Inst.Ref,
7303) InnerError!Air.Inst.Ref {7310) CompileError!Air.Inst.Ref {
7304 const ot = operand.ty.zigTypeTag();7311 const ot = operand.ty.zigTypeTag();
7305 if (ot != .ErrorSet and ot != .ErrorUnion) return Air.Inst.Ref.bool_true;7312 if (ot != .ErrorSet and ot != .ErrorUnion) return Air.Inst.Ref.bool_true;
7306 if (ot == .ErrorSet) return Air.Inst.Ref.bool_false;7313 if (ot == .ErrorSet) return Air.Inst.Ref.bool_false;
...@@ -7329,7 +7336,7 @@ fn analyzeSlice(...@@ -7329,7 +7336,7 @@ fn analyzeSlice(
7329 end_opt: ?Air.Inst.Index,7336 end_opt: ?Air.Inst.Index,
7330 sentinel_opt: ?Air.Inst.Index,7337 sentinel_opt: ?Air.Inst.Index,
7331 sentinel_src: LazySrcLoc,7338 sentinel_src: LazySrcLoc,
7332) InnerError!Air.Inst.Ref {7339) CompileError!Air.Inst.Ref {
7333 const ptr_child = switch (array_ptr.ty.zigTypeTag()) {7340 const ptr_child = switch (array_ptr.ty.zigTypeTag()) {
7334 .Pointer => array_ptr.ty.elemType(),7341 .Pointer => array_ptr.ty.elemType(),
7335 else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}),7342 else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}),
...@@ -7405,7 +7412,7 @@ fn cmpNumeric(...@@ -7405,7 +7412,7 @@ fn cmpNumeric(
7405 op: std.math.CompareOperator,7412 op: std.math.CompareOperator,
7406 lhs_src: LazySrcLoc,7413 lhs_src: LazySrcLoc,
7407 rhs_src: LazySrcLoc,7414 rhs_src: LazySrcLoc,
7408) InnerError!Air.Inst.Ref {7415) CompileError!Air.Inst.Ref {
7409 const lhs_ty = sema.getTypeOf(lhs);7416 const lhs_ty = sema.getTypeOf(lhs);
7410 const rhs_ty = sema.getTypeOf(rhs);7417 const rhs_ty = sema.getTypeOf(rhs);
74117418
...@@ -7746,7 +7753,7 @@ fn resolvePeerTypes(...@@ -7746,7 +7753,7 @@ fn resolvePeerTypes(
7746 return chosen.ty;7753 return chosen.ty;
7747}7754}
77487755
7749fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) InnerError!Type {7756fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type) CompileError!Type {
7750 switch (ty.tag()) {7757 switch (ty.tag()) {
7751 .@"struct" => {7758 .@"struct" => {
7752 const struct_obj = ty.castTag(.@"struct").?.data;7759 const struct_obj = ty.castTag(.@"struct").?.data;
...@@ -7798,7 +7805,7 @@ fn resolveBuiltinTypeFields(...@@ -7798,7 +7805,7 @@ fn resolveBuiltinTypeFields(
7798 block: *Scope.Block,7805 block: *Scope.Block,
7799 src: LazySrcLoc,7806 src: LazySrcLoc,
7800 name: []const u8,7807 name: []const u8,
7801) InnerError!Type {7808) CompileError!Type {
7802 const resolved_ty = try sema.getBuiltinType(block, src, name);7809 const resolved_ty = try sema.getBuiltinType(block, src, name);
7803 return sema.resolveTypeFields(block, src, resolved_ty);7810 return sema.resolveTypeFields(block, src, resolved_ty);
7804}7811}
...@@ -7808,7 +7815,7 @@ fn getBuiltin(...@@ -7808,7 +7815,7 @@ fn getBuiltin(
7808 block: *Scope.Block,7815 block: *Scope.Block,
7809 src: LazySrcLoc,7816 src: LazySrcLoc,
7810 name: []const u8,7817 name: []const u8,
7811) InnerError!Air.Inst.Ref {7818) CompileError!Air.Inst.Ref {
7812 const mod = sema.mod;7819 const mod = sema.mod;
7813 const std_pkg = mod.root_pkg.table.get("std").?;7820 const std_pkg = mod.root_pkg.table.get("std").?;
7814 const std_file = (mod.importPkg(std_pkg) catch unreachable).file;7821 const std_file = (mod.importPkg(std_pkg) catch unreachable).file;
...@@ -7834,7 +7841,7 @@ fn getBuiltinType(...@@ -7834,7 +7841,7 @@ fn getBuiltinType(
7834 block: *Scope.Block,7841 block: *Scope.Block,
7835 src: LazySrcLoc,7842 src: LazySrcLoc,
7836 name: []const u8,7843 name: []const u8,
7837) InnerError!Type {7844) CompileError!Type {
7838 const ty_inst = try sema.getBuiltin(block, src, name);7845 const ty_inst = try sema.getBuiltin(block, src, name);
7839 return sema.resolveAirAsType(block, src, ty_inst);7846 return sema.resolveAirAsType(block, src, ty_inst);
7840}7847}
...@@ -7848,7 +7855,7 @@ fn typeHasOnePossibleValue(...@@ -7848,7 +7855,7 @@ fn typeHasOnePossibleValue(
7848 block: *Scope.Block,7855 block: *Scope.Block,
7849 src: LazySrcLoc,7856 src: LazySrcLoc,
7850 starting_type: Type,7857 starting_type: Type,
7851) InnerError!?Value {7858) CompileError!?Value {
7852 var ty = starting_type;7859 var ty = starting_type;
7853 while (true) switch (ty.tag()) {7860 while (true) switch (ty.tag()) {
7854 .f16,7861 .f16,
...@@ -7986,7 +7993,7 @@ fn typeHasOnePossibleValue(...@@ -7986,7 +7993,7 @@ fn typeHasOnePossibleValue(
7986 };7993 };
7987}7994}
79887995
7989fn getAstTree(sema: *Sema, block: *Scope.Block) InnerError!*const std.zig.ast.Tree {7996fn getAstTree(sema: *Sema, block: *Scope.Block) CompileError!*const std.zig.ast.Tree {
7990 return block.src_decl.namespace.file_scope.getTree(sema.gpa) catch |err| {7997 return block.src_decl.namespace.file_scope.getTree(sema.gpa) catch |err| {
7991 log.err("unable to load AST to report compile error: {s}", .{@errorName(err)});7998 log.err("unable to load AST to report compile error: {s}", .{@errorName(err)});
7992 return error.AnalysisFail;7999 return error.AnalysisFail;
...@@ -8166,15 +8173,15 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {...@@ -8166,15 +8173,15 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref {
8166 return indexToRef(@intCast(u32, sema.air_instructions.len - 1));8173 return indexToRef(@intCast(u32, sema.air_instructions.len - 1));
8167}8174}
81688175
8169fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) InnerError!Air.Inst.Ref {8176fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref {
8170 return sema.addConstant(ty, try Value.Tag.int_u64.create(sema.arena, int));8177 return sema.addConstant(ty, try Value.Tag.int_u64.create(sema.arena, int));
8171}8178}
81728179
8173fn addConstUndef(sema: *Sema, ty: Type) InnerError!Air.Inst.Ref {8180fn addConstUndef(sema: *Sema, ty: Type) CompileError!Air.Inst.Ref {
8174 return sema.addConstant(ty, Value.initTag(.undef));8181 return sema.addConstant(ty, Value.initTag(.undef));
8175}8182}
81768183
8177fn addConstant(sema: *Sema, ty: Type, val: Value) InnerError!Air.Inst.Ref {8184fn addConstant(sema: *Sema, ty: Type, val: Value) CompileError!Air.Inst.Ref {
8178 const gpa = sema.gpa;8185 const gpa = sema.gpa;
8179 const ty_inst = try sema.addType(ty);8186 const ty_inst = try sema.addType(ty);
8180 try sema.air_values.append(gpa, val);8187 try sema.air_values.append(gpa, val);