authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-23 22:40:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-23 22:40:57-07:00
log6b98384e20e738dceabaad38dab1be12375f2a3d
treec6836eb784d8c07e177f98ee8503b179236c2b65
parentfbfae832eaf520f7fcc632580b4b4a7fb171f90f

stage2: remove dead ZIR instructions

clearing up some enum tag space for future added instructions

3 files changed, 6 insertions(+), 37 deletions(-)

src/AstGen.zig-3
......@@ -1825,7 +1825,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
18251825 .int_big,
18261826 .float,
18271827 .float128,
1828 .intcast,
18291828 .int_type,
18301829 .is_non_null,
18311830 .is_null,
......@@ -1837,7 +1836,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
18371836 .mul,
18381837 .mulwrap,
18391838 .param_type,
1840 .ptrtoint,
18411839 .ref,
18421840 .shl,
18431841 .shr,
......@@ -2004,7 +2002,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
20042002 .condbr_inline,
20052003 .compile_error,
20062004 .ret_node,
2007 .ret_tok,
20082005 .ret_coerce,
20092006 .@"unreachable",
20102007 .store,
src/Sema.zig+2-17
......@@ -206,7 +206,6 @@ pub fn analyzeBody(
206206 .float => try sema.zirFloat(block, inst),
207207 .float128 => try sema.zirFloat128(block, inst),
208208 .int_type => try sema.zirIntType(block, inst),
209 .intcast => try sema.zirIntcast(block, inst),
210209 .is_err => try sema.zirIsErr(block, inst),
211210 .is_err_ptr => try sema.zirIsErrPtr(block, inst),
212211 .is_non_null => try sema.zirIsNull(block, inst, true),
......@@ -225,7 +224,6 @@ pub fn analyzeBody(
225224 .param_type => try sema.zirParamType(block, inst),
226225 .ptr_type => try sema.zirPtrType(block, inst),
227226 .ptr_type_simple => try sema.zirPtrTypeSimple(block, inst),
228 .ptrtoint => try sema.zirPtrtoint(block, inst),
229227 .ref => try sema.zirRef(block, inst),
230228 .shl => try sema.zirShl(block, inst),
231229 .shr => try sema.zirShr(block, inst),
......@@ -369,7 +367,6 @@ pub fn analyzeBody(
369367 .compile_error => return sema.zirCompileError(block, inst),
370368 .ret_coerce => return sema.zirRetTok(block, inst, true),
371369 .ret_node => return sema.zirRetNode(block, inst),
372 .ret_tok => return sema.zirRetTok(block, inst, false),
373370 .@"unreachable" => return sema.zirUnreachable(block, inst),
374371 .repeat => return sema.zirRepeat(block, inst),
375372 .panic => return sema.zirPanic(block, inst),
......@@ -2860,7 +2857,7 @@ fn analyzeAs(
28602857 return sema.coerce(block, dest_type, operand, src);
28612858}
28622859
2863fn zirPtrtoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2860fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
28642861 const tracy = trace(@src());
28652862 defer tracy.end();
28662863
......@@ -2936,7 +2933,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
29362933 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
29372934}
29382935
2939fn zirIntcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2936fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
29402937 const tracy = trace(@src());
29412938 defer tracy.end();
29422939
......@@ -5161,12 +5158,6 @@ fn zirFrameAddress(
51615158 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});
51625159}
51635160
5164fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5165 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5166 const src = inst_data.src();
5167 return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrToInt", .{});
5168}
5169
51705161fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
51715162 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
51725163 const src = inst_data.src();
......@@ -5245,12 +5236,6 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
52455236 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToPtr", .{});
52465237}
52475238
5248fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5249 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5250 const src = inst_data.src();
5251 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntCast", .{});
5252}
5253
52545239fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
52555240 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
52565241 const src = inst_data.src();
src/Zir.zig+4-17
......@@ -384,11 +384,6 @@ pub const Inst = struct {
384384 /// A float literal that fits in a f128. Uses the `pl_node` union value.
385385 /// Payload is `Float128`.
386386 float128,
387 /// Convert an integer value to another integer type, asserting that the destination type
388 /// can hold the same mathematical value.
389 /// Uses the `pl_node` field. AST is the `@intCast` syntax.
390 /// Payload is `Bin` with lhs as the dest type, rhs the operand.
391 intcast,
392387 /// Make an integer type out of signedness and bit count.
393388 /// Payload is `int_type`
394389 int_type,
......@@ -445,9 +440,6 @@ pub const Inst = struct {
445440 /// is not in a position where it must create an invalid type.
446441 /// Uses the `param_type` union field.
447442 param_type,
448 /// Convert a pointer to a `usize` integer.
449 /// Uses the `un_node` field. The AST node is the builtin fn call node.
450 ptrtoint,
451443 /// Turns an R-Value into a const L-Value. In other words, it takes a value,
452444 /// stores it in a memory location, and returns a const pointer to it. If the value
453445 /// is `comptime`, the memory location is global static constant data. Otherwise,
......@@ -464,9 +456,7 @@ pub const Inst = struct {
464456 /// Includes an operand as the return value.
465457 /// Includes a token source location.
466458 /// Uses the `un_tok` union field.
467 ret_tok,
468 /// Same as `ret_tok` except the operand needs to get coerced to the function's
469 /// return type.
459 /// The operand needs to get coerced to the function's return type.
470460 ret_coerce,
471461 /// Create a pointer type that does not have a sentinel, alignment, or bit range specified.
472462 /// Uses the `ptr_type_simple` union field.
......@@ -712,6 +702,7 @@ pub const Inst = struct {
712702 shl_with_overflow,
713703
714704 /// Implement builtin `@ptrToInt`. Uses `un_node`.
705 /// Convert a pointer to a `usize` integer.
715706 ptr_to_int,
716707 /// Implement builtin `@errToInt`. Uses `un_node`.
717708 error_to_int,
......@@ -801,6 +792,8 @@ pub const Inst = struct {
801792 float_cast,
802793 /// Implements the `@intCast` builtin.
803794 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
795 /// Convert an integer value to another integer type, asserting that the destination type
796 /// can hold the same mathematical value.
804797 int_cast,
805798 /// Implements the `@errSetCast` builtin.
806799 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
......@@ -1030,7 +1023,6 @@ pub const Inst = struct {
10301023 .int_big,
10311024 .float,
10321025 .float128,
1033 .intcast,
10341026 .int_type,
10351027 .is_non_null,
10361028 .is_null,
......@@ -1042,7 +1034,6 @@ pub const Inst = struct {
10421034 .mul,
10431035 .mulwrap,
10441036 .param_type,
1045 .ptrtoint,
10461037 .ref,
10471038 .shl,
10481039 .shr,
......@@ -1202,7 +1193,6 @@ pub const Inst = struct {
12021193 .condbr_inline,
12031194 .compile_error,
12041195 .ret_node,
1205 .ret_tok,
12061196 .ret_coerce,
12071197 .@"unreachable",
12081198 .repeat,
......@@ -2341,7 +2331,6 @@ const Writer = struct {
23412331 .coerce_result_ptr,
23422332 .elem_ptr,
23432333 .elem_val,
2344 .intcast,
23452334 .store,
23462335 .store_to_block_ptr,
23472336 .store_to_inferred_ptr,
......@@ -2362,7 +2351,6 @@ const Writer = struct {
23622351 .load,
23632352 .ensure_result_used,
23642353 .ensure_result_non_error,
2365 .ptrtoint,
23662354 .ret_node,
23672355 .resolve_inferred_alloc,
23682356 .optional_type,
......@@ -2432,7 +2420,6 @@ const Writer = struct {
24322420 => try self.writeUnNode(stream, inst),
24332421
24342422 .ref,
2435 .ret_tok,
24362423 .ret_coerce,
24372424 .ensure_err_payload_void,
24382425 => try self.writeUnTok(stream, inst),