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...@@ -1825,7 +1825,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
1825 .int_big,1825 .int_big,
1826 .float,1826 .float,
1827 .float128,1827 .float128,
1828 .intcast,
1829 .int_type,1828 .int_type,
1830 .is_non_null,1829 .is_non_null,
1831 .is_null,1830 .is_null,
...@@ -1837,7 +1836,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner...@@ -1837,7 +1836,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
1837 .mul,1836 .mul,
1838 .mulwrap,1837 .mulwrap,
1839 .param_type,1838 .param_type,
1840 .ptrtoint,
1841 .ref,1839 .ref,
1842 .shl,1840 .shl,
1843 .shr,1841 .shr,
...@@ -2004,7 +2002,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner...@@ -2004,7 +2002,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: ast.Node.Index) Inner
2004 .condbr_inline,2002 .condbr_inline,
2005 .compile_error,2003 .compile_error,
2006 .ret_node,2004 .ret_node,
2007 .ret_tok,
2008 .ret_coerce,2005 .ret_coerce,
2009 .@"unreachable",2006 .@"unreachable",
2010 .store,2007 .store,
src/Sema.zig+2-17
...@@ -206,7 +206,6 @@ pub fn analyzeBody(...@@ -206,7 +206,6 @@ pub fn analyzeBody(
206 .float => try sema.zirFloat(block, inst),206 .float => try sema.zirFloat(block, inst),
207 .float128 => try sema.zirFloat128(block, inst),207 .float128 => try sema.zirFloat128(block, inst),
208 .int_type => try sema.zirIntType(block, inst),208 .int_type => try sema.zirIntType(block, inst),
209 .intcast => try sema.zirIntcast(block, inst),
210 .is_err => try sema.zirIsErr(block, inst),209 .is_err => try sema.zirIsErr(block, inst),
211 .is_err_ptr => try sema.zirIsErrPtr(block, inst),210 .is_err_ptr => try sema.zirIsErrPtr(block, inst),
212 .is_non_null => try sema.zirIsNull(block, inst, true),211 .is_non_null => try sema.zirIsNull(block, inst, true),
...@@ -225,7 +224,6 @@ pub fn analyzeBody(...@@ -225,7 +224,6 @@ pub fn analyzeBody(
225 .param_type => try sema.zirParamType(block, inst),224 .param_type => try sema.zirParamType(block, inst),
226 .ptr_type => try sema.zirPtrType(block, inst),225 .ptr_type => try sema.zirPtrType(block, inst),
227 .ptr_type_simple => try sema.zirPtrTypeSimple(block, inst),226 .ptr_type_simple => try sema.zirPtrTypeSimple(block, inst),
228 .ptrtoint => try sema.zirPtrtoint(block, inst),
229 .ref => try sema.zirRef(block, inst),227 .ref => try sema.zirRef(block, inst),
230 .shl => try sema.zirShl(block, inst),228 .shl => try sema.zirShl(block, inst),
231 .shr => try sema.zirShr(block, inst),229 .shr => try sema.zirShr(block, inst),
...@@ -369,7 +367,6 @@ pub fn analyzeBody(...@@ -369,7 +367,6 @@ pub fn analyzeBody(
369 .compile_error => return sema.zirCompileError(block, inst),367 .compile_error => return sema.zirCompileError(block, inst),
370 .ret_coerce => return sema.zirRetTok(block, inst, true),368 .ret_coerce => return sema.zirRetTok(block, inst, true),
371 .ret_node => return sema.zirRetNode(block, inst),369 .ret_node => return sema.zirRetNode(block, inst),
372 .ret_tok => return sema.zirRetTok(block, inst, false),
373 .@"unreachable" => return sema.zirUnreachable(block, inst),370 .@"unreachable" => return sema.zirUnreachable(block, inst),
374 .repeat => return sema.zirRepeat(block, inst),371 .repeat => return sema.zirRepeat(block, inst),
375 .panic => return sema.zirPanic(block, inst),372 .panic => return sema.zirPanic(block, inst),
...@@ -2860,7 +2857,7 @@ fn analyzeAs(...@@ -2860,7 +2857,7 @@ fn analyzeAs(
2860 return sema.coerce(block, dest_type, operand, src);2857 return sema.coerce(block, dest_type, operand, src);
2861}2858}
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 {
2864 const tracy = trace(@src());2861 const tracy = trace(@src());
2865 defer tracy.end();2862 defer tracy.end();
28662863
...@@ -2936,7 +2933,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne...@@ -2936,7 +2933,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne
2936 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);2933 return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src);
2937}2934}
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 {
2940 const tracy = trace(@src());2937 const tracy = trace(@src());
2941 defer tracy.end();2938 defer tracy.end();
29422939
...@@ -5161,12 +5158,6 @@ fn zirFrameAddress(...@@ -5161,12 +5158,6 @@ fn zirFrameAddress(
5161 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});5158 return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{});
5162}5159}
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
5170fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5161fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5171 const inst_data = sema.code.instructions.items(.data)[inst].un_node;5162 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
5172 const src = inst_data.src();5163 const src = inst_data.src();
...@@ -5245,12 +5236,6 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro...@@ -5245,12 +5236,6 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro
5245 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToPtr", .{});5236 return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToPtr", .{});
5246}5237}
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
5254fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {5239fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5255 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;5240 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
5256 const src = inst_data.src();5241 const src = inst_data.src();
src/Zir.zig+4-17
...@@ -384,11 +384,6 @@ pub const Inst = struct {...@@ -384,11 +384,6 @@ pub const Inst = struct {
384 /// A float literal that fits in a f128. Uses the `pl_node` union value.384 /// A float literal that fits in a f128. Uses the `pl_node` union value.
385 /// Payload is `Float128`.385 /// Payload is `Float128`.
386 float128,386 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,
392 /// Make an integer type out of signedness and bit count.387 /// Make an integer type out of signedness and bit count.
393 /// Payload is `int_type`388 /// Payload is `int_type`
394 int_type,389 int_type,
...@@ -445,9 +440,6 @@ pub const Inst = struct {...@@ -445,9 +440,6 @@ pub const Inst = struct {
445 /// is not in a position where it must create an invalid type.440 /// is not in a position where it must create an invalid type.
446 /// Uses the `param_type` union field.441 /// Uses the `param_type` union field.
447 param_type,442 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,
451 /// Turns an R-Value into a const L-Value. In other words, it takes a value,443 /// Turns an R-Value into a const L-Value. In other words, it takes a value,
452 /// stores it in a memory location, and returns a const pointer to it. If the value444 /// stores it in a memory location, and returns a const pointer to it. If the value
453 /// is `comptime`, the memory location is global static constant data. Otherwise,445 /// is `comptime`, the memory location is global static constant data. Otherwise,
...@@ -464,9 +456,7 @@ pub const Inst = struct {...@@ -464,9 +456,7 @@ pub const Inst = struct {
464 /// Includes an operand as the return value.456 /// Includes an operand as the return value.
465 /// Includes a token source location.457 /// Includes a token source location.
466 /// Uses the `un_tok` union field.458 /// Uses the `un_tok` union field.
467 ret_tok,459 /// The operand needs to get coerced to the function's return type.
468 /// Same as `ret_tok` except the operand needs to get coerced to the function's
469 /// return type.
470 ret_coerce,460 ret_coerce,
471 /// Create a pointer type that does not have a sentinel, alignment, or bit range specified.461 /// Create a pointer type that does not have a sentinel, alignment, or bit range specified.
472 /// Uses the `ptr_type_simple` union field.462 /// Uses the `ptr_type_simple` union field.
...@@ -712,6 +702,7 @@ pub const Inst = struct {...@@ -712,6 +702,7 @@ pub const Inst = struct {
712 shl_with_overflow,702 shl_with_overflow,
713703
714 /// Implement builtin `@ptrToInt`. Uses `un_node`.704 /// Implement builtin `@ptrToInt`. Uses `un_node`.
705 /// Convert a pointer to a `usize` integer.
715 ptr_to_int,706 ptr_to_int,
716 /// Implement builtin `@errToInt`. Uses `un_node`.707 /// Implement builtin `@errToInt`. Uses `un_node`.
717 error_to_int,708 error_to_int,
...@@ -801,6 +792,8 @@ pub const Inst = struct {...@@ -801,6 +792,8 @@ pub const Inst = struct {
801 float_cast,792 float_cast,
802 /// Implements the `@intCast` builtin.793 /// Implements the `@intCast` builtin.
803 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.794 /// 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.
804 int_cast,797 int_cast,
805 /// Implements the `@errSetCast` builtin.798 /// Implements the `@errSetCast` builtin.
806 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.799 /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand.
...@@ -1030,7 +1023,6 @@ pub const Inst = struct {...@@ -1030,7 +1023,6 @@ pub const Inst = struct {
1030 .int_big,1023 .int_big,
1031 .float,1024 .float,
1032 .float128,1025 .float128,
1033 .intcast,
1034 .int_type,1026 .int_type,
1035 .is_non_null,1027 .is_non_null,
1036 .is_null,1028 .is_null,
...@@ -1042,7 +1034,6 @@ pub const Inst = struct {...@@ -1042,7 +1034,6 @@ pub const Inst = struct {
1042 .mul,1034 .mul,
1043 .mulwrap,1035 .mulwrap,
1044 .param_type,1036 .param_type,
1045 .ptrtoint,
1046 .ref,1037 .ref,
1047 .shl,1038 .shl,
1048 .shr,1039 .shr,
...@@ -1202,7 +1193,6 @@ pub const Inst = struct {...@@ -1202,7 +1193,6 @@ pub const Inst = struct {
1202 .condbr_inline,1193 .condbr_inline,
1203 .compile_error,1194 .compile_error,
1204 .ret_node,1195 .ret_node,
1205 .ret_tok,
1206 .ret_coerce,1196 .ret_coerce,
1207 .@"unreachable",1197 .@"unreachable",
1208 .repeat,1198 .repeat,
...@@ -2341,7 +2331,6 @@ const Writer = struct {...@@ -2341,7 +2331,6 @@ const Writer = struct {
2341 .coerce_result_ptr,2331 .coerce_result_ptr,
2342 .elem_ptr,2332 .elem_ptr,
2343 .elem_val,2333 .elem_val,
2344 .intcast,
2345 .store,2334 .store,
2346 .store_to_block_ptr,2335 .store_to_block_ptr,
2347 .store_to_inferred_ptr,2336 .store_to_inferred_ptr,
...@@ -2362,7 +2351,6 @@ const Writer = struct {...@@ -2362,7 +2351,6 @@ const Writer = struct {
2362 .load,2351 .load,
2363 .ensure_result_used,2352 .ensure_result_used,
2364 .ensure_result_non_error,2353 .ensure_result_non_error,
2365 .ptrtoint,
2366 .ret_node,2354 .ret_node,
2367 .resolve_inferred_alloc,2355 .resolve_inferred_alloc,
2368 .optional_type,2356 .optional_type,
...@@ -2432,7 +2420,6 @@ const Writer = struct {...@@ -2432,7 +2420,6 @@ const Writer = struct {
2432 => try self.writeUnNode(stream, inst),2420 => try self.writeUnNode(stream, inst),
24332421
2434 .ref,2422 .ref,
2435 .ret_tok,
2436 .ret_coerce,2423 .ret_coerce,
2437 .ensure_err_payload_void,2424 .ensure_err_payload_void,
2438 => try self.writeUnTok(stream, inst),2425 => try self.writeUnTok(stream, inst),