authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-04-29 12:23:46+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-04-30 01:06:01+03:00
log596f7df02e78adf334eed4a1f14eafa31ca611b9
treec2e3dc7082a0b0c8d870506820d10c708c906934
parent1d455896cb24165c5a3e0b3e10934c60a285589d

Zir: turn extended func into func_extended


5 files changed, 75 insertions(+), 80 deletions(-)

src/AstGen.zig+15-14
...@@ -72,6 +72,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {...@@ -72,6 +72,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
72 i32 => @bitCast(u32, @field(extra, field.name)),72 i32 => @bitCast(u32, @field(extra, field.name)),
73 Zir.Inst.Call.Flags => @bitCast(u32, @field(extra, field.name)),73 Zir.Inst.Call.Flags => @bitCast(u32, @field(extra, field.name)),
74 Zir.Inst.SwitchBlock.Bits => @bitCast(u32, @field(extra, field.name)),74 Zir.Inst.SwitchBlock.Bits => @bitCast(u32, @field(extra, field.name)),
75 Zir.Inst.ExtendedFunc.Bits => @bitCast(u32, @field(extra, field.name)),
75 else => @compileError("bad field type"),76 else => @compileError("bad field type"),
76 };77 };
77 i += 1;78 i += 1;
...@@ -2245,6 +2246,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner...@@ -2245,6 +2246,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
2245 .field_val_named,2246 .field_val_named,
2246 .func,2247 .func,
2247 .func_inferred,2248 .func_inferred,
2249 .func_extended,
2248 .int,2250 .int,
2249 .int_big,2251 .int_big,
2250 .float,2252 .float,
...@@ -10023,10 +10025,18 @@ const GenZir = struct {...@@ -10023,10 +10025,18 @@ const GenZir = struct {
10023 @boolToInt(args.cc != .none),10025 @boolToInt(args.cc != .none),
10024 );10026 );
10025 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{10027 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{
10026 .src_node = gz.nodeIndexToRelative(args.src_node),
10027 .param_block = args.param_block,10028 .param_block = args.param_block,
10028 .ret_body_len = @intCast(u32, ret_ty.len),10029 .ret_body_len = @intCast(u32, ret_ty.len),
10029 .body_len = @intCast(u32, body.len),10030 .body_len = @intCast(u32, body.len),
10031 .bits = .{
10032 .is_var_args = args.is_var_args,
10033 .is_inferred_error = args.is_inferred_error,
10034 .has_lib_name = args.lib_name != 0,
10035 .has_cc = args.cc != .none,
10036 .has_align = args.align_inst != .none,
10037 .is_test = args.is_test,
10038 .is_extern = args.is_extern,
10039 },
10030 });10040 });
10031 if (args.lib_name != 0) {10041 if (args.lib_name != 0) {
10032 astgen.extra.appendAssumeCapacity(args.lib_name);10042 astgen.extra.appendAssumeCapacity(args.lib_name);
...@@ -10050,19 +10060,10 @@ const GenZir = struct {...@@ -10050,19 +10060,10 @@ const GenZir = struct {
10050 astgen.instructions.items(.data)[args.ret_br].@"break".block_inst = new_index;10060 astgen.instructions.items(.data)[args.ret_br].@"break".block_inst = new_index;
10051 }10061 }
10052 astgen.instructions.appendAssumeCapacity(.{10062 astgen.instructions.appendAssumeCapacity(.{
10053 .tag = .extended,10063 .tag = .func_extended,
10054 .data = .{ .extended = .{10064 .data = .{ .pl_node = .{
10055 .opcode = .func,10065 .src_node = gz.nodeIndexToRelative(args.src_node),
10056 .small = @bitCast(u16, Zir.Inst.ExtendedFunc.Small{10066 .payload_index = payload_index,
10057 .is_var_args = args.is_var_args,
10058 .is_inferred_error = args.is_inferred_error,
10059 .has_lib_name = args.lib_name != 0,
10060 .has_cc = args.cc != .none,
10061 .has_align = args.align_inst != .none,
10062 .is_test = args.is_test,
10063 .is_extern = args.is_extern,
10064 }),
10065 .operand = payload_index,
10066 } },10067 } },
10067 });10068 });
10068 gz.instructions.appendAssumeCapacity(new_index);10069 gz.instructions.appendAssumeCapacity(new_index);
src/Module.zig+4-4
...@@ -1532,10 +1532,10 @@ pub const Fn = struct {...@@ -1532,10 +1532,10 @@ pub const Fn = struct {
1532 switch (zir_tags[func.zir_body_inst]) {1532 switch (zir_tags[func.zir_body_inst]) {
1533 .func => return false,1533 .func => return false,
1534 .func_inferred => return true,1534 .func_inferred => return true,
1535 .extended => {1535 .func_extended => {
1536 const extended = zir.instructions.items(.data)[func.zir_body_inst].extended;1536 const inst_data = zir.instructions.items(.data)[func.zir_body_inst].pl_node;
1537 const small = @bitCast(Zir.Inst.ExtendedFunc.Small, extended.small);1537 const extra = zir.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);
1538 return small.is_inferred_error;1538 return extra.data.bits.is_inferred_error;
1539 },1539 },
1540 else => unreachable,1540 else => unreachable,
1541 }1541 }
src/Sema.zig+14-18
...@@ -745,6 +745,7 @@ fn analyzeBodyInner(...@@ -745,6 +745,7 @@ fn analyzeBodyInner(
745 .field_call_bind => try sema.zirFieldCallBind(block, inst),745 .field_call_bind => try sema.zirFieldCallBind(block, inst),
746 .func => try sema.zirFunc(block, inst, false),746 .func => try sema.zirFunc(block, inst, false),
747 .func_inferred => try sema.zirFunc(block, inst, true),747 .func_inferred => try sema.zirFunc(block, inst, true),
748 .func_extended => try sema.zirFuncExtended(block, inst),
748 .import => try sema.zirImport(block, inst),749 .import => try sema.zirImport(block, inst),
749 .indexable_ptr_len => try sema.zirIndexablePtrLen(block, inst),750 .indexable_ptr_len => try sema.zirIndexablePtrLen(block, inst),
750 .int => try sema.zirInt(block, inst),751 .int => try sema.zirInt(block, inst),
...@@ -911,7 +912,6 @@ fn analyzeBodyInner(...@@ -911,7 +912,6 @@ fn analyzeBodyInner(
911 const extended = datas[inst].extended;912 const extended = datas[inst].extended;
912 break :ext switch (extended.opcode) {913 break :ext switch (extended.opcode) {
913 // zig fmt: off914 // zig fmt: off
914 .func => try sema.zirFuncExtended( block, extended, inst),
915 .variable => try sema.zirVarExtended( block, extended),915 .variable => try sema.zirVarExtended( block, extended),
916 .struct_decl => try sema.zirStructDecl( block, extended, inst),916 .struct_decl => try sema.zirStructDecl( block, extended, inst),
917 .enum_decl => try sema.zirEnumDecl( block, extended),917 .enum_decl => try sema.zirEnumDecl( block, extended),
...@@ -16099,37 +16099,33 @@ fn zirVarExtended(...@@ -16099,37 +16099,33 @@ fn zirVarExtended(
16099 return result;16099 return result;
16100}16100}
1610116101
16102fn zirFuncExtended(16102fn zirFuncExtended(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
16103 sema: *Sema,
16104 block: *Block,
16105 extended: Zir.Inst.Extended.InstData,
16106 inst: Zir.Inst.Index,
16107) CompileError!Air.Inst.Ref {
16108 const tracy = trace(@src());16103 const tracy = trace(@src());
16109 defer tracy.end();16104 defer tracy.end();
1611016105
16111 const extra = sema.code.extraData(Zir.Inst.ExtendedFunc, extended.operand);16106 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
16112 const src: LazySrcLoc = .{ .node_offset = extra.data.src_node };16107 const src = inst_data.src();
16113 const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = extra.data.src_node };16108 const extra = sema.code.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);
16109
16110 const cc_src: LazySrcLoc = .{ .node_offset_fn_type_cc = inst_data.src_node };
16114 const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align16111 const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align
16115 const small = @bitCast(Zir.Inst.ExtendedFunc.Small, extended.small);
1611616112
16117 var extra_index: usize = extra.end;16113 var extra_index: usize = extra.end;
1611816114
16119 const lib_name: ?[]const u8 = if (small.has_lib_name) blk: {16115 const lib_name: ?[]const u8 = if (extra.data.bits.has_lib_name) blk: {
16120 const lib_name = sema.code.nullTerminatedString(sema.code.extra[extra_index]);16116 const lib_name = sema.code.nullTerminatedString(sema.code.extra[extra_index]);
16121 extra_index += 1;16117 extra_index += 1;
16122 break :blk lib_name;16118 break :blk lib_name;
16123 } else null;16119 } else null;
1612416120
16125 const cc: std.builtin.CallingConvention = if (small.has_cc) blk: {16121 const cc: std.builtin.CallingConvention = if (extra.data.bits.has_cc) blk: {
16126 const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);16122 const cc_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
16127 extra_index += 1;16123 extra_index += 1;
16128 const cc_tv = try sema.resolveInstConst(block, cc_src, cc_ref);16124 const cc_tv = try sema.resolveInstConst(block, cc_src, cc_ref);
16129 break :blk cc_tv.val.toEnum(std.builtin.CallingConvention);16125 break :blk cc_tv.val.toEnum(std.builtin.CallingConvention);
16130 } else .Unspecified;16126 } else .Unspecified;
1613116127
16132 const align_val: Value = if (small.has_align) blk: {16128 const align_val: Value = if (extra.data.bits.has_align) blk: {
16133 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);16129 const align_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]);
16134 extra_index += 1;16130 extra_index += 1;
16135 const align_tv = try sema.resolveInstConst(block, align_src, align_ref);16131 const align_tv = try sema.resolveInstConst(block, align_src, align_ref);
...@@ -16146,13 +16142,13 @@ fn zirFuncExtended(...@@ -16146,13 +16142,13 @@ fn zirFuncExtended(
16146 src_locs = sema.code.extraData(Zir.Inst.Func.SrcLocs, extra_index).data;16142 src_locs = sema.code.extraData(Zir.Inst.Func.SrcLocs, extra_index).data;
16147 }16143 }
1614816144
16149 const is_var_args = small.is_var_args;16145 const is_var_args = extra.data.bits.is_var_args;
16150 const is_inferred_error = small.is_inferred_error;16146 const is_inferred_error = extra.data.bits.is_inferred_error;
16151 const is_extern = small.is_extern;16147 const is_extern = extra.data.bits.is_extern;
1615216148
16153 return sema.funcCommon(16149 return sema.funcCommon(
16154 block,16150 block,
16155 extra.data.src_node,16151 inst_data.src_node,
16156 inst,16152 inst,
16157 ret_ty_body,16153 ret_ty_body,
16158 cc,16154 cc,
src/Zir.zig+30-32
...@@ -73,6 +73,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en...@@ -73,6 +73,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en
73 i32 => @bitCast(i32, code.extra[i]),73 i32 => @bitCast(i32, code.extra[i]),
74 Inst.Call.Flags => @bitCast(Inst.Call.Flags, code.extra[i]),74 Inst.Call.Flags => @bitCast(Inst.Call.Flags, code.extra[i]),
75 Inst.SwitchBlock.Bits => @bitCast(Inst.SwitchBlock.Bits, code.extra[i]),75 Inst.SwitchBlock.Bits => @bitCast(Inst.SwitchBlock.Bits, code.extra[i]),
76 Inst.ExtendedFunc.Bits => @bitCast(Inst.ExtendedFunc.Bits, code.extra[i]),
76 else => @compileError("bad field type"),77 else => @compileError("bad field type"),
77 };78 };
78 i += 1;79 i += 1;
...@@ -415,6 +416,10 @@ pub const Inst = struct {...@@ -415,6 +416,10 @@ pub const Inst = struct {
415 func,416 func,
416 /// Same as `func` but has an inferred error set.417 /// Same as `func` but has an inferred error set.
417 func_inferred,418 func_inferred,
419 /// Represents a function declaration or function prototype, depending on
420 /// whether body_len is 0.
421 /// Uses the `pl_node` union field. `payload_index` points to a `ExtendedFunc`.
422 func_extended,
418 /// Implements the `@import` builtin.423 /// Implements the `@import` builtin.
419 /// Uses the `str_tok` field.424 /// Uses the `str_tok` field.
420 import,425 import,
...@@ -1062,6 +1067,7 @@ pub const Inst = struct {...@@ -1062,6 +1067,7 @@ pub const Inst = struct {
1062 .field_val_named,1067 .field_val_named,
1063 .func,1068 .func,
1064 .func_inferred,1069 .func_inferred,
1070 .func_extended,
1065 .has_decl,1071 .has_decl,
1066 .int,1072 .int,
1067 .int_big,1073 .int_big,
...@@ -1347,6 +1353,7 @@ pub const Inst = struct {...@@ -1347,6 +1353,7 @@ pub const Inst = struct {
1347 .field_val_named,1353 .field_val_named,
1348 .func,1354 .func,
1349 .func_inferred,1355 .func_inferred,
1356 .func_extended,
1350 .has_decl,1357 .has_decl,
1351 .int,1358 .int,
1352 .int_big,1359 .int_big,
...@@ -1601,6 +1608,7 @@ pub const Inst = struct {...@@ -1601,6 +1608,7 @@ pub const Inst = struct {
1601 .field_call_bind = .pl_node,1608 .field_call_bind = .pl_node,
1602 .func = .pl_node,1609 .func = .pl_node,
1603 .func_inferred = .pl_node,1610 .func_inferred = .pl_node,
1611 .func_extended = .pl_node,
1604 .import = .str_tok,1612 .import = .str_tok,
1605 .int = .int,1613 .int = .int,
1606 .int_big = .str,1614 .int_big = .str,
...@@ -1802,11 +1810,6 @@ pub const Inst = struct {...@@ -1802,11 +1810,6 @@ pub const Inst = struct {
1802 /// Rarer instructions are here; ones that do not fit in the 8-bit `Tag` enum.1810 /// Rarer instructions are here; ones that do not fit in the 8-bit `Tag` enum.
1803 /// `noreturn` instructions may not go here; they must be part of the main `Tag` enum.1811 /// `noreturn` instructions may not go here; they must be part of the main `Tag` enum.
1804 pub const Extended = enum(u16) {1812 pub const Extended = enum(u16) {
1805 /// Represents a function declaration or function prototype, depending on
1806 /// whether body_len is 0.
1807 /// `operand` is payload index to `ExtendedFunc`.
1808 /// `small` is `ExtendedFunc.Small`.
1809 func,
1810 /// Declares a global variable.1813 /// Declares a global variable.
1811 /// `operand` is payload index to `ExtendedVar`.1814 /// `operand` is payload index to `ExtendedVar`.
1812 /// `small` is `ExtendedVar.Small`.1815 /// `small` is `ExtendedVar.Small`.
...@@ -2621,14 +2624,14 @@ pub const Inst = struct {...@@ -2621,14 +2624,14 @@ pub const Inst = struct {
2621 /// 4. body: Index // for each body_len2624 /// 4. body: Index // for each body_len
2622 /// 5. src_locs: Func.SrcLocs // if body_len != 02625 /// 5. src_locs: Func.SrcLocs // if body_len != 0
2623 pub const ExtendedFunc = struct {2626 pub const ExtendedFunc = struct {
2624 src_node: i32,
2625 /// If this is 0 it means a void return type.2627 /// If this is 0 it means a void return type.
2626 ret_body_len: u32,2628 ret_body_len: u32,
2627 /// Points to the block that contains the param instructions for this function.2629 /// Points to the block that contains the param instructions for this function.
2628 param_block: Index,2630 param_block: Index,
2629 body_len: u32,2631 body_len: u32,
2632 bits: Bits,
26302633
2631 pub const Small = packed struct {2634 pub const Bits = packed struct {
2632 is_var_args: bool,2635 is_var_args: bool,
2633 is_inferred_error: bool,2636 is_inferred_error: bool,
2634 has_lib_name: bool,2637 has_lib_name: bool,
...@@ -2636,7 +2639,7 @@ pub const Inst = struct {...@@ -2636,7 +2639,7 @@ pub const Inst = struct {
2636 has_align: bool,2639 has_align: bool,
2637 is_test: bool,2640 is_test: bool,
2638 is_extern: bool,2641 is_extern: bool,
2639 _: u9 = undefined,2642 _: u25 = undefined,
2640 };2643 };
2641 };2644 };
26422645
...@@ -3460,14 +3463,11 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {...@@ -3460,14 +3463,11 @@ pub fn declIterator(zir: Zir, decl_inst: u32) DeclIterator {
3460 switch (tags[decl_inst]) {3463 switch (tags[decl_inst]) {
3461 // Functions are allowed and yield no iterations.3464 // Functions are allowed and yield no iterations.
3462 // There is one case matching this in the extended instruction set below.3465 // There is one case matching this in the extended instruction set below.
3463 .func,3466 .func, .func_inferred, .func_extended => return declIteratorInner(zir, 0, 0),
3464 .func_inferred,
3465 => return declIteratorInner(zir, 0, 0),
34663467
3467 .extended => {3468 .extended => {
3468 const extended = datas[decl_inst].extended;3469 const extended = datas[decl_inst].extended;
3469 switch (extended.opcode) {3470 switch (extended.opcode) {
3470 .func => return declIteratorInner(zir, 0, 0),
3471 .struct_decl => {3471 .struct_decl => {
3472 const small = @bitCast(Inst.StructDecl.Small, extended.small);3472 const small = @bitCast(Inst.StructDecl.Small, extended.small);
3473 var extra_index: usize = extended.operand;3473 var extra_index: usize = extended.operand;
...@@ -3572,21 +3572,21 @@ fn findDeclsInner(...@@ -3572,21 +3572,21 @@ fn findDeclsInner(
3572 const body = zir.extra[extra.end..][0..extra.data.body_len];3572 const body = zir.extra[extra.end..][0..extra.data.body_len];
3573 return zir.findDeclsBody(list, body);3573 return zir.findDeclsBody(list, body);
3574 },3574 },
3575 .func_extended => {
3576 try list.append(inst);
3577
3578 const inst_data = datas[inst].pl_node;
3579 const extra = zir.extraData(Inst.ExtendedFunc, inst_data.payload_index);
3580 var extra_index: usize = extra.end;
3581 extra_index += @boolToInt(extra.data.bits.has_lib_name);
3582 extra_index += @boolToInt(extra.data.bits.has_cc);
3583 extra_index += @boolToInt(extra.data.bits.has_align);
3584 const body = zir.extra[extra_index..][0..extra.data.body_len];
3585 return zir.findDeclsBody(list, body);
3586 },
3575 .extended => {3587 .extended => {
3576 const extended = datas[inst].extended;3588 const extended = datas[inst].extended;
3577 switch (extended.opcode) {3589 switch (extended.opcode) {
3578 .func => {
3579 try list.append(inst);
3580
3581 const extra = zir.extraData(Inst.ExtendedFunc, extended.operand);
3582 const small = @bitCast(Inst.ExtendedFunc.Small, extended.small);
3583 var extra_index: usize = extra.end;
3584 extra_index += @boolToInt(small.has_lib_name);
3585 extra_index += @boolToInt(small.has_cc);
3586 extra_index += @boolToInt(small.has_align);
3587 const body = zir.extra[extra_index..][0..extra.data.body_len];
3588 return zir.findDeclsBody(list, body);
3589 },
35903590
3591 // Decl instructions are interesting but have no body.3591 // Decl instructions are interesting but have no body.
3592 // TODO yes they do have a body actually. recurse over them just like block instructions.3592 // TODO yes they do have a body actually. recurse over them just like block instructions.
...@@ -3733,15 +3733,13 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {...@@ -3733,15 +3733,13 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo {
3733 .body = body,3733 .body = body,
3734 };3734 };
3735 },3735 },
3736 .extended => blk: {3736 .func_extended => blk: {
3737 const extended = datas[fn_inst].extended;3737 const inst_data = datas[fn_inst].pl_node;
3738 assert(extended.opcode == .func);3738 const extra = zir.extraData(Inst.ExtendedFunc, inst_data.payload_index);
3739 const extra = zir.extraData(Inst.ExtendedFunc, extended.operand);
3740 const small = @bitCast(Inst.ExtendedFunc.Small, extended.small);
3741 var extra_index: usize = extra.end;3739 var extra_index: usize = extra.end;
3742 extra_index += @boolToInt(small.has_lib_name);3740 extra_index += @boolToInt(extra.data.bits.has_lib_name);
3743 extra_index += @boolToInt(small.has_cc);3741 extra_index += @boolToInt(extra.data.bits.has_cc);
3744 extra_index += @boolToInt(small.has_align);3742 extra_index += @boolToInt(extra.data.bits.has_align);
3745 const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len];3743 const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len];
3746 extra_index += ret_ty_body.len;3744 extra_index += ret_ty_body.len;
3747 const body = zir.extra[extra_index..][0..extra.data.body_len];3745 const body = zir.extra[extra_index..][0..extra.data.body_len];
src/print_zir.zig+12-12
...@@ -429,6 +429,7 @@ const Writer = struct {...@@ -429,6 +429,7 @@ const Writer = struct {
429429
430 .func => try self.writeFunc(stream, inst, false),430 .func => try self.writeFunc(stream, inst, false),
431 .func_inferred => try self.writeFunc(stream, inst, true),431 .func_inferred => try self.writeFunc(stream, inst, true),
432 .func_extended => try self.writeFuncExtended(stream, inst),
432433
433 .@"unreachable" => try self.writeUnreachable(stream, inst),434 .@"unreachable" => try self.writeUnreachable(stream, inst),
434435
...@@ -469,7 +470,6 @@ const Writer = struct {...@@ -469,7 +470,6 @@ const Writer = struct {
469 },470 },
470471
471 .@"asm" => try self.writeAsm(stream, extended),472 .@"asm" => try self.writeAsm(stream, extended),
472 .func => try self.writeFuncExtended(stream, extended),
473 .variable => try self.writeVarExtended(stream, extended),473 .variable => try self.writeVarExtended(stream, extended),
474 .alloc => try self.writeAllocExtended(stream, extended),474 .alloc => try self.writeAllocExtended(stream, extended),
475475
...@@ -1920,24 +1920,24 @@ const Writer = struct {...@@ -1920,24 +1920,24 @@ const Writer = struct {
1920 );1920 );
1921 }1921 }
19221922
1923 fn writeFuncExtended(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1923 fn writeFuncExtended(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
1924 const extra = self.code.extraData(Zir.Inst.ExtendedFunc, extended.operand);1924 const inst_data = self.code.instructions.items(.data)[inst].pl_node;
1925 const src: LazySrcLoc = .{ .node_offset = extra.data.src_node };1925 const extra = self.code.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);
1926 const small = @bitCast(Zir.Inst.ExtendedFunc.Small, extended.small);1926 const src = inst_data.src();
19271927
1928 var extra_index: usize = extra.end;1928 var extra_index: usize = extra.end;
1929 if (small.has_lib_name) {1929 if (extra.data.bits.has_lib_name) {
1930 const lib_name = self.code.nullTerminatedString(self.code.extra[extra_index]);1930 const lib_name = self.code.nullTerminatedString(self.code.extra[extra_index]);
1931 extra_index += 1;1931 extra_index += 1;
1932 try stream.print("lib_name=\"{}\", ", .{std.zig.fmtEscapes(lib_name)});1932 try stream.print("lib_name=\"{}\", ", .{std.zig.fmtEscapes(lib_name)});
1933 }1933 }
1934 try self.writeFlag(stream, "test, ", small.is_test);1934 try self.writeFlag(stream, "test, ", extra.data.bits.is_test);
1935 const cc: Zir.Inst.Ref = if (!small.has_cc) .none else blk: {1935 const cc: Zir.Inst.Ref = if (!extra.data.bits.has_cc) .none else blk: {
1936 const cc = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);1936 const cc = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1937 extra_index += 1;1937 extra_index += 1;
1938 break :blk cc;1938 break :blk cc;
1939 };1939 };
1940 const align_inst: Zir.Inst.Ref = if (!small.has_align) .none else blk: {1940 const align_inst: Zir.Inst.Ref = if (!extra.data.bits.has_align) .none else blk: {
1941 const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);1941 const align_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1942 extra_index += 1;1942 extra_index += 1;
1943 break :blk align_inst;1943 break :blk align_inst;
...@@ -1956,9 +1956,9 @@ const Writer = struct {...@@ -1956,9 +1956,9 @@ const Writer = struct {
1956 return self.writeFuncCommon(1956 return self.writeFuncCommon(
1957 stream,1957 stream,
1958 ret_ty_body,1958 ret_ty_body,
1959 small.is_inferred_error,1959 extra.data.bits.is_inferred_error,
1960 small.is_var_args,1960 extra.data.bits.is_var_args,
1961 small.is_extern,1961 extra.data.bits.is_extern,
1962 cc,1962 cc,
1963 align_inst,1963 align_inst,
1964 body,1964 body,