authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-13 12:34:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-15 19:06:39-07:00
log0170a242bb99e96fcb127e26e1b2fcbe5a19c4ee
treeab5dd10064527ff8fcd7d3f676466de9c30d1c2b
parent798ad631f3f9836de663bc6c728b415e0a13528f

stage2: move zir.Code to become root level fields of zir.zig

next commit will do the rename

4 files changed, 431 insertions(+), 432 deletions(-)

src/AstGen.zig+3-3
......@@ -1,7 +1,7 @@
1//! A Work-In-Progress `zir.Code`. This is a shared parent of all
2//! `GenZir` scopes. Once the `zir.Code` is produced, this struct
1//! A Work-In-Progress `Zir`. This is a shared parent of all
2//! `GenZir` scopes. Once the `Zir` is produced, this struct
33//! is deinitialized.
4//! The `GenZir.finish` function converts this to a `zir.Code`.
4//! The `GenZir.finish` function converts this to a `Zir`.
55
66const AstGen = @This();
77
src/Module.zig+103-103
......@@ -21,7 +21,7 @@ const TypedValue = @import("TypedValue.zig");
2121const Package = @import("Package.zig");
2222const link = @import("link.zig");
2323const ir = @import("ir.zig");
24const zir = @import("zir.zig");
24const Zir = @import("zir.zig"); // TODO rename this to Zir
2525const trace = @import("tracy.zig").trace;
2626const AstGen = @import("AstGen.zig");
2727const Sema = @import("Sema.zig");
......@@ -464,7 +464,7 @@ pub const Fn = struct {
464464 /// The first N elements of `extra` are indexes into `string_bytes` to
465465 /// a null-terminated string.
466466 /// This memory is managed with gpa, must be freed when the function is freed.
467 zir: zir.Code,
467 zir: Zir,
468468 /// undefined unless analysis state is `success`.
469469 body: ir.Body,
470470 state: Analysis,
......@@ -808,7 +808,7 @@ pub const Scope = struct {
808808 /// This `Block` maps a block ZIR instruction to the corresponding
809809 /// TZIR instruction for break instruction analysis.
810810 pub const Label = struct {
811 zir_block: zir.Inst.Index,
811 zir_block: Zir.Inst.Index,
812812 merges: Merges,
813813 };
814814
......@@ -834,7 +834,7 @@ pub const Scope = struct {
834834
835835 /// For debugging purposes.
836836 pub fn dump(block: *Block, mod: Module) void {
837 zir.dumpBlock(mod, block);
837 Zir.dumpBlock(mod, block);
838838 }
839839
840840 pub fn makeSubBlock(parent: *Block) Block {
......@@ -1045,7 +1045,7 @@ pub const Scope = struct {
10451045 };
10461046
10471047 /// This is a temporary structure; references to it are valid only
1048 /// while constructing a `zir.Code`.
1048 /// while constructing a `Zir`.
10491049 pub const GenZir = struct {
10501050 pub const base_tag: Tag = .gen_zir;
10511051 base: Scope = Scope{ .tag = base_tag },
......@@ -1056,16 +1056,16 @@ pub const Scope = struct {
10561056 astgen: *AstGen,
10571057 /// Keeps track of the list of instructions in this scope only. Indexes
10581058 /// to instructions in `astgen`.
1059 instructions: ArrayListUnmanaged(zir.Inst.Index) = .{},
1059 instructions: ArrayListUnmanaged(Zir.Inst.Index) = .{},
10601060 label: ?Label = null,
1061 break_block: zir.Inst.Index = 0,
1062 continue_block: zir.Inst.Index = 0,
1061 break_block: Zir.Inst.Index = 0,
1062 continue_block: Zir.Inst.Index = 0,
10631063 /// Only valid when setBreakResultLoc is called.
10641064 break_result_loc: AstGen.ResultLoc = undefined,
10651065 /// When a block has a pointer result location, here it is.
1066 rl_ptr: zir.Inst.Ref = .none,
1066 rl_ptr: Zir.Inst.Ref = .none,
10671067 /// When a block has a type result location, here it is.
1068 rl_ty_inst: zir.Inst.Ref = .none,
1068 rl_ty_inst: Zir.Inst.Ref = .none,
10691069 /// Keeps track of how many branches of a block did not actually
10701070 /// consume the result location. astgen uses this to figure out
10711071 /// whether to rely on break instructions or writing to the result
......@@ -1077,25 +1077,25 @@ pub const Scope = struct {
10771077 break_count: usize = 0,
10781078 /// Tracks `break :foo bar` instructions so they can possibly be elided later if
10791079 /// the labeled block ends up not needing a result location pointer.
1080 labeled_breaks: ArrayListUnmanaged(zir.Inst.Index) = .{},
1080 labeled_breaks: ArrayListUnmanaged(Zir.Inst.Index) = .{},
10811081 /// Tracks `store_to_block_ptr` instructions that correspond to break instructions
10821082 /// so they can possibly be elided later if the labeled block ends up not needing
10831083 /// a result location pointer.
1084 labeled_store_to_block_ptr_list: ArrayListUnmanaged(zir.Inst.Index) = .{},
1084 labeled_store_to_block_ptr_list: ArrayListUnmanaged(Zir.Inst.Index) = .{},
10851085
10861086 pub const Label = struct {
10871087 token: ast.TokenIndex,
1088 block_inst: zir.Inst.Index,
1088 block_inst: Zir.Inst.Index,
10891089 used: bool = false,
10901090 };
10911091
10921092 /// Only valid to call on the top of the `GenZir` stack. Completes the
1093 /// `AstGen` into a `zir.Code`. Leaves the `AstGen` in an
1093 /// `AstGen` into a `Zir`. Leaves the `AstGen` in an
10941094 /// initialized, but empty, state.
1095 pub fn finish(gz: *GenZir) !zir.Code {
1095 pub fn finish(gz: *GenZir) !Zir {
10961096 const gpa = gz.astgen.mod.gpa;
10971097 try gz.setBlockBody(0);
1098 return zir.Code{
1098 return Zir{
10991099 .instructions = gz.astgen.instructions.toOwnedSlice(),
11001100 .string_bytes = gz.astgen.string_bytes.toOwnedSlice(gpa),
11011101 .extra = gz.astgen.extra.toOwnedSlice(gpa),
......@@ -1148,24 +1148,24 @@ pub const Scope = struct {
11481148 }
11491149 }
11501150
1151 pub fn setBoolBrBody(gz: GenZir, inst: zir.Inst.Index) !void {
1151 pub fn setBoolBrBody(gz: GenZir, inst: Zir.Inst.Index) !void {
11521152 const gpa = gz.astgen.mod.gpa;
11531153 try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len +
1154 @typeInfo(zir.Inst.Block).Struct.fields.len + gz.instructions.items.len);
1154 @typeInfo(Zir.Inst.Block).Struct.fields.len + gz.instructions.items.len);
11551155 const zir_datas = gz.astgen.instructions.items(.data);
11561156 zir_datas[inst].bool_br.payload_index = gz.astgen.addExtraAssumeCapacity(
1157 zir.Inst.Block{ .body_len = @intCast(u32, gz.instructions.items.len) },
1157 Zir.Inst.Block{ .body_len = @intCast(u32, gz.instructions.items.len) },
11581158 );
11591159 gz.astgen.extra.appendSliceAssumeCapacity(gz.instructions.items);
11601160 }
11611161
1162 pub fn setBlockBody(gz: GenZir, inst: zir.Inst.Index) !void {
1162 pub fn setBlockBody(gz: GenZir, inst: Zir.Inst.Index) !void {
11631163 const gpa = gz.astgen.mod.gpa;
11641164 try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len +
1165 @typeInfo(zir.Inst.Block).Struct.fields.len + gz.instructions.items.len);
1165 @typeInfo(Zir.Inst.Block).Struct.fields.len + gz.instructions.items.len);
11661166 const zir_datas = gz.astgen.instructions.items(.data);
11671167 zir_datas[inst].pl_node.payload_index = gz.astgen.addExtraAssumeCapacity(
1168 zir.Inst.Block{ .body_len = @intCast(u32, gz.instructions.items.len) },
1168 Zir.Inst.Block{ .body_len = @intCast(u32, gz.instructions.items.len) },
11691169 );
11701170 gz.astgen.extra.appendSliceAssumeCapacity(gz.instructions.items);
11711171 }
......@@ -1180,12 +1180,12 @@ pub const Scope = struct {
11801180 return str_index;
11811181 }
11821182
1183 pub fn addFnTypeCc(gz: *GenZir, tag: zir.Inst.Tag, args: struct {
1183 pub fn addFnTypeCc(gz: *GenZir, tag: Zir.Inst.Tag, args: struct {
11841184 src_node: ast.Node.Index,
1185 param_types: []const zir.Inst.Ref,
1186 ret_ty: zir.Inst.Ref,
1187 cc: zir.Inst.Ref,
1188 }) !zir.Inst.Ref {
1185 param_types: []const Zir.Inst.Ref,
1186 ret_ty: Zir.Inst.Ref,
1187 cc: Zir.Inst.Ref,
1188 }) !Zir.Inst.Ref {
11891189 assert(args.src_node != 0);
11901190 assert(args.ret_ty != .none);
11911191 assert(args.cc != .none);
......@@ -1193,16 +1193,16 @@ pub const Scope = struct {
11931193 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
11941194 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
11951195 try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len +
1196 @typeInfo(zir.Inst.FnTypeCc).Struct.fields.len + args.param_types.len);
1196 @typeInfo(Zir.Inst.FnTypeCc).Struct.fields.len + args.param_types.len);
11971197
1198 const payload_index = gz.astgen.addExtraAssumeCapacity(zir.Inst.FnTypeCc{
1198 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.FnTypeCc{
11991199 .return_type = args.ret_ty,
12001200 .cc = args.cc,
12011201 .param_types_len = @intCast(u32, args.param_types.len),
12021202 });
12031203 gz.astgen.appendRefsAssumeCapacity(args.param_types);
12041204
1205 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1205 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
12061206 gz.astgen.instructions.appendAssumeCapacity(.{
12071207 .tag = tag,
12081208 .data = .{ .pl_node = .{
......@@ -1214,26 +1214,26 @@ pub const Scope = struct {
12141214 return gz.astgen.indexToRef(new_index);
12151215 }
12161216
1217 pub fn addFnType(gz: *GenZir, tag: zir.Inst.Tag, args: struct {
1217 pub fn addFnType(gz: *GenZir, tag: Zir.Inst.Tag, args: struct {
12181218 src_node: ast.Node.Index,
1219 ret_ty: zir.Inst.Ref,
1220 param_types: []const zir.Inst.Ref,
1221 }) !zir.Inst.Ref {
1219 ret_ty: Zir.Inst.Ref,
1220 param_types: []const Zir.Inst.Ref,
1221 }) !Zir.Inst.Ref {
12221222 assert(args.src_node != 0);
12231223 assert(args.ret_ty != .none);
12241224 const gpa = gz.astgen.mod.gpa;
12251225 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
12261226 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
12271227 try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len +
1228 @typeInfo(zir.Inst.FnType).Struct.fields.len + args.param_types.len);
1228 @typeInfo(Zir.Inst.FnType).Struct.fields.len + args.param_types.len);
12291229
1230 const payload_index = gz.astgen.addExtraAssumeCapacity(zir.Inst.FnType{
1230 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.FnType{
12311231 .return_type = args.ret_ty,
12321232 .param_types_len = @intCast(u32, args.param_types.len),
12331233 });
12341234 gz.astgen.appendRefsAssumeCapacity(args.param_types);
12351235
1236 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1236 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
12371237 gz.astgen.instructions.appendAssumeCapacity(.{
12381238 .tag = tag,
12391239 .data = .{ .pl_node = .{
......@@ -1247,27 +1247,27 @@ pub const Scope = struct {
12471247
12481248 pub fn addCall(
12491249 gz: *GenZir,
1250 tag: zir.Inst.Tag,
1251 callee: zir.Inst.Ref,
1252 args: []const zir.Inst.Ref,
1250 tag: Zir.Inst.Tag,
1251 callee: Zir.Inst.Ref,
1252 args: []const Zir.Inst.Ref,
12531253 /// Absolute node index. This function does the conversion to offset from Decl.
12541254 src_node: ast.Node.Index,
1255 ) !zir.Inst.Ref {
1255 ) !Zir.Inst.Ref {
12561256 assert(callee != .none);
12571257 assert(src_node != 0);
12581258 const gpa = gz.astgen.mod.gpa;
12591259 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
12601260 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
12611261 try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len +
1262 @typeInfo(zir.Inst.Call).Struct.fields.len + args.len);
1262 @typeInfo(Zir.Inst.Call).Struct.fields.len + args.len);
12631263
1264 const payload_index = gz.astgen.addExtraAssumeCapacity(zir.Inst.Call{
1264 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Call{
12651265 .callee = callee,
12661266 .args_len = @intCast(u32, args.len),
12671267 });
12681268 gz.astgen.appendRefsAssumeCapacity(args);
12691269
1270 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1270 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
12711271 gz.astgen.instructions.appendAssumeCapacity(.{
12721272 .tag = tag,
12731273 .data = .{ .pl_node = .{
......@@ -1279,19 +1279,19 @@ pub const Scope = struct {
12791279 return gz.astgen.indexToRef(new_index);
12801280 }
12811281
1282 /// Note that this returns a `zir.Inst.Index` not a ref.
1282 /// Note that this returns a `Zir.Inst.Index` not a ref.
12831283 /// Leaves the `payload_index` field undefined.
12841284 pub fn addBoolBr(
12851285 gz: *GenZir,
1286 tag: zir.Inst.Tag,
1287 lhs: zir.Inst.Ref,
1288 ) !zir.Inst.Index {
1286 tag: Zir.Inst.Tag,
1287 lhs: Zir.Inst.Ref,
1288 ) !Zir.Inst.Index {
12891289 assert(lhs != .none);
12901290 const gpa = gz.astgen.mod.gpa;
12911291 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
12921292 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
12931293
1294 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1294 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
12951295 gz.astgen.instructions.appendAssumeCapacity(.{
12961296 .tag = tag,
12971297 .data = .{ .bool_br = .{
......@@ -1303,14 +1303,14 @@ pub const Scope = struct {
13031303 return new_index;
13041304 }
13051305
1306 pub fn addInt(gz: *GenZir, integer: u64) !zir.Inst.Ref {
1306 pub fn addInt(gz: *GenZir, integer: u64) !Zir.Inst.Ref {
13071307 return gz.add(.{
13081308 .tag = .int,
13091309 .data = .{ .int = integer },
13101310 });
13111311 }
13121312
1313 pub fn addFloat(gz: *GenZir, number: f32, src_node: ast.Node.Index) !zir.Inst.Ref {
1313 pub fn addFloat(gz: *GenZir, number: f32, src_node: ast.Node.Index) !Zir.Inst.Ref {
13141314 return gz.add(.{
13151315 .tag = .float,
13161316 .data = .{ .float = .{
......@@ -1322,11 +1322,11 @@ pub const Scope = struct {
13221322
13231323 pub fn addUnNode(
13241324 gz: *GenZir,
1325 tag: zir.Inst.Tag,
1326 operand: zir.Inst.Ref,
1325 tag: Zir.Inst.Tag,
1326 operand: Zir.Inst.Ref,
13271327 /// Absolute node index. This function does the conversion to offset from Decl.
13281328 src_node: ast.Node.Index,
1329 ) !zir.Inst.Ref {
1329 ) !Zir.Inst.Ref {
13301330 assert(operand != .none);
13311331 return gz.add(.{
13321332 .tag = tag,
......@@ -1339,17 +1339,17 @@ pub const Scope = struct {
13391339
13401340 pub fn addPlNode(
13411341 gz: *GenZir,
1342 tag: zir.Inst.Tag,
1342 tag: Zir.Inst.Tag,
13431343 /// Absolute node index. This function does the conversion to offset from Decl.
13441344 src_node: ast.Node.Index,
13451345 extra: anytype,
1346 ) !zir.Inst.Ref {
1346 ) !Zir.Inst.Ref {
13471347 const gpa = gz.astgen.mod.gpa;
13481348 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
13491349 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
13501350
13511351 const payload_index = try gz.astgen.addExtra(extra);
1352 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1352 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
13531353 gz.astgen.instructions.appendAssumeCapacity(.{
13541354 .tag = tag,
13551355 .data = .{ .pl_node = .{
......@@ -1363,19 +1363,19 @@ pub const Scope = struct {
13631363
13641364 pub fn addArrayTypeSentinel(
13651365 gz: *GenZir,
1366 len: zir.Inst.Ref,
1367 sentinel: zir.Inst.Ref,
1368 elem_type: zir.Inst.Ref,
1369 ) !zir.Inst.Ref {
1366 len: Zir.Inst.Ref,
1367 sentinel: Zir.Inst.Ref,
1368 elem_type: Zir.Inst.Ref,
1369 ) !Zir.Inst.Ref {
13701370 const gpa = gz.astgen.mod.gpa;
13711371 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
13721372 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
13731373
1374 const payload_index = try gz.astgen.addExtra(zir.Inst.ArrayTypeSentinel{
1374 const payload_index = try gz.astgen.addExtra(Zir.Inst.ArrayTypeSentinel{
13751375 .sentinel = sentinel,
13761376 .elem_type = elem_type,
13771377 });
1378 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1378 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
13791379 gz.astgen.instructions.appendAssumeCapacity(.{
13801380 .tag = .array_type_sentinel,
13811381 .data = .{ .array_type_sentinel = .{
......@@ -1389,11 +1389,11 @@ pub const Scope = struct {
13891389
13901390 pub fn addUnTok(
13911391 gz: *GenZir,
1392 tag: zir.Inst.Tag,
1393 operand: zir.Inst.Ref,
1392 tag: Zir.Inst.Tag,
1393 operand: Zir.Inst.Ref,
13941394 /// Absolute token index. This function does the conversion to Decl offset.
13951395 abs_tok_index: ast.TokenIndex,
1396 ) !zir.Inst.Ref {
1396 ) !Zir.Inst.Ref {
13971397 assert(operand != .none);
13981398 return gz.add(.{
13991399 .tag = tag,
......@@ -1406,11 +1406,11 @@ pub const Scope = struct {
14061406
14071407 pub fn addStrTok(
14081408 gz: *GenZir,
1409 tag: zir.Inst.Tag,
1409 tag: Zir.Inst.Tag,
14101410 str_index: u32,
14111411 /// Absolute token index. This function does the conversion to Decl offset.
14121412 abs_tok_index: ast.TokenIndex,
1413 ) !zir.Inst.Ref {
1413 ) !Zir.Inst.Ref {
14141414 return gz.add(.{
14151415 .tag = tag,
14161416 .data = .{ .str_tok = .{
......@@ -1422,10 +1422,10 @@ pub const Scope = struct {
14221422
14231423 pub fn addBreak(
14241424 gz: *GenZir,
1425 tag: zir.Inst.Tag,
1426 break_block: zir.Inst.Index,
1427 operand: zir.Inst.Ref,
1428 ) !zir.Inst.Index {
1425 tag: Zir.Inst.Tag,
1426 break_block: Zir.Inst.Index,
1427 operand: Zir.Inst.Ref,
1428 ) !Zir.Inst.Index {
14291429 return gz.addAsIndex(.{
14301430 .tag = tag,
14311431 .data = .{ .@"break" = .{
......@@ -1437,10 +1437,10 @@ pub const Scope = struct {
14371437
14381438 pub fn addBin(
14391439 gz: *GenZir,
1440 tag: zir.Inst.Tag,
1441 lhs: zir.Inst.Ref,
1442 rhs: zir.Inst.Ref,
1443 ) !zir.Inst.Ref {
1440 tag: Zir.Inst.Tag,
1441 lhs: Zir.Inst.Ref,
1442 rhs: Zir.Inst.Ref,
1443 ) !Zir.Inst.Ref {
14441444 assert(lhs != .none);
14451445 assert(rhs != .none);
14461446 return gz.add(.{
......@@ -1454,10 +1454,10 @@ pub const Scope = struct {
14541454
14551455 pub fn addDecl(
14561456 gz: *GenZir,
1457 tag: zir.Inst.Tag,
1457 tag: Zir.Inst.Tag,
14581458 decl_index: u32,
14591459 src_node: ast.Node.Index,
1460 ) !zir.Inst.Ref {
1460 ) !Zir.Inst.Ref {
14611461 return gz.add(.{
14621462 .tag = tag,
14631463 .data = .{ .pl_node = .{
......@@ -1469,10 +1469,10 @@ pub const Scope = struct {
14691469
14701470 pub fn addNode(
14711471 gz: *GenZir,
1472 tag: zir.Inst.Tag,
1472 tag: Zir.Inst.Tag,
14731473 /// Absolute node index. This function does the conversion to offset from Decl.
14741474 src_node: ast.Node.Index,
1475 ) !zir.Inst.Ref {
1475 ) !Zir.Inst.Ref {
14761476 return gz.add(.{
14771477 .tag = tag,
14781478 .data = .{ .node = gz.astgen.decl.nodeIndexToRelative(src_node) },
......@@ -1482,9 +1482,9 @@ pub const Scope = struct {
14821482 /// Asserts that `str` is 8 or fewer bytes.
14831483 pub fn addSmallStr(
14841484 gz: *GenZir,
1485 tag: zir.Inst.Tag,
1485 tag: Zir.Inst.Tag,
14861486 str: []const u8,
1487 ) !zir.Inst.Ref {
1487 ) !Zir.Inst.Ref {
14881488 var buf: [9]u8 = undefined;
14891489 mem.copy(u8, &buf, str);
14901490 buf[str.len] = 0;
......@@ -1495,11 +1495,11 @@ pub const Scope = struct {
14951495 });
14961496 }
14971497
1498 /// Note that this returns a `zir.Inst.Index` not a ref.
1498 /// Note that this returns a `Zir.Inst.Index` not a ref.
14991499 /// Does *not* append the block instruction to the scope.
15001500 /// Leaves the `payload_index` field undefined.
1501 pub fn addBlock(gz: *GenZir, tag: zir.Inst.Tag, node: ast.Node.Index) !zir.Inst.Index {
1502 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1501 pub fn addBlock(gz: *GenZir, tag: Zir.Inst.Tag, node: ast.Node.Index) !Zir.Inst.Index {
1502 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
15031503 const gpa = gz.astgen.mod.gpa;
15041504 try gz.astgen.instructions.append(gpa, .{
15051505 .tag = tag,
......@@ -1511,12 +1511,12 @@ pub const Scope = struct {
15111511 return new_index;
15121512 }
15131513
1514 /// Note that this returns a `zir.Inst.Index` not a ref.
1514 /// Note that this returns a `Zir.Inst.Index` not a ref.
15151515 /// Leaves the `payload_index` field undefined.
1516 pub fn addCondBr(gz: *GenZir, tag: zir.Inst.Tag, node: ast.Node.Index) !zir.Inst.Index {
1516 pub fn addCondBr(gz: *GenZir, tag: Zir.Inst.Tag, node: ast.Node.Index) !Zir.Inst.Index {
15171517 const gpa = gz.astgen.mod.gpa;
15181518 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
1519 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1519 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
15201520 try gz.astgen.instructions.append(gpa, .{
15211521 .tag = tag,
15221522 .data = .{ .pl_node = .{
......@@ -1528,16 +1528,16 @@ pub const Scope = struct {
15281528 return new_index;
15291529 }
15301530
1531 pub fn add(gz: *GenZir, inst: zir.Inst) !zir.Inst.Ref {
1531 pub fn add(gz: *GenZir, inst: Zir.Inst) !Zir.Inst.Ref {
15321532 return gz.astgen.indexToRef(try gz.addAsIndex(inst));
15331533 }
15341534
1535 pub fn addAsIndex(gz: *GenZir, inst: zir.Inst) !zir.Inst.Index {
1535 pub fn addAsIndex(gz: *GenZir, inst: Zir.Inst) !Zir.Inst.Index {
15361536 const gpa = gz.astgen.mod.gpa;
15371537 try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1);
15381538 try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1);
15391539
1540 const new_index = @intCast(zir.Inst.Index, gz.astgen.instructions.len);
1540 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
15411541 gz.astgen.instructions.appendAssumeCapacity(inst);
15421542 gz.instructions.appendAssumeCapacity(new_index);
15431543 return new_index;
......@@ -1554,7 +1554,7 @@ pub const Scope = struct {
15541554 parent: *Scope,
15551555 gen_zir: *GenZir,
15561556 name: []const u8,
1557 inst: zir.Inst.Ref,
1557 inst: Zir.Inst.Ref,
15581558 /// Source location of the corresponding variable declaration.
15591559 src: LazySrcLoc,
15601560 };
......@@ -1569,7 +1569,7 @@ pub const Scope = struct {
15691569 parent: *Scope,
15701570 gen_zir: *GenZir,
15711571 name: []const u8,
1572 ptr: zir.Inst.Ref,
1572 ptr: Zir.Inst.Ref,
15731573 /// Source location of the corresponding variable declaration.
15741574 src: LazySrcLoc,
15751575 };
......@@ -2511,7 +2511,7 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool {
25112511 var analysis_arena = std.heap.ArenaAllocator.init(mod.gpa);
25122512 defer analysis_arena.deinit();
25132513
2514 var code: zir.Code = blk: {
2514 var code: Zir = blk: {
25152515 var astgen = try AstGen.init(mod, decl, &analysis_arena.allocator);
25162516 defer astgen.deinit();
25172517
......@@ -2578,7 +2578,7 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool {
25782578 var analysis_arena = std.heap.ArenaAllocator.init(mod.gpa);
25792579 defer analysis_arena.deinit();
25802580
2581 var code: zir.Code = blk: {
2581 var code: Zir = blk: {
25822582 var astgen = try AstGen.init(mod, decl, &analysis_arena.allocator);
25832583 defer astgen.deinit();
25842584
......@@ -2676,7 +2676,7 @@ fn astgenAndSemaFn(
26762676 }
26772677 break :blk count;
26782678 };
2679 const param_types = try fn_type_scope_arena.allocator.alloc(zir.Inst.Ref, param_count);
2679 const param_types = try fn_type_scope_arena.allocator.alloc(Zir.Inst.Ref, param_count);
26802680
26812681 var is_var_args = false;
26822682 {
......@@ -2782,7 +2782,7 @@ fn astgenAndSemaFn(
27822782 else
27832783 false;
27842784
2785 const cc: zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0)
2785 const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0)
27862786 // TODO instead of enum literal type, this needs to be the
27872787 // std.builtin.CallingConvention enum. We need to implement importing other files
27882788 // and enums in order to fix this.
......@@ -2797,8 +2797,8 @@ fn astgenAndSemaFn(
27972797 else
27982798 .none;
27992799
2800 const fn_type_inst: zir.Inst.Ref = if (cc != .none) fn_type: {
2801 const tag: zir.Inst.Tag = if (is_var_args) .fn_type_cc_var_args else .fn_type_cc;
2800 const fn_type_inst: Zir.Inst.Ref = if (cc != .none) fn_type: {
2801 const tag: Zir.Inst.Tag = if (is_var_args) .fn_type_cc_var_args else .fn_type_cc;
28022802 break :fn_type try fn_type_scope.addFnTypeCc(tag, .{
28032803 .src_node = fn_proto.ast.proto_node,
28042804 .ret_ty = return_type_inst,
......@@ -2806,7 +2806,7 @@ fn astgenAndSemaFn(
28062806 .cc = cc,
28072807 });
28082808 } else fn_type: {
2809 const tag: zir.Inst.Tag = if (is_var_args) .fn_type_var_args else .fn_type;
2809 const tag: Zir.Inst.Tag = if (is_var_args) .fn_type_var_args else .fn_type;
28102810 break :fn_type try fn_type_scope.addFnType(tag, .{
28112811 .src_node = fn_proto.ast.proto_node,
28122812 .ret_ty = return_type_inst,
......@@ -2890,10 +2890,10 @@ fn astgenAndSemaFn(
28902890 const new_func = try decl_arena.allocator.create(Fn);
28912891 const fn_payload = try decl_arena.allocator.create(Value.Payload.Function);
28922892
2893 const fn_zir: zir.Code = blk: {
2893 const fn_zir: Zir = blk: {
28942894 // We put the ZIR inside the Decl arena.
28952895 var astgen = try AstGen.init(mod, decl, &decl_arena.allocator);
2896 astgen.ref_start_index = @intCast(u32, zir.Inst.Ref.typed_value_map.len + param_count);
2896 astgen.ref_start_index = @intCast(u32, Zir.Inst.Ref.typed_value_map.len + param_count);
28972897 defer astgen.deinit();
28982898
28992899 var gen_scope: Scope.GenZir = .{
......@@ -2920,7 +2920,7 @@ fn astgenAndSemaFn(
29202920 .gen_zir = &gen_scope,
29212921 .name = param_name,
29222922 // Implicit const list first, then implicit arg list.
2923 .inst = @intToEnum(zir.Inst.Ref, @intCast(u32, zir.Inst.Ref.typed_value_map.len + i)),
2923 .inst = @intToEnum(Zir.Inst.Ref, @intCast(u32, Zir.Inst.Ref.typed_value_map.len + i)),
29242924 .src = decl.tokSrcLoc(name_token),
29252925 };
29262926 params_scope = &sub_scope.base;
src/Sema.zig+237-237
......@@ -1,6 +1,6 @@
11//! Semantic analysis of ZIR instructions.
22//! Shared to every Block. Stored on the stack.
3//! State used for compiling a `zir.Code` into TZIR.
3//! State used for compiling a `Zir` into TZIR.
44//! Transforms untyped ZIR instructions into semantically-analyzed TZIR instructions.
55//! Does type checking, comptime control flow, and safety-check generation.
66//! This is the the heart of the Zig compiler.
......@@ -10,7 +10,7 @@ mod: *Module,
1010gpa: *Allocator,
1111/// Points to the arena allocator of the Decl.
1212arena: *Allocator,
13code: zir.Code,
13code: Zir,
1414/// Maps ZIR to TZIR.
1515inst_map: []*Inst,
1616/// When analyzing an inline function call, owner_decl is the Decl of the caller
......@@ -52,7 +52,7 @@ const Value = @import("value.zig").Value;
5252const Type = @import("type.zig").Type;
5353const TypedValue = @import("TypedValue.zig");
5454const ir = @import("ir.zig");
55const zir = @import("zir.zig");
55const Zir = @import("zir.zig"); // TODO rename to Zir.zig
5656const Module = @import("Module.zig");
5757const Inst = ir.Inst;
5858const Body = ir.Body;
......@@ -64,14 +64,14 @@ const LazySrcLoc = Module.LazySrcLoc;
6464const RangeSet = @import("RangeSet.zig");
6565const AstGen = @import("AstGen.zig");
6666
67pub fn root(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Index {
67pub fn root(sema: *Sema, root_block: *Scope.Block) !Zir.Inst.Index {
6868 const inst_data = sema.code.instructions.items(.data)[0].pl_node;
69 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
69 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
7070 const root_body = sema.code.extra[extra.end..][0..extra.data.body_len];
7171 return sema.analyzeBody(root_block, root_body);
7272}
7373
74pub fn rootAsRef(sema: *Sema, root_block: *Scope.Block) !zir.Inst.Ref {
74pub fn rootAsRef(sema: *Sema, root_block: *Scope.Block) !Zir.Inst.Ref {
7575 const break_inst = try sema.root(root_block);
7676 return sema.code.instructions.items(.data)[break_inst].@"break".operand;
7777}
......@@ -89,7 +89,7 @@ pub fn rootAsType(sema: *Sema, root_block: *Scope.Block) !Type {
8989/// Returns only the result from the body that is specified.
9090/// Only appropriate to call when it is determined at comptime that this body
9191/// has no peers.
92fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) InnerError!*Inst {
92fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!*Inst {
9393 const break_inst = try sema.analyzeBody(block, body);
9494 const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand;
9595 return sema.resolveInst(operand_ref);
......@@ -99,22 +99,22 @@ fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const zir.Inst.Index) I
9999/// return type of `analyzeBody` so that we can tail call them.
100100/// Only appropriate to return when the instruction is known to be NoReturn
101101/// solely based on the ZIR tag.
102const always_noreturn: InnerError!zir.Inst.Index = @as(zir.Inst.Index, undefined);
102const always_noreturn: InnerError!Zir.Inst.Index = @as(Zir.Inst.Index, undefined);
103103
104104/// This function is the main loop of `Sema` and it can be used in two different ways:
105105/// * The traditional way where there are N breaks out of the block and peer type
106/// resolution is done on the break operands. In this case, the `zir.Inst.Index`
106/// resolution is done on the break operands. In this case, the `Zir.Inst.Index`
107107/// part of the return value will be `undefined`, and callsites should ignore it,
108108/// finding the block result value via the block scope.
109109/// * The "flat" way. There is only 1 break out of the block, and it is with a `break_inline`
110/// instruction. In this case, the `zir.Inst.Index` part of the return value will be
110/// instruction. In this case, the `Zir.Inst.Index` part of the return value will be
111111/// the break instruction. This communicates both which block the break applies to, as
112112/// well as the operand. No block scope needs to be created for this strategy.
113113pub fn analyzeBody(
114114 sema: *Sema,
115115 block: *Scope.Block,
116 body: []const zir.Inst.Index,
117) InnerError!zir.Inst.Index {
116 body: []const Zir.Inst.Index,
117) InnerError!Zir.Inst.Index {
118118 // No tracy calls here, to avoid interfering with the tail call mechanism.
119119
120120 const map = block.sema.inst_map;
......@@ -368,7 +368,7 @@ pub fn analyzeBody(
368368 .block_inline => blk: {
369369 // Directly analyze the block body without introducing a new block.
370370 const inst_data = datas[inst].pl_node;
371 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
371 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
372372 const inline_body = sema.code.extra[extra.end..][0..extra.data.body_len];
373373 const break_inst = try sema.analyzeBody(block, inline_body);
374374 const break_data = datas[break_inst].@"break";
......@@ -381,7 +381,7 @@ pub fn analyzeBody(
381381 .condbr_inline => blk: {
382382 const inst_data = datas[inst].pl_node;
383383 const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node };
384 const extra = sema.code.extraData(zir.Inst.CondBr, inst_data.payload_index);
384 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);
385385 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];
386386 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
387387 const cond = try sema.resolveInstConst(block, cond_src, extra.data.condition);
......@@ -401,19 +401,19 @@ pub fn analyzeBody(
401401}
402402
403403/// TODO when we rework TZIR memory layout, this function will no longer have a possible error.
404pub fn resolveInst(sema: *Sema, zir_ref: zir.Inst.Ref) error{OutOfMemory}!*ir.Inst {
404pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) error{OutOfMemory}!*ir.Inst {
405405 var i: usize = @enumToInt(zir_ref);
406406
407407 // First section of indexes correspond to a set number of constant values.
408 if (i < zir.Inst.Ref.typed_value_map.len) {
408 if (i < Zir.Inst.Ref.typed_value_map.len) {
409409 // TODO when we rework TZIR memory layout, this function can be as simple as:
410 // if (zir_ref < zir.const_inst_list.len + sema.param_count)
410 // if (zir_ref < Zir.const_inst_list.len + sema.param_count)
411411 // return zir_ref;
412412 // Until then we allocate memory for a new, mutable `ir.Inst` to match what
413413 // TZIR expects.
414 return sema.mod.constInst(sema.arena, .unneeded, zir.Inst.Ref.typed_value_map[i]);
414 return sema.mod.constInst(sema.arena, .unneeded, Zir.Inst.Ref.typed_value_map[i]);
415415 }
416 i -= zir.Inst.Ref.typed_value_map.len;
416 i -= Zir.Inst.Ref.typed_value_map.len;
417417
418418 // Next section of indexes correspond to function parameters, if any.
419419 if (i < sema.param_inst_list.len) {
......@@ -429,7 +429,7 @@ fn resolveConstString(
429429 sema: *Sema,
430430 block: *Scope.Block,
431431 src: LazySrcLoc,
432 zir_ref: zir.Inst.Ref,
432 zir_ref: Zir.Inst.Ref,
433433) ![]u8 {
434434 const tzir_inst = try sema.resolveInst(zir_ref);
435435 const wanted_type = Type.initTag(.const_slice_u8);
......@@ -438,7 +438,7 @@ fn resolveConstString(
438438 return val.toAllocatedBytes(sema.arena);
439439}
440440
441fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: zir.Inst.Ref) !Type {
441fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type {
442442 const tzir_inst = try sema.resolveInst(zir_ref);
443443 const wanted_type = Type.initTag(.@"type");
444444 const coerced_inst = try sema.coerce(block, wanted_type, tzir_inst, src);
......@@ -476,7 +476,7 @@ fn resolveAlreadyCoercedInt(
476476 sema: *Sema,
477477 block: *Scope.Block,
478478 src: LazySrcLoc,
479 zir_ref: zir.Inst.Ref,
479 zir_ref: Zir.Inst.Ref,
480480 comptime Int: type,
481481) !Int {
482482 comptime assert(@typeInfo(Int).Int.bits <= 64);
......@@ -492,7 +492,7 @@ fn resolveInt(
492492 sema: *Sema,
493493 block: *Scope.Block,
494494 src: LazySrcLoc,
495 zir_ref: zir.Inst.Ref,
495 zir_ref: Zir.Inst.Ref,
496496 dest_type: Type,
497497) !u64 {
498498 const tzir_inst = try sema.resolveInst(zir_ref);
......@@ -506,7 +506,7 @@ fn resolveInstConst(
506506 sema: *Sema,
507507 block: *Scope.Block,
508508 src: LazySrcLoc,
509 zir_ref: zir.Inst.Ref,
509 zir_ref: Zir.Inst.Ref,
510510) InnerError!TypedValue {
511511 const tzir_inst = try sema.resolveInst(zir_ref);
512512 const val = try sema.resolveConstValue(block, src, tzir_inst);
......@@ -516,13 +516,13 @@ fn resolveInstConst(
516516 };
517517}
518518
519fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
519fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
520520 const tracy = trace(@src());
521521 defer tracy.end();
522522 return sema.mod.fail(&block.base, sema.src, "TODO implement zir_sema.zirBitcastResultPtr", .{});
523523}
524524
525fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
525fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
526526 const tracy = trace(@src());
527527 defer tracy.end();
528528 return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{});
......@@ -531,7 +531,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In
531531fn zirStructDecl(
532532 sema: *Sema,
533533 block: *Scope.Block,
534 inst: zir.Inst.Index,
534 inst: Zir.Inst.Index,
535535 layout: std.builtin.TypeInfo.ContainerLayout,
536536) InnerError!*Inst {
537537 const tracy = trace(@src());
......@@ -540,7 +540,7 @@ fn zirStructDecl(
540540 const gpa = sema.gpa;
541541 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
542542 const src = inst_data.src();
543 const extra = sema.code.extraData(zir.Inst.StructDecl, inst_data.payload_index);
543 const extra = sema.code.extraData(Zir.Inst.StructDecl, inst_data.payload_index);
544544 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
545545 const fields_len = extra.data.fields_len;
546546
......@@ -650,7 +650,7 @@ fn zirStructDecl(
650650
651651 const field_name_zir = sema.code.nullTerminatedString(sema.code.extra[extra_index]);
652652 extra_index += 1;
653 const field_type_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
653 const field_type_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
654654 extra_index += 1;
655655
656656 // This string needs to outlive the ZIR code.
......@@ -669,7 +669,7 @@ fn zirStructDecl(
669669 };
670670
671671 if (has_align) {
672 const align_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
672 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
673673 extra_index += 1;
674674 // TODO: if we need to report an error here, use a source location
675675 // that points to this alignment expression rather than the struct.
......@@ -677,7 +677,7 @@ fn zirStructDecl(
677677 gop.entry.value.abi_align = (try sema.resolveInstConst(block, src, align_ref)).val;
678678 }
679679 if (has_default) {
680 const default_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
680 const default_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
681681 extra_index += 1;
682682 // TODO: if we need to report an error here, use a source location
683683 // that points to this default value expression rather than the struct.
......@@ -692,7 +692,7 @@ fn zirStructDecl(
692692fn zirEnumDecl(
693693 sema: *Sema,
694694 block: *Scope.Block,
695 inst: zir.Inst.Index,
695 inst: Zir.Inst.Index,
696696 nonexhaustive: bool,
697697) InnerError!*Inst {
698698 const tracy = trace(@src());
......@@ -701,7 +701,7 @@ fn zirEnumDecl(
701701 const gpa = sema.gpa;
702702 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
703703 const src = inst_data.src();
704 const extra = sema.code.extraData(zir.Inst.EnumDecl, inst_data.payload_index);
704 const extra = sema.code.extraData(Zir.Inst.EnumDecl, inst_data.payload_index);
705705 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
706706 const fields_len = extra.data.fields_len;
707707
......@@ -842,7 +842,7 @@ fn zirEnumDecl(
842842 assert(!gop.found_existing);
843843
844844 if (has_tag_value) {
845 const tag_val_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
845 const tag_val_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
846846 extra_index += 1;
847847 // TODO: if we need to report an error here, use a source location
848848 // that points to this default value expression rather than the struct.
......@@ -858,29 +858,29 @@ fn zirEnumDecl(
858858 return sema.analyzeDeclVal(block, src, new_decl);
859859}
860860
861fn zirUnionDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
861fn zirUnionDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
862862 const tracy = trace(@src());
863863 defer tracy.end();
864864
865865 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
866866 const src = inst_data.src();
867 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
867 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
868868
869869 return sema.mod.fail(&block.base, sema.src, "TODO implement zirUnionDecl", .{});
870870}
871871
872fn zirOpaqueDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
872fn zirOpaqueDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
873873 const tracy = trace(@src());
874874 defer tracy.end();
875875
876876 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
877877 const src = inst_data.src();
878 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
878 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
879879
880880 return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{});
881881}
882882
883fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
883fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
884884 const tracy = trace(@src());
885885 defer tracy.end();
886886
......@@ -892,7 +892,7 @@ fn zirRetPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!
892892 return block.addNoOp(src, ptr_type, .alloc);
893893}
894894
895fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
895fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
896896 const tracy = trace(@src());
897897 defer tracy.end();
898898
......@@ -901,7 +901,7 @@ fn zirRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In
901901 return sema.analyzeRef(block, inst_data.src(), operand);
902902}
903903
904fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
904fn zirRetType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
905905 const tracy = trace(@src());
906906 defer tracy.end();
907907
......@@ -912,7 +912,7 @@ fn zirRetType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
912912 return sema.mod.constType(sema.arena, src, ret_type);
913913}
914914
915fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
915fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
916916 const tracy = trace(@src());
917917 defer tracy.end();
918918
......@@ -935,7 +935,7 @@ fn ensureResultUsed(
935935 }
936936}
937937
938fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
938fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
939939 const tracy = trace(@src());
940940 defer tracy.end();
941941
......@@ -948,7 +948,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde
948948 }
949949}
950950
951fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
951fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
952952 const tracy = trace(@src());
953953 defer tracy.end();
954954
......@@ -982,7 +982,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In
982982 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
983983}
984984
985fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
985fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
986986 const tracy = trace(@src());
987987 defer tracy.end();
988988
......@@ -995,7 +995,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*
995995 return block.addNoOp(var_decl_src, ptr_type, .alloc);
996996}
997997
998fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
998fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
999999 const tracy = trace(@src());
10001000 defer tracy.end();
10011001
......@@ -1012,7 +1012,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
10121012fn zirAllocInferred(
10131013 sema: *Sema,
10141014 block: *Scope.Block,
1015 inst: zir.Inst.Index,
1015 inst: Zir.Inst.Index,
10161016 inferred_alloc_ty: Type,
10171017) InnerError!*Inst {
10181018 const tracy = trace(@src());
......@@ -1038,7 +1038,7 @@ fn zirAllocInferred(
10381038 return result;
10391039}
10401040
1041fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1041fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
10421042 const tracy = trace(@src());
10431043 defer tracy.end();
10441044
......@@ -1064,7 +1064,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde
10641064 ptr.tag = .alloc;
10651065}
10661066
1067fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1067fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
10681068 const tracy = trace(@src());
10691069 defer tracy.end();
10701070
......@@ -1072,26 +1072,26 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Ind
10721072 const mod = sema.mod;
10731073 const validate_inst = sema.code.instructions.items(.data)[inst].pl_node;
10741074 const struct_init_src = validate_inst.src();
1075 const validate_extra = sema.code.extraData(zir.Inst.Block, validate_inst.payload_index);
1075 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);
10761076 const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len];
10771077
10781078 const struct_obj: *Module.Struct = s: {
10791079 const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node;
1080 const field_ptr_extra = sema.code.extraData(zir.Inst.Field, field_ptr_data.payload_index).data;
1080 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
10811081 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);
10821082 break :s object_ptr.ty.elemType().castTag(.@"struct").?.data;
10831083 };
10841084
10851085 // Maps field index to field_ptr index of where it was already initialized.
1086 const found_fields = try gpa.alloc(zir.Inst.Index, struct_obj.fields.entries.items.len);
1086 const found_fields = try gpa.alloc(Zir.Inst.Index, struct_obj.fields.entries.items.len);
10871087 defer gpa.free(found_fields);
10881088
1089 mem.set(zir.Inst.Index, found_fields, 0);
1089 mem.set(Zir.Inst.Index, found_fields, 0);
10901090
10911091 for (instrs) |field_ptr| {
10921092 const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node;
10931093 const field_src: LazySrcLoc = .{ .node_offset_back2tok = field_ptr_data.src_node };
1094 const field_ptr_extra = sema.code.extraData(zir.Inst.Field, field_ptr_data.payload_index).data;
1094 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
10951095 const field_name = sema.code.nullTerminatedString(field_ptr_extra.field_name_start);
10961096 const field_index = struct_obj.fields.getIndex(field_name) orelse
10971097 return sema.failWithBadFieldAccess(block, struct_obj, field_src, field_name);
......@@ -1164,7 +1164,7 @@ fn failWithBadFieldAccess(
11641164 return mod.failWithOwnedErrorMsg(&block.base, msg);
11651165}
11661166
1167fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1167fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
11681168 const tracy = trace(@src());
11691169 defer tracy.end();
11701170
......@@ -1180,7 +1180,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In
11801180 return sema.storePtr(block, src, bitcasted_ptr, value);
11811181}
11821182
1183fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1183fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
11841184 const tracy = trace(@src());
11851185 defer tracy.end();
11861186
......@@ -1199,7 +1199,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index)
11991199 return sema.storePtr(block, src, bitcasted_ptr, value);
12001200}
12011201
1202fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1202fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
12031203 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
12041204 const src = inst_data.src();
12051205 try sema.requireFunctionBlock(block, src);
......@@ -1208,7 +1208,7 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index)
12081208 sema.branch_quota = quota;
12091209}
12101210
1211fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1211fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
12121212 const tracy = trace(@src());
12131213 defer tracy.end();
12141214
......@@ -1218,19 +1218,19 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!v
12181218 return sema.storePtr(block, sema.src, ptr, value);
12191219}
12201220
1221fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1221fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
12221222 const tracy = trace(@src());
12231223 defer tracy.end();
12241224
12251225 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
12261226 const src = inst_data.src();
1227 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
1227 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
12281228 const ptr = try sema.resolveInst(extra.lhs);
12291229 const value = try sema.resolveInst(extra.rhs);
12301230 return sema.storePtr(block, src, ptr, value);
12311231}
12321232
1233fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1233fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
12341234 const tracy = trace(@src());
12351235 defer tracy.end();
12361236
......@@ -1266,7 +1266,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
12661266 return sema.mod.constType(sema.arena, src, param_type);
12671267}
12681268
1269fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1269fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
12701270 const tracy = trace(@src());
12711271 defer tracy.end();
12721272
......@@ -1292,7 +1292,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In
12921292 return sema.analyzeDeclRef(block, .unneeded, new_decl);
12931293}
12941294
1295fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1295fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
12961296 const tracy = trace(@src());
12971297 defer tracy.end();
12981298
......@@ -1300,7 +1300,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In
13001300 return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int);
13011301}
13021302
1303fn zirFloat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1303fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
13041304 const arena = sema.arena;
13051305 const inst_data = sema.code.instructions.items(.data)[inst].float;
13061306 const src = inst_data.src();
......@@ -1312,10 +1312,10 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*
13121312 });
13131313}
13141314
1315fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1315fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
13161316 const arena = sema.arena;
13171317 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1318 const extra = sema.code.extraData(zir.Inst.Float128, inst_data.payload_index).data;
1318 const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;
13191319 const src = inst_data.src();
13201320 const number = extra.get();
13211321
......@@ -1325,7 +1325,7 @@ fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
13251325 });
13261326}
13271327
1328fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index {
1328fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
13291329 const tracy = trace(@src());
13301330 defer tracy.end();
13311331
......@@ -1336,13 +1336,13 @@ fn zirCompileError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner
13361336 return sema.mod.fail(&block.base, src, "{s}", .{msg});
13371337}
13381338
1339fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1339fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
13401340 var managed = sema.mod.compile_log_text.toManaged(sema.gpa);
13411341 defer sema.mod.compile_log_text = managed.moveToUnmanaged();
13421342 const writer = managed.writer();
13431343
13441344 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1345 const extra = sema.code.extraData(zir.Inst.MultiOp, inst_data.payload_index);
1345 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
13461346 const args = sema.code.refSlice(extra.end, extra.data.operands_len);
13471347
13481348 for (args) |arg_ref, i| {
......@@ -1363,7 +1363,7 @@ fn zirCompileLog(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
13631363 }
13641364}
13651365
1366fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index {
1366fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
13671367 const tracy = trace(@src());
13681368 defer tracy.end();
13691369
......@@ -1373,13 +1373,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!
13731373 return always_noreturn;
13741374}
13751375
1376fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1376fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
13771377 const tracy = trace(@src());
13781378 defer tracy.end();
13791379
13801380 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
13811381 const src = inst_data.src();
1382 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
1382 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
13831383 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
13841384
13851385 // TZIR expects a block outside the loop block too.
......@@ -1434,13 +1434,13 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerE
14341434 return sema.analyzeBlockBody(parent_block, src, &child_block, merges);
14351435}
14361436
1437fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1437fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
14381438 const tracy = trace(@src());
14391439 defer tracy.end();
14401440
14411441 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
14421442 const src = inst_data.src();
1443 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
1443 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
14441444 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
14451445
14461446 // Reserve space for a Block instruction so that generated Break instructions can
......@@ -1566,12 +1566,12 @@ fn analyzeBlockBody(
15661566 return &merges.block_inst.base;
15671567}
15681568
1569fn zirExport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1569fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
15701570 const tracy = trace(@src());
15711571 defer tracy.end();
15721572
15731573 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1574 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
1574 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
15751575 const src = inst_data.src();
15761576 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
15771577 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -1588,7 +1588,7 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!
15881588 try sema.mod.analyzeExport(&block.base, src, export_name, actual_fn.owner_decl);
15891589}
15901590
1591fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1591fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
15921592 const tracy = trace(@src());
15931593 defer tracy.end();
15941594
......@@ -1598,7 +1598,7 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
15981598 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
15991599}
16001600
1601fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index {
1601fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
16021602 const tracy = trace(@src());
16031603 defer tracy.end();
16041604
......@@ -1638,7 +1638,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: zir.Inst.Index) InnerE
16381638 }
16391639}
16401640
1641fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
1641fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
16421642 const tracy = trace(@src());
16431643 defer tracy.end();
16441644
......@@ -1656,21 +1656,21 @@ fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE
16561656 _ = try block.addDbgStmt(src, abs_byte_off);
16571657}
16581658
1659fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1659fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
16601660 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
16611661 const src = inst_data.src();
16621662 const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key;
16631663 return sema.analyzeDeclRef(block, src, decl);
16641664}
16651665
1666fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1666fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
16671667 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
16681668 const src = inst_data.src();
16691669 const decl = sema.owner_decl.dependencies.entries.items[inst_data.payload_index].key;
16701670 return sema.analyzeDeclVal(block, src, decl);
16711671}
16721672
1673fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1673fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
16741674 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
16751675 const src = inst_data.src();
16761676 const decl_name = inst_data.get(sema.code);
......@@ -1678,7 +1678,7 @@ fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner
16781678 return sema.analyzeDeclRef(block, src, decl);
16791679}
16801680
1681fn zirDeclValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1681fn zirDeclValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
16821682 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
16831683 const src = inst_data.src();
16841684 const decl_name = inst_data.get(sema.code);
......@@ -1701,7 +1701,7 @@ fn lookupIdentifier(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, name: []c
17011701fn zirCallNone(
17021702 sema: *Sema,
17031703 block: *Scope.Block,
1704 inst: zir.Inst.Index,
1704 inst: Zir.Inst.Index,
17051705 ensure_result_used: bool,
17061706) InnerError!*Inst {
17071707 const tracy = trace(@src());
......@@ -1716,7 +1716,7 @@ fn zirCallNone(
17161716fn zirCall(
17171717 sema: *Sema,
17181718 block: *Scope.Block,
1719 inst: zir.Inst.Index,
1719 inst: Zir.Inst.Index,
17201720 modifier: std.builtin.CallOptions.Modifier,
17211721 ensure_result_used: bool,
17221722) InnerError!*Inst {
......@@ -1726,7 +1726,7 @@ fn zirCall(
17261726 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
17271727 const func_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node };
17281728 const call_src = inst_data.src();
1729 const extra = sema.code.extraData(zir.Inst.Call, inst_data.payload_index);
1729 const extra = sema.code.extraData(Zir.Inst.Call, inst_data.payload_index);
17301730 const args = sema.code.refSlice(extra.end, extra.data.args_len);
17311731
17321732 return sema.analyzeCall(block, extra.data.callee, func_src, call_src, modifier, ensure_result_used, args);
......@@ -1735,12 +1735,12 @@ fn zirCall(
17351735fn analyzeCall(
17361736 sema: *Sema,
17371737 block: *Scope.Block,
1738 zir_func: zir.Inst.Ref,
1738 zir_func: Zir.Inst.Ref,
17391739 func_src: LazySrcLoc,
17401740 call_src: LazySrcLoc,
17411741 modifier: std.builtin.CallOptions.Modifier,
17421742 ensure_result_used: bool,
1743 zir_args: []const zir.Inst.Ref,
1743 zir_args: []const Zir.Inst.Ref,
17441744) InnerError!*ir.Inst {
17451745 const func = try sema.resolveInst(zir_func);
17461746
......@@ -1886,7 +1886,7 @@ fn analyzeCall(
18861886 return result;
18871887}
18881888
1889fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1889fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
18901890 const tracy = trace(@src());
18911891 defer tracy.end();
18921892
......@@ -1897,7 +1897,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
18971897 return sema.mod.constType(sema.arena, src, ty);
18981898}
18991899
1900fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1900fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19011901 const tracy = trace(@src());
19021902 defer tracy.end();
19031903
......@@ -1909,7 +1909,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner
19091909 return sema.mod.constType(sema.arena, src, opt_type);
19101910}
19111911
1912fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1912fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19131913 const tracy = trace(@src());
19141914 defer tracy.end();
19151915
......@@ -1921,7 +1921,7 @@ fn zirOptionalTypeFromPtrElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.I
19211921 return sema.mod.constType(sema.arena, inst_data.src(), opt_ty);
19221922}
19231923
1924fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1924fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19251925 const tracy = trace(@src());
19261926 defer tracy.end();
19271927
......@@ -1934,14 +1934,14 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
19341934 return sema.mod.constType(sema.arena, .unneeded, array_ty);
19351935}
19361936
1937fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1937fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19381938 const tracy = trace(@src());
19391939 defer tracy.end();
19401940
19411941 // TODO these should be lazily evaluated
19421942 const inst_data = sema.code.instructions.items(.data)[inst].array_type_sentinel;
19431943 const len = try sema.resolveInstConst(block, .unneeded, inst_data.len);
1944 const extra = sema.code.extraData(zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data;
1944 const extra = sema.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data;
19451945 const sentinel = try sema.resolveInstConst(block, .unneeded, extra.sentinel);
19461946 const elem_type = try sema.resolveType(block, .unneeded, extra.elem_type);
19471947 const array_ty = try sema.mod.arrayType(sema.arena, len.val.toUnsignedInt(), sentinel.val, elem_type);
......@@ -1949,12 +1949,12 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index)
19491949 return sema.mod.constType(sema.arena, .unneeded, array_ty);
19501950}
19511951
1952fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1952fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19531953 const tracy = trace(@src());
19541954 defer tracy.end();
19551955
19561956 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
1957 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
1957 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
19581958 const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node };
19591959 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
19601960 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
......@@ -1970,7 +1970,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inn
19701970 return sema.mod.constType(sema.arena, src, err_union_ty);
19711971}
19721972
1973fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1973fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19741974 const tracy = trace(@src());
19751975 defer tracy.end();
19761976
......@@ -1988,7 +1988,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
19881988 });
19891989}
19901990
1991fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
1991fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
19921992 const tracy = trace(@src());
19931993 defer tracy.end();
19941994
......@@ -2014,7 +2014,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
20142014 return block.addUnOp(src, Type.initTag(.u16), .error_to_int, op_coerced);
20152015}
20162016
2017fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2017fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
20182018 const tracy = trace(@src());
20192019 defer tracy.end();
20202020
......@@ -2047,12 +2047,12 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
20472047 return block.addUnOp(src, Type.initTag(.anyerror), .int_to_error, op);
20482048}
20492049
2050fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2050fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
20512051 const tracy = trace(@src());
20522052 defer tracy.end();
20532053
20542054 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2055 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2055 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
20562056 const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node };
20572057 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
20582058 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
......@@ -2126,7 +2126,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inn
21262126 });
21272127}
21282128
2129fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2129fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
21302130 const tracy = trace(@src());
21312131 defer tracy.end();
21322132
......@@ -2139,7 +2139,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE
21392139 });
21402140}
21412141
2142fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2142fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
21432143 const tracy = trace(@src());
21442144 defer tracy.end();
21452145
......@@ -2152,7 +2152,7 @@ fn zirEnumLiteralSmall(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) I
21522152 });
21532153}
21542154
2155fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2155fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
21562156 const mod = sema.mod;
21572157 const arena = sema.arena;
21582158 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
......@@ -2234,12 +2234,12 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
22342234 return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag);
22352235}
22362236
2237fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2237fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
22382238 const mod = sema.mod;
22392239 const target = mod.getTarget();
22402240 const arena = sema.arena;
22412241 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
2242 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2242 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
22432243 const src = inst_data.src();
22442244 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
22452245 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -2293,7 +2293,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
22932293fn zirOptionalPayloadPtr(
22942294 sema: *Sema,
22952295 block: *Scope.Block,
2296 inst: zir.Inst.Index,
2296 inst: Zir.Inst.Index,
22972297 safety_check: bool,
22982298) InnerError!*Inst {
22992299 const tracy = trace(@src());
......@@ -2336,7 +2336,7 @@ fn zirOptionalPayloadPtr(
23362336fn zirOptionalPayload(
23372337 sema: *Sema,
23382338 block: *Scope.Block,
2339 inst: zir.Inst.Index,
2339 inst: Zir.Inst.Index,
23402340 safety_check: bool,
23412341) InnerError!*Inst {
23422342 const tracy = trace(@src());
......@@ -2374,7 +2374,7 @@ fn zirOptionalPayload(
23742374fn zirErrUnionPayload(
23752375 sema: *Sema,
23762376 block: *Scope.Block,
2377 inst: zir.Inst.Index,
2377 inst: Zir.Inst.Index,
23782378 safety_check: bool,
23792379) InnerError!*Inst {
23802380 const tracy = trace(@src());
......@@ -2408,7 +2408,7 @@ fn zirErrUnionPayload(
24082408fn zirErrUnionPayloadPtr(
24092409 sema: *Sema,
24102410 block: *Scope.Block,
2411 inst: zir.Inst.Index,
2411 inst: Zir.Inst.Index,
24122412 safety_check: bool,
24132413) InnerError!*Inst {
24142414 const tracy = trace(@src());
......@@ -2449,7 +2449,7 @@ fn zirErrUnionPayloadPtr(
24492449}
24502450
24512451/// Value in, value out
2452fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2452fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
24532453 const tracy = trace(@src());
24542454 defer tracy.end();
24552455
......@@ -2473,7 +2473,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inner
24732473}
24742474
24752475/// Pointer in, value out
2476fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2476fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
24772477 const tracy = trace(@src());
24782478 defer tracy.end();
24792479
......@@ -2499,7 +2499,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In
24992499 return block.addUnOp(src, operand.ty.castTag(.error_union).?.data.payload, .unwrap_errunion_err_ptr, operand);
25002500}
25012501
2502fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!void {
2502fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void {
25032503 const tracy = trace(@src());
25042504 defer tracy.end();
25052505
......@@ -2513,13 +2513,13 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde
25132513 }
25142514}
25152515
2516fn zirFnType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: bool) InnerError!*Inst {
2516fn zirFnType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, var_args: bool) InnerError!*Inst {
25172517 const tracy = trace(@src());
25182518 defer tracy.end();
25192519
25202520 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
25212521 const src = inst_data.src();
2522 const extra = sema.code.extraData(zir.Inst.FnType, inst_data.payload_index);
2522 const extra = sema.code.extraData(Zir.Inst.FnType, inst_data.payload_index);
25232523 const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len);
25242524
25252525 return sema.fnTypeCommon(
......@@ -2532,14 +2532,14 @@ fn zirFnType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: b
25322532 );
25332533}
25342534
2535fn zirFnTypeCc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index, var_args: bool) InnerError!*Inst {
2535fn zirFnTypeCc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, var_args: bool) InnerError!*Inst {
25362536 const tracy = trace(@src());
25372537 defer tracy.end();
25382538
25392539 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
25402540 const src = inst_data.src();
25412541 const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = inst_data.src_node };
2542 const extra = sema.code.extraData(zir.Inst.FnTypeCc, inst_data.payload_index);
2542 const extra = sema.code.extraData(Zir.Inst.FnTypeCc, inst_data.payload_index);
25432543 const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len);
25442544
25452545 const cc_tv = try sema.resolveInstConst(block, cc_src, extra.data.cc);
......@@ -2562,8 +2562,8 @@ fn fnTypeCommon(
25622562 sema: *Sema,
25632563 block: *Scope.Block,
25642564 src_node_offset: i32,
2565 zir_param_types: []const zir.Inst.Ref,
2566 zir_return_type: zir.Inst.Ref,
2565 zir_param_types: []const Zir.Inst.Ref,
2566 zir_return_type: Zir.Inst.Ref,
25672567 cc: std.builtin.CallingConvention,
25682568 var_args: bool,
25692569) InnerError!*Inst {
......@@ -2608,7 +2608,7 @@ fn fnTypeCommon(
26082608 return sema.mod.constType(sema.arena, src, fn_ty);
26092609}
26102610
2611fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2611fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26122612 const tracy = trace(@src());
26132613 defer tracy.end();
26142614
......@@ -2616,13 +2616,13 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Ins
26162616 return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs);
26172617}
26182618
2619fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2619fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26202620 const tracy = trace(@src());
26212621 defer tracy.end();
26222622
26232623 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
26242624 const src = inst_data.src();
2625 const extra = sema.code.extraData(zir.Inst.As, inst_data.payload_index).data;
2625 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;
26262626 return sema.analyzeAs(block, src, extra.dest_type, extra.operand);
26272627}
26282628
......@@ -2630,15 +2630,15 @@ fn analyzeAs(
26302630 sema: *Sema,
26312631 block: *Scope.Block,
26322632 src: LazySrcLoc,
2633 zir_dest_type: zir.Inst.Ref,
2634 zir_operand: zir.Inst.Ref,
2633 zir_dest_type: Zir.Inst.Ref,
2634 zir_operand: Zir.Inst.Ref,
26352635) InnerError!*Inst {
26362636 const dest_type = try sema.resolveType(block, src, zir_dest_type);
26372637 const operand = try sema.resolveInst(zir_operand);
26382638 return sema.coerce(block, dest_type, operand, src);
26392639}
26402640
2641fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2641fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26422642 const tracy = trace(@src());
26432643 defer tracy.end();
26442644
......@@ -2655,14 +2655,14 @@ fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
26552655 return block.addUnOp(src, ty, .ptrtoint, ptr);
26562656}
26572657
2658fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2658fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26592659 const tracy = trace(@src());
26602660 defer tracy.end();
26612661
26622662 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
26632663 const src = inst_data.src();
26642664 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
2665 const extra = sema.code.extraData(zir.Inst.Field, inst_data.payload_index).data;
2665 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
26662666 const field_name = sema.code.nullTerminatedString(extra.field_name_start);
26672667 const object = try sema.resolveInst(extra.lhs);
26682668 const object_ptr = if (object.ty.zigTypeTag() == .Pointer)
......@@ -2673,27 +2673,27 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
26732673 return sema.analyzeLoad(block, src, result_ptr, result_ptr.src);
26742674}
26752675
2676fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2676fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26772677 const tracy = trace(@src());
26782678 defer tracy.end();
26792679
26802680 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
26812681 const src = inst_data.src();
26822682 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
2683 const extra = sema.code.extraData(zir.Inst.Field, inst_data.payload_index).data;
2683 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
26842684 const field_name = sema.code.nullTerminatedString(extra.field_name_start);
26852685 const object_ptr = try sema.resolveInst(extra.lhs);
26862686 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
26872687}
26882688
2689fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2689fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
26902690 const tracy = trace(@src());
26912691 defer tracy.end();
26922692
26932693 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
26942694 const src = inst_data.src();
26952695 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2696 const extra = sema.code.extraData(zir.Inst.FieldNamed, inst_data.payload_index).data;
2696 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
26972697 const object = try sema.resolveInst(extra.lhs);
26982698 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name);
26992699 const object_ptr = try sema.analyzeRef(block, src, object);
......@@ -2701,20 +2701,20 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne
27012701 return sema.analyzeLoad(block, src, result_ptr, src);
27022702}
27032703
2704fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2704fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
27052705 const tracy = trace(@src());
27062706 defer tracy.end();
27072707
27082708 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
27092709 const src = inst_data.src();
27102710 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2711 const extra = sema.code.extraData(zir.Inst.FieldNamed, inst_data.payload_index).data;
2711 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
27122712 const object_ptr = try sema.resolveInst(extra.lhs);
27132713 const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name);
27142714 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
27152715}
27162716
2717fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2717fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
27182718 const tracy = trace(@src());
27192719 defer tracy.end();
27202720
......@@ -2722,7 +2722,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
27222722 const src = inst_data.src();
27232723 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
27242724 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2725 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2725 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
27262726
27272727 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);
27282728 const operand = try sema.resolveInst(extra.rhs);
......@@ -2757,7 +2757,7 @@ fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
27572757 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{});
27582758}
27592759
2760fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2760fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
27612761 const tracy = trace(@src());
27622762 defer tracy.end();
27632763
......@@ -2765,14 +2765,14 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
27652765 const src = inst_data.src();
27662766 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
27672767 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2768 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2768 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
27692769
27702770 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);
27712771 const operand = try sema.resolveInst(extra.rhs);
27722772 return sema.bitcast(block, dest_type, operand);
27732773}
27742774
2775fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2775fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
27762776 const tracy = trace(@src());
27772777 defer tracy.end();
27782778
......@@ -2780,7 +2780,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
27802780 const src = inst_data.src();
27812781 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
27822782 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2783 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2783 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
27842784
27852785 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);
27862786 const operand = try sema.resolveInst(extra.rhs);
......@@ -2815,7 +2815,7 @@ fn zirFloatcast(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
28152815 return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{});
28162816}
28172817
2818fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2818fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28192819 const tracy = trace(@src());
28202820 defer tracy.end();
28212821
......@@ -2830,14 +2830,14 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
28302830 return sema.analyzeLoad(block, sema.src, result_ptr, sema.src);
28312831}
28322832
2833fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2833fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28342834 const tracy = trace(@src());
28352835 defer tracy.end();
28362836
28372837 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
28382838 const src = inst_data.src();
28392839 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
2840 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2840 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
28412841 const array = try sema.resolveInst(extra.lhs);
28422842 const array_ptr = if (array.ty.zigTypeTag() == .Pointer)
28432843 array
......@@ -2848,7 +2848,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE
28482848 return sema.analyzeLoad(block, src, result_ptr, src);
28492849}
28502850
2851fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2851fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28522852 const tracy = trace(@src());
28532853 defer tracy.end();
28542854
......@@ -2858,39 +2858,39 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
28582858 return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src);
28592859}
28602860
2861fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2861fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28622862 const tracy = trace(@src());
28632863 defer tracy.end();
28642864
28652865 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
28662866 const src = inst_data.src();
28672867 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
2868 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
2868 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
28692869 const array_ptr = try sema.resolveInst(extra.lhs);
28702870 const elem_index = try sema.resolveInst(extra.rhs);
28712871 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src);
28722872}
28732873
2874fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2874fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28752875 const tracy = trace(@src());
28762876 defer tracy.end();
28772877
28782878 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
28792879 const src = inst_data.src();
2880 const extra = sema.code.extraData(zir.Inst.SliceStart, inst_data.payload_index).data;
2880 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
28812881 const array_ptr = try sema.resolveInst(extra.lhs);
28822882 const start = try sema.resolveInst(extra.start);
28832883
28842884 return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded);
28852885}
28862886
2887fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2887fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28882888 const tracy = trace(@src());
28892889 defer tracy.end();
28902890
28912891 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
28922892 const src = inst_data.src();
2893 const extra = sema.code.extraData(zir.Inst.SliceEnd, inst_data.payload_index).data;
2893 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
28942894 const array_ptr = try sema.resolveInst(extra.lhs);
28952895 const start = try sema.resolveInst(extra.start);
28962896 const end = try sema.resolveInst(extra.end);
......@@ -2898,14 +2898,14 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
28982898 return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded);
28992899}
29002900
2901fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
2901fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
29022902 const tracy = trace(@src());
29032903 defer tracy.end();
29042904
29052905 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
29062906 const src = inst_data.src();
29072907 const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node };
2908 const extra = sema.code.extraData(zir.Inst.SliceSentinel, inst_data.payload_index).data;
2908 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
29092909 const array_ptr = try sema.resolveInst(extra.lhs);
29102910 const start = try sema.resolveInst(extra.start);
29112911 const end = try sema.resolveInst(extra.end);
......@@ -2917,7 +2917,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne
29172917fn zirSwitchCapture(
29182918 sema: *Sema,
29192919 block: *Scope.Block,
2920 inst: zir.Inst.Index,
2920 inst: Zir.Inst.Index,
29212921 is_multi: bool,
29222922 is_ref: bool,
29232923) InnerError!*Inst {
......@@ -2935,7 +2935,7 @@ fn zirSwitchCapture(
29352935fn zirSwitchCaptureElse(
29362936 sema: *Sema,
29372937 block: *Scope.Block,
2938 inst: zir.Inst.Index,
2938 inst: Zir.Inst.Index,
29392939 is_ref: bool,
29402940) InnerError!*Inst {
29412941 const tracy = trace(@src());
......@@ -2952,9 +2952,9 @@ fn zirSwitchCaptureElse(
29522952fn zirSwitchBlock(
29532953 sema: *Sema,
29542954 block: *Scope.Block,
2955 inst: zir.Inst.Index,
2955 inst: Zir.Inst.Index,
29562956 is_ref: bool,
2957 special_prong: zir.SpecialProng,
2957 special_prong: Zir.SpecialProng,
29582958) InnerError!*Inst {
29592959 const tracy = trace(@src());
29602960 defer tracy.end();
......@@ -2962,7 +2962,7 @@ fn zirSwitchBlock(
29622962 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
29632963 const src = inst_data.src();
29642964 const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node };
2965 const extra = sema.code.extraData(zir.Inst.SwitchBlock, inst_data.payload_index);
2965 const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index);
29662966
29672967 const operand_ptr = try sema.resolveInst(extra.data.operand);
29682968 const operand = if (is_ref)
......@@ -2985,9 +2985,9 @@ fn zirSwitchBlock(
29852985fn zirSwitchBlockMulti(
29862986 sema: *Sema,
29872987 block: *Scope.Block,
2988 inst: zir.Inst.Index,
2988 inst: Zir.Inst.Index,
29892989 is_ref: bool,
2990 special_prong: zir.SpecialProng,
2990 special_prong: Zir.SpecialProng,
29912991) InnerError!*Inst {
29922992 const tracy = trace(@src());
29932993 defer tracy.end();
......@@ -2995,7 +2995,7 @@ fn zirSwitchBlockMulti(
29952995 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
29962996 const src = inst_data.src();
29972997 const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node };
2998 const extra = sema.code.extraData(zir.Inst.SwitchBlockMulti, inst_data.payload_index);
2998 const extra = sema.code.extraData(Zir.Inst.SwitchBlockMulti, inst_data.payload_index);
29992999
30003000 const operand_ptr = try sema.resolveInst(extra.data.operand);
30013001 const operand = if (is_ref)
......@@ -3020,16 +3020,16 @@ fn analyzeSwitch(
30203020 block: *Scope.Block,
30213021 operand: *Inst,
30223022 extra_end: usize,
3023 special_prong: zir.SpecialProng,
3023 special_prong: Zir.SpecialProng,
30243024 scalar_cases_len: usize,
30253025 multi_cases_len: usize,
3026 switch_inst: zir.Inst.Index,
3026 switch_inst: Zir.Inst.Index,
30273027 src_node_offset: i32,
30283028) InnerError!*Inst {
30293029 const gpa = sema.gpa;
30303030 const mod = sema.mod;
30313031
3032 const special: struct { body: []const zir.Inst.Index, end: usize } = switch (special_prong) {
3032 const special: struct { body: []const Zir.Inst.Index, end: usize } = switch (special_prong) {
30333033 .none => .{ .body = &.{}, .end = extra_end },
30343034 .under, .@"else" => blk: {
30353035 const body_len = sema.code.extra[extra_end];
......@@ -3079,7 +3079,7 @@ fn analyzeSwitch(
30793079 {
30803080 var scalar_i: u32 = 0;
30813081 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3082 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3082 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
30833083 extra_index += 1;
30843084 const body_len = sema.code.extra[extra_index];
30853085 extra_index += 1;
......@@ -3189,7 +3189,7 @@ fn analyzeSwitch(
31893189 {
31903190 var scalar_i: u32 = 0;
31913191 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3192 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3192 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
31933193 extra_index += 1;
31943194 const body_len = sema.code.extra[extra_index];
31953195 extra_index += 1;
......@@ -3229,9 +3229,9 @@ fn analyzeSwitch(
32293229
32303230 var range_i: u32 = 0;
32313231 while (range_i < ranges_len) : (range_i += 1) {
3232 const item_first = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3232 const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
32333233 extra_index += 1;
3234 const item_last = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3234 const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
32353235 extra_index += 1;
32363236
32373237 try sema.validateSwitchRange(
......@@ -3285,7 +3285,7 @@ fn analyzeSwitch(
32853285 {
32863286 var scalar_i: u32 = 0;
32873287 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3288 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3288 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
32893289 extra_index += 1;
32903290 const body_len = sema.code.extra[extra_index];
32913291 extra_index += 1;
......@@ -3368,7 +3368,7 @@ fn analyzeSwitch(
33683368 {
33693369 var scalar_i: u32 = 0;
33703370 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3371 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3371 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
33723372 extra_index += 1;
33733373 const body_len = sema.code.extra[extra_index];
33743374 extra_index += 1;
......@@ -3435,7 +3435,7 @@ fn analyzeSwitch(
34353435 {
34363436 var scalar_i: usize = 0;
34373437 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3438 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3438 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
34393439 extra_index += 1;
34403440 const body_len = sema.code.extra[extra_index];
34413441 extra_index += 1;
......@@ -3474,9 +3474,9 @@ fn analyzeSwitch(
34743474
34753475 var range_i: usize = 0;
34763476 while (range_i < ranges_len) : (range_i += 1) {
3477 const item_first = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3477 const item_first = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
34783478 extra_index += 1;
3479 const item_last = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3479 const item_last = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
34803480 extra_index += 1;
34813481
34823482 // Validation above ensured these will succeed.
......@@ -3544,7 +3544,7 @@ fn analyzeSwitch(
35443544
35453545 var scalar_i: usize = 0;
35463546 while (scalar_i < scalar_cases_len) : (scalar_i += 1) {
3547 const item_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3547 const item_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
35483548 extra_index += 1;
35493549 const body_len = sema.code.extra[extra_index];
35503550 extra_index += 1;
......@@ -3597,9 +3597,9 @@ fn analyzeSwitch(
35973597
35983598 var range_i: usize = 0;
35993599 while (range_i < ranges_len) : (range_i += 1) {
3600 const first_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3600 const first_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
36013601 extra_index += 1;
3602 const last_ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_index]);
3602 const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
36033603 extra_index += 1;
36043604
36053605 const item_first = try sema.resolveInst(first_ref);
......@@ -3696,7 +3696,7 @@ fn analyzeSwitch(
36963696fn resolveSwitchItemVal(
36973697 sema: *Sema,
36983698 block: *Scope.Block,
3699 item_ref: zir.Inst.Ref,
3699 item_ref: Zir.Inst.Ref,
37003700 switch_node_offset: i32,
37013701 switch_prong_src: AstGen.SwitchProngSrc,
37023702 range_expand: AstGen.SwitchProngSrc.RangeExpand,
......@@ -3720,8 +3720,8 @@ fn validateSwitchRange(
37203720 sema: *Sema,
37213721 block: *Scope.Block,
37223722 range_set: *RangeSet,
3723 first_ref: zir.Inst.Ref,
3724 last_ref: zir.Inst.Ref,
3723 first_ref: Zir.Inst.Ref,
3724 last_ref: Zir.Inst.Ref,
37253725 src_node_offset: i32,
37263726 switch_prong_src: AstGen.SwitchProngSrc,
37273727) InnerError!void {
......@@ -3735,7 +3735,7 @@ fn validateSwitchItem(
37353735 sema: *Sema,
37363736 block: *Scope.Block,
37373737 range_set: *RangeSet,
3738 item_ref: zir.Inst.Ref,
3738 item_ref: Zir.Inst.Ref,
37393739 src_node_offset: i32,
37403740 switch_prong_src: AstGen.SwitchProngSrc,
37413741) InnerError!void {
......@@ -3748,7 +3748,7 @@ fn validateSwitchItemEnum(
37483748 sema: *Sema,
37493749 block: *Scope.Block,
37503750 seen_fields: []?AstGen.SwitchProngSrc,
3751 item_ref: zir.Inst.Ref,
3751 item_ref: Zir.Inst.Ref,
37523752 src_node_offset: i32,
37533753 switch_prong_src: AstGen.SwitchProngSrc,
37543754) InnerError!void {
......@@ -3815,7 +3815,7 @@ fn validateSwitchItemBool(
38153815 block: *Scope.Block,
38163816 true_count: *u8,
38173817 false_count: *u8,
3818 item_ref: zir.Inst.Ref,
3818 item_ref: Zir.Inst.Ref,
38193819 src_node_offset: i32,
38203820 switch_prong_src: AstGen.SwitchProngSrc,
38213821) InnerError!void {
......@@ -3837,7 +3837,7 @@ fn validateSwitchItemSparse(
38373837 sema: *Sema,
38383838 block: *Scope.Block,
38393839 seen_values: *ValueSrcMap,
3840 item_ref: zir.Inst.Ref,
3840 item_ref: Zir.Inst.Ref,
38413841 src_node_offset: i32,
38423842 switch_prong_src: AstGen.SwitchProngSrc,
38433843) InnerError!void {
......@@ -3879,12 +3879,12 @@ fn validateSwitchNoRange(
38793879 return sema.mod.failWithOwnedErrorMsg(&block.base, msg);
38803880}
38813881
3882fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
3882fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
38833883 const tracy = trace(@src());
38843884 defer tracy.end();
38853885
38863886 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
3887 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
3887 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
38883888 const src = inst_data.src();
38893889 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
38903890 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -3907,7 +3907,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
39073907 return mod.constBool(arena, src, false);
39083908}
39093909
3910fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
3910fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
39113911 const tracy = trace(@src());
39123912 defer tracy.end();
39133913
......@@ -3933,13 +3933,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!
39333933 return mod.constType(sema.arena, src, file.namespace.ty);
39343934}
39353935
3936fn zirShl(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
3936fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
39373937 const tracy = trace(@src());
39383938 defer tracy.end();
39393939 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});
39403940}
39413941
3942fn zirShr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
3942fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
39433943 const tracy = trace(@src());
39443944 defer tracy.end();
39453945 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{});
......@@ -3948,7 +3948,7 @@ fn zirShr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*In
39483948fn zirBitwise(
39493949 sema: *Sema,
39503950 block: *Scope.Block,
3951 inst: zir.Inst.Index,
3951 inst: Zir.Inst.Index,
39523952 ir_tag: ir.Inst.Tag,
39533953) InnerError!*Inst {
39543954 const tracy = trace(@src());
......@@ -3958,7 +3958,7 @@ fn zirBitwise(
39583958 const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node };
39593959 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
39603960 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
3961 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
3961 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
39623962 const lhs = try sema.resolveInst(extra.lhs);
39633963 const rhs = try sema.resolveInst(extra.rhs);
39643964
......@@ -4011,19 +4011,19 @@ fn zirBitwise(
40114011 return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs);
40124012}
40134013
4014fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4014fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
40154015 const tracy = trace(@src());
40164016 defer tracy.end();
40174017 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});
40184018}
40194019
4020fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4020fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
40214021 const tracy = trace(@src());
40224022 defer tracy.end();
40234023 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});
40244024}
40254025
4026fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4026fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
40274027 const tracy = trace(@src());
40284028 defer tracy.end();
40294029 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{});
......@@ -4032,8 +4032,8 @@ fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
40324032fn zirNegate(
40334033 sema: *Sema,
40344034 block: *Scope.Block,
4035 inst: zir.Inst.Index,
4036 tag_override: zir.Inst.Tag,
4035 inst: Zir.Inst.Index,
4036 tag_override: Zir.Inst.Tag,
40374037) InnerError!*Inst {
40384038 const tracy = trace(@src());
40394039 defer tracy.end();
......@@ -4048,7 +4048,7 @@ fn zirNegate(
40484048 return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src);
40494049}
40504050
4051fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4051fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
40524052 const tracy = trace(@src());
40534053 defer tracy.end();
40544054
......@@ -4057,7 +4057,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
40574057 const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node };
40584058 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
40594059 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
4060 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
4060 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
40614061 const lhs = try sema.resolveInst(extra.lhs);
40624062 const rhs = try sema.resolveInst(extra.rhs);
40634063
......@@ -4067,7 +4067,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
40674067fn analyzeArithmetic(
40684068 sema: *Sema,
40694069 block: *Scope.Block,
4070 zir_tag: zir.Inst.Tag,
4070 zir_tag: Zir.Inst.Tag,
40714071 lhs: *Inst,
40724072 rhs: *Inst,
40734073 src: LazySrcLoc,
......@@ -4174,7 +4174,7 @@ fn analyzeArithmetic(
41744174 return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs);
41754175}
41764176
4177fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4177fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
41784178 const tracy = trace(@src());
41794179 defer tracy.end();
41804180
......@@ -4188,7 +4188,7 @@ fn zirLoad(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*I
41884188fn zirAsm(
41894189 sema: *Sema,
41904190 block: *Scope.Block,
4191 inst: zir.Inst.Index,
4191 inst: Zir.Inst.Index,
41924192 is_volatile: bool,
41934193) InnerError!*Inst {
41944194 const tracy = trace(@src());
......@@ -4198,7 +4198,7 @@ fn zirAsm(
41984198 const src = inst_data.src();
41994199 const asm_source_src: LazySrcLoc = .{ .node_offset_asm_source = inst_data.src_node };
42004200 const ret_ty_src: LazySrcLoc = .{ .node_offset_asm_ret_ty = inst_data.src_node };
4201 const extra = sema.code.extraData(zir.Inst.Asm, inst_data.payload_index);
4201 const extra = sema.code.extraData(Zir.Inst.Asm, inst_data.payload_index);
42024202 const return_type = try sema.resolveType(block, ret_ty_src, extra.data.return_type);
42034203 const asm_source = try sema.resolveConstString(block, asm_source_src, extra.data.asm_source);
42044204
......@@ -4218,7 +4218,7 @@ fn zirAsm(
42184218 const clobbers = try sema.arena.alloc([]const u8, extra.data.clobbers_len);
42194219
42204220 for (args) |*arg| {
4221 arg.* = try sema.resolveInst(@intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]));
4221 arg.* = try sema.resolveInst(@intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]));
42224222 extra_i += 1;
42234223 }
42244224 for (inputs) |*name| {
......@@ -4253,7 +4253,7 @@ fn zirAsm(
42534253fn zirCmp(
42544254 sema: *Sema,
42554255 block: *Scope.Block,
4256 inst: zir.Inst.Index,
4256 inst: Zir.Inst.Index,
42574257 op: std.math.CompareOperator,
42584258) InnerError!*Inst {
42594259 const tracy = trace(@src());
......@@ -4262,7 +4262,7 @@ fn zirCmp(
42624262 const mod = sema.mod;
42634263
42644264 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
4265 const extra = sema.code.extraData(zir.Inst.Bin, inst_data.payload_index).data;
4265 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
42664266 const src: LazySrcLoc = inst_data.src();
42674267 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
42684268 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
......@@ -4356,7 +4356,7 @@ fn zirCmp(
43564356 return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs);
43574357}
43584358
4359fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4359fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
43604360 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
43614361 const src = inst_data.src();
43624362 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -4366,7 +4366,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!
43664366 return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size);
43674367}
43684368
4369fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4369fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
43704370 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
43714371 const src = inst_data.src();
43724372 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
......@@ -4376,20 +4376,20 @@ fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
43764376 return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), bit_size);
43774377}
43784378
4379fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4379fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
43804380 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
43814381 const src = inst_data.src();
43824382 return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeInfo", .{});
43834383}
43844384
4385fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4385fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
43864386 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
43874387 const src = inst_data.src();
43884388 const operand = try sema.resolveInst(inst_data.operand);
43894389 return sema.mod.constType(sema.arena, src, operand.ty);
43904390}
43914391
4392fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4392fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
43934393 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
43944394 const src = inst_data.src();
43954395 const operand_ptr = try sema.resolveInst(inst_data.operand);
......@@ -4397,13 +4397,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
43974397 return sema.mod.constType(sema.arena, src, elem_ty);
43984398}
43994399
4400fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4400fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
44014401 const tracy = trace(@src());
44024402 defer tracy.end();
44034403
44044404 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
44054405 const src = inst_data.src();
4406 const extra = sema.code.extraData(zir.Inst.MultiOp, inst_data.payload_index);
4406 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
44074407 const args = sema.code.refSlice(extra.end, extra.data.operands_len);
44084408
44094409 const inst_list = try sema.gpa.alloc(*ir.Inst, extra.data.operands_len);
......@@ -4417,7 +4417,7 @@ fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
44174417 return sema.mod.constType(sema.arena, src, result_type);
44184418}
44194419
4420fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4420fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
44214421 const tracy = trace(@src());
44224422 defer tracy.end();
44234423
......@@ -4437,7 +4437,7 @@ fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
44374437fn zirBoolOp(
44384438 sema: *Sema,
44394439 block: *Scope.Block,
4440 inst: zir.Inst.Index,
4440 inst: Zir.Inst.Index,
44414441 comptime is_bool_or: bool,
44424442) InnerError!*Inst {
44434443 const tracy = trace(@src());
......@@ -4468,7 +4468,7 @@ fn zirBoolOp(
44684468fn zirBoolBr(
44694469 sema: *Sema,
44704470 parent_block: *Scope.Block,
4471 inst: zir.Inst.Index,
4471 inst: Zir.Inst.Index,
44724472 is_bool_or: bool,
44734473) InnerError!*Inst {
44744474 const tracy = trace(@src());
......@@ -4478,7 +4478,7 @@ fn zirBoolBr(
44784478 const inst_data = datas[inst].bool_br;
44794479 const src: LazySrcLoc = .unneeded;
44804480 const lhs = try sema.resolveInst(inst_data.lhs);
4481 const extra = sema.code.extraData(zir.Inst.Block, inst_data.payload_index);
4481 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
44824482 const body = sema.code.extra[extra.end..][0..extra.data.body_len];
44834483
44844484 if (try sema.resolveDefinedValue(parent_block, src, lhs)) |lhs_val| {
......@@ -4536,7 +4536,7 @@ fn zirBoolBr(
45364536fn zirIsNull(
45374537 sema: *Sema,
45384538 block: *Scope.Block,
4539 inst: zir.Inst.Index,
4539 inst: Zir.Inst.Index,
45404540 invert_logic: bool,
45414541) InnerError!*Inst {
45424542 const tracy = trace(@src());
......@@ -4551,7 +4551,7 @@ fn zirIsNull(
45514551fn zirIsNullPtr(
45524552 sema: *Sema,
45534553 block: *Scope.Block,
4554 inst: zir.Inst.Index,
4554 inst: Zir.Inst.Index,
45554555 invert_logic: bool,
45564556) InnerError!*Inst {
45574557 const tracy = trace(@src());
......@@ -4564,7 +4564,7 @@ fn zirIsNullPtr(
45644564 return sema.analyzeIsNull(block, src, loaded, invert_logic);
45654565}
45664566
4567fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4567fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
45684568 const tracy = trace(@src());
45694569 defer tracy.end();
45704570
......@@ -4573,7 +4573,7 @@ fn zirIsErr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*
45734573 return sema.analyzeIsErr(block, inst_data.src(), operand);
45744574}
45754575
4576fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4576fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
45774577 const tracy = trace(@src());
45784578 defer tracy.end();
45794579
......@@ -4587,15 +4587,15 @@ fn zirIsErrPtr(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErro
45874587fn zirCondbr(
45884588 sema: *Sema,
45894589 parent_block: *Scope.Block,
4590 inst: zir.Inst.Index,
4591) InnerError!zir.Inst.Index {
4590 inst: Zir.Inst.Index,
4591) InnerError!Zir.Inst.Index {
45924592 const tracy = trace(@src());
45934593 defer tracy.end();
45944594
45954595 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
45964596 const src = inst_data.src();
45974597 const cond_src: LazySrcLoc = .{ .node_offset_if_cond = inst_data.src_node };
4598 const extra = sema.code.extraData(zir.Inst.CondBr, inst_data.payload_index);
4598 const extra = sema.code.extraData(Zir.Inst.CondBr, inst_data.payload_index);
45994599
46004600 const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len];
46014601 const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
......@@ -4628,7 +4628,7 @@ fn zirCondbr(
46284628 return always_noreturn;
46294629}
46304630
4631fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index {
4631fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
46324632 const tracy = trace(@src());
46334633 defer tracy.end();
46344634
......@@ -4648,9 +4648,9 @@ fn zirUnreachable(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerE
46484648fn zirRetTok(
46494649 sema: *Sema,
46504650 block: *Scope.Block,
4651 inst: zir.Inst.Index,
4651 inst: Zir.Inst.Index,
46524652 need_coercion: bool,
4653) InnerError!zir.Inst.Index {
4653) InnerError!Zir.Inst.Index {
46544654 const tracy = trace(@src());
46554655 defer tracy.end();
46564656
......@@ -4661,7 +4661,7 @@ fn zirRetTok(
46614661 return sema.analyzeRet(block, operand, src, need_coercion);
46624662}
46634663
4664fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!zir.Inst.Index {
4664fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index {
46654665 const tracy = trace(@src());
46664666 defer tracy.end();
46674667
......@@ -4678,7 +4678,7 @@ fn analyzeRet(
46784678 operand: *Inst,
46794679 src: LazySrcLoc,
46804680 need_coercion: bool,
4681) InnerError!zir.Inst.Index {
4681) InnerError!Zir.Inst.Index {
46824682 if (block.inlining) |inlining| {
46834683 // We are inlining a function call; rewrite the `ret` as a `break`.
46844684 try inlining.merges.results.append(sema.gpa, operand);
......@@ -4702,7 +4702,7 @@ fn analyzeRet(
47024702 return always_noreturn;
47034703}
47044704
4705fn floatOpAllowed(tag: zir.Inst.Tag) bool {
4705fn floatOpAllowed(tag: Zir.Inst.Tag) bool {
47064706 // extend this swich as additional operators are implemented
47074707 return switch (tag) {
47084708 .add, .sub => true,
......@@ -4710,7 +4710,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool {
47104710 };
47114711}
47124712
4713fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4713fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
47144714 const tracy = trace(@src());
47154715 defer tracy.end();
47164716
......@@ -4731,36 +4731,36 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) Inne
47314731 return sema.mod.constType(sema.arena, .unneeded, ty);
47324732}
47334733
4734fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4734fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
47354735 const tracy = trace(@src());
47364736 defer tracy.end();
47374737
47384738 const src: LazySrcLoc = .unneeded;
47394739 const inst_data = sema.code.instructions.items(.data)[inst].ptr_type;
4740 const extra = sema.code.extraData(zir.Inst.PtrType, inst_data.payload_index);
4740 const extra = sema.code.extraData(Zir.Inst.PtrType, inst_data.payload_index);
47414741
47424742 var extra_i = extra.end;
47434743
47444744 const sentinel = if (inst_data.flags.has_sentinel) blk: {
4745 const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]);
4745 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
47464746 extra_i += 1;
47474747 break :blk (try sema.resolveInstConst(block, .unneeded, ref)).val;
47484748 } else null;
47494749
47504750 const abi_align = if (inst_data.flags.has_align) blk: {
4751 const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]);
4751 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
47524752 extra_i += 1;
47534753 break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u32);
47544754 } else 0;
47554755
47564756 const bit_start = if (inst_data.flags.has_bit_range) blk: {
4757 const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]);
4757 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
47584758 extra_i += 1;
47594759 break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16);
47604760 } else 0;
47614761
47624762 const bit_end = if (inst_data.flags.has_bit_range) blk: {
4763 const ref = @intToEnum(zir.Inst.Ref, sema.code.extra[extra_i]);
4763 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
47644764 extra_i += 1;
47654765 break :blk try sema.resolveAlreadyCoercedInt(block, .unneeded, ref, u16);
47664766 } else 0;
......@@ -4785,7 +4785,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
47854785 return sema.mod.constType(sema.arena, src, ty);
47864786}
47874787
4788fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4788fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
47894789 const tracy = trace(@src());
47904790 defer tracy.end();
47914791
......@@ -4799,13 +4799,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) In
47994799 });
48004800}
48014801
4802fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4802fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
48034803 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
48044804 const src = inst_data.src();
48054805 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInit", .{});
48064806}
48074807
4808fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError!*Inst {
4808fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
48094809 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
48104810 const src = inst_data.src();
48114811 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldType", .{});
......@@ -4895,7 +4895,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id:
48954895 try parent_block.instructions.append(sema.gpa, &block_inst.base);
48964896}
48974897
4898fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !zir.Inst.Index {
4898fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index {
48994899 // TODO Once we have a panic function to call, call it here instead of breakpoint.
49004900 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
49014901 _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach);
src/zir.zig+88-89
......@@ -1,5 +1,14 @@
11//! Zig Intermediate Representation. Astgen.zig converts AST nodes to these
22//! untyped IR instructions. Next, Sema.zig processes these into TZIR.
3//! The minimum amount of information needed to represent a list of ZIR instructions.
4//! Once this structure is completed, it can be used to generate TZIR, followed by
5//! machine code, without any memory access into the AST tree token list, node list,
6//! or source bytes. Exceptions include:
7//! * Compile errors, which may need to reach into these data structures to
8//! create a useful report.
9//! * In the future, possibly inline assembly, which needs to get parsed and
10//! handled by the codegen backend, and errors reported there. However for now,
11//! inline assembly is not an exception.
312
413const std = @import("std");
514const mem = std.mem;
......@@ -9,6 +18,7 @@ const BigIntConst = std.math.big.int.Const;
918const BigIntMutable = std.math.big.int.Mutable;
1019const ast = std.zig.ast;
1120
21const Zir = @This();
1222const Type = @import("type.zig").Type;
1323const Value = @import("value.zig").Value;
1424const TypedValue = @import("TypedValue.zig");
......@@ -16,96 +26,85 @@ const ir = @import("ir.zig");
1626const Module = @import("Module.zig");
1727const LazySrcLoc = Module.LazySrcLoc;
1828
19/// The minimum amount of information needed to represent a list of ZIR instructions.
20/// Once this structure is completed, it can be used to generate TZIR, followed by
21/// machine code, without any memory access into the AST tree token list, node list,
22/// or source bytes. Exceptions include:
23/// * Compile errors, which may need to reach into these data structures to
24/// create a useful report.
25/// * In the future, possibly inline assembly, which needs to get parsed and
26/// handled by the codegen backend, and errors reported there. However for now,
27/// inline assembly is not an exception.
28pub const Code = struct {
29 /// There is always implicitly a `block` instruction at index 0.
30 /// This is so that `break_inline` can break from the root block.
31 instructions: std.MultiArrayList(Inst).Slice,
32 /// In order to store references to strings in fewer bytes, we copy all
33 /// string bytes into here. String bytes can be null. It is up to whomever
34 /// is referencing the data here whether they want to store both index and length,
35 /// thus allowing null bytes, or store only index, and use null-termination. The
36 /// `string_bytes` array is agnostic to either usage.
37 string_bytes: []u8,
38 /// The meaning of this data is determined by `Inst.Tag` value.
39 extra: []u32,
40
41 /// Returns the requested data, as well as the new index which is at the start of the
42 /// trailers for the object.
43 pub fn extraData(code: Code, comptime T: type, index: usize) struct { data: T, end: usize } {
44 const fields = std.meta.fields(T);
45 var i: usize = index;
46 var result: T = undefined;
47 inline for (fields) |field| {
48 @field(result, field.name) = switch (field.field_type) {
49 u32 => code.extra[i],
50 Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]),
51 else => unreachable,
52 };
53 i += 1;
54 }
55 return .{
56 .data = result,
57 .end = i,
29/// There is always implicitly a `block` instruction at index 0.
30/// This is so that `break_inline` can break from the root block.
31instructions: std.MultiArrayList(Inst).Slice,
32/// In order to store references to strings in fewer bytes, we copy all
33/// string bytes into here. String bytes can be null. It is up to whomever
34/// is referencing the data here whether they want to store both index and length,
35/// thus allowing null bytes, or store only index, and use null-termination. The
36/// `string_bytes` array is agnostic to either usage.
37string_bytes: []u8,
38/// The meaning of this data is determined by `Inst.Tag` value.
39extra: []u32,
40
41/// Returns the requested data, as well as the new index which is at the start of the
42/// trailers for the object.
43pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, end: usize } {
44 const fields = std.meta.fields(T);
45 var i: usize = index;
46 var result: T = undefined;
47 inline for (fields) |field| {
48 @field(result, field.name) = switch (field.field_type) {
49 u32 => code.extra[i],
50 Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]),
51 else => unreachable,
5852 };
53 i += 1;
5954 }
55 return .{
56 .data = result,
57 .end = i,
58 };
59}
6060
61 /// Given an index into `string_bytes` returns the null-terminated string found there.
62 pub fn nullTerminatedString(code: Code, index: usize) [:0]const u8 {
63 var end: usize = index;
64 while (code.string_bytes[end] != 0) {
65 end += 1;
66 }
67 return code.string_bytes[index..end :0];
68 }
69
70 pub fn refSlice(code: Code, start: usize, len: usize) []Inst.Ref {
71 const raw_slice = code.extra[start..][0..len];
72 return @bitCast([]Inst.Ref, raw_slice);
73 }
74
75 pub fn deinit(code: *Code, gpa: *Allocator) void {
76 code.instructions.deinit(gpa);
77 gpa.free(code.string_bytes);
78 gpa.free(code.extra);
79 code.* = undefined;
61/// Given an index into `string_bytes` returns the null-terminated string found there.
62pub fn nullTerminatedString(code: Zir, index: usize) [:0]const u8 {
63 var end: usize = index;
64 while (code.string_bytes[end] != 0) {
65 end += 1;
8066 }
67 return code.string_bytes[index..end :0];
68}
69
70pub fn refSlice(code: Zir, start: usize, len: usize) []Inst.Ref {
71 const raw_slice = code.extra[start..][0..len];
72 return @bitCast([]Inst.Ref, raw_slice);
73}
74
75pub fn deinit(code: *Zir, gpa: *Allocator) void {
76 code.instructions.deinit(gpa);
77 gpa.free(code.string_bytes);
78 gpa.free(code.extra);
79 code.* = undefined;
80}
81
82/// For debugging purposes, like dumpFn but for unanalyzed zir blocks
83pub fn dump(
84 code: Zir,
85 gpa: *Allocator,
86 kind: []const u8,
87 scope: *Module.Scope,
88 param_count: usize,
89) !void {
90 var arena = std.heap.ArenaAllocator.init(gpa);
91 defer arena.deinit();
92
93 var writer: Writer = .{
94 .gpa = gpa,
95 .arena = &arena.allocator,
96 .scope = scope,
97 .code = code,
98 .indent = 0,
99 .param_count = param_count,
100 };
81101
82 /// For debugging purposes, like dumpFn but for unanalyzed zir blocks
83 pub fn dump(
84 code: Code,
85 gpa: *Allocator,
86 kind: []const u8,
87 scope: *Module.Scope,
88 param_count: usize,
89 ) !void {
90 var arena = std.heap.ArenaAllocator.init(gpa);
91 defer arena.deinit();
92
93 var writer: Writer = .{
94 .gpa = gpa,
95 .arena = &arena.allocator,
96 .scope = scope,
97 .code = code,
98 .indent = 0,
99 .param_count = param_count,
100 };
101
102 const decl_name = scope.srcDecl().?.name;
103 const stderr = std.io.getStdErr().writer();
104 try stderr.print("ZIR {s} {s} %0 ", .{ kind, decl_name });
105 try writer.writeInstToStream(stderr, 0);
106 try stderr.print(" // end ZIR {s} {s}\n\n", .{ kind, decl_name });
107 }
108};
102 const decl_name = scope.srcDecl().?.name;
103 const stderr = std.io.getStdErr().writer();
104 try stderr.print("ZIR {s} {s} %0 ", .{ kind, decl_name });
105 try writer.writeInstToStream(stderr, 0);
106 try stderr.print(" // end ZIR {s} {s}\n\n", .{ kind, decl_name });
107}
109108
110109/// These are untyped instructions generated from an Abstract Syntax Tree.
111110/// The data here is immutable because it is possible to have multiple
......@@ -885,7 +884,7 @@ pub const Inst = struct {
885884 }
886885 };
887886
888 /// The position of a ZIR instruction within the `Code` instructions array.
887 /// The position of a ZIR instruction within the `Zir` instructions array.
889888 pub const Index = u32;
890889
891890 /// A reference to a TypedValue, parameter of the current function,
......@@ -1236,7 +1235,7 @@ pub const Inst = struct {
12361235 /// Number of bytes in the string.
12371236 len: u32,
12381237
1239 pub fn get(self: @This(), code: Code) []const u8 {
1238 pub fn get(self: @This(), code: Zir) []const u8 {
12401239 return code.string_bytes[self.start..][0..self.len];
12411240 }
12421241 },
......@@ -1257,7 +1256,7 @@ pub const Inst = struct {
12571256 /// Offset from Decl AST token index.
12581257 src_tok: u32,
12591258
1260 pub fn get(self: @This(), code: Code) [:0]const u8 {
1259 pub fn get(self: @This(), code: Zir) [:0]const u8 {
12611260 return code.nullTerminatedString(self.start);
12621261 }
12631262
......@@ -1609,7 +1608,7 @@ const Writer = struct {
16091608 gpa: *Allocator,
16101609 arena: *Allocator,
16111610 scope: *Module.Scope,
1612 code: Code,
1611 code: Zir,
16131612 indent: usize,
16141613 param_count: usize,
16151614