| author | |
| committer | |
| log | ae495de54d6aed6efbfc727f66154216b15225af |
| tree | 875de98aa0bcca806fb0ccc901203cb53ec0656a |
| parent | 5a3045b5de03fade87ccbb4191344861374ea0a4 |
7 files changed, 2185 insertions(+), 430 deletions(-)
BRANCH_TODO-2| ... | @@ -737,5 +737,3 @@ fn errorSetDecl( | ... | @@ -737,5 +737,3 @@ fn errorSetDecl( |
| 737 | try mod.analyzeExport(&decl_scope.base, export_src, name, decl); | 737 | try mod.analyzeExport(&decl_scope.base, export_src, name, decl); |
| 738 | } | 738 | } |
| 739 | } | 739 | } |
| 740 | |||
| 741 |
src/AstGen.zig+670-227| ... | @@ -51,6 +51,7 @@ pub fn addExtraAssumeCapacity(astgen: *AstGen, extra: anytype) u32 { | ... | @@ -51,6 +51,7 @@ pub fn addExtraAssumeCapacity(astgen: *AstGen, extra: anytype) u32 { |
| 51 | astgen.extra.appendAssumeCapacity(switch (field.field_type) { | 51 | astgen.extra.appendAssumeCapacity(switch (field.field_type) { |
| 52 | u32 => @field(extra, field.name), | 52 | u32 => @field(extra, field.name), |
| 53 | Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), | 53 | Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 54 | i32 => @bitCast(u32, @field(extra, field.name)), | ||
| 54 | else => @compileError("bad field type"), | 55 | else => @compileError("bad field type"), |
| 55 | }); | 56 | }); |
| 56 | } | 57 | } |
| ... | @@ -237,6 +238,9 @@ pub const ResultLoc = union(enum) { | ... | @@ -237,6 +238,9 @@ pub const ResultLoc = union(enum) { |
| 237 | } | 238 | } |
| 238 | }; | 239 | }; |
| 239 | 240 | ||
| 241 | pub const align_rl: ResultLoc = .{ .ty = .u16_type }; | ||
| 242 | pub const bool_rl: ResultLoc = .{ .ty = .bool_type }; | ||
| 243 | |||
| 240 | pub fn typeExpr(gz: *GenZir, scope: *Scope, type_node: ast.Node.Index) InnerError!Zir.Inst.Ref { | 244 | pub fn typeExpr(gz: *GenZir, scope: *Scope, type_node: ast.Node.Index) InnerError!Zir.Inst.Ref { |
| 241 | return expr(gz, scope, .{ .ty = .type_type }, type_node); | 245 | return expr(gz, scope, .{ .ty = .type_type }, type_node); |
| 242 | } | 246 | } |
| ... | @@ -469,20 +473,22 @@ pub fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inn | ... | @@ -469,20 +473,22 @@ pub fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inn |
| 469 | try assign(gz, scope, node); | 473 | try assign(gz, scope, node); |
| 470 | return rvalue(gz, scope, rl, .void_value, node); | 474 | return rvalue(gz, scope, rl, .void_value, node); |
| 471 | }, | 475 | }, |
| 472 | .assign_bit_and => { | 476 | |
| 473 | try assignOp(gz, scope, node, .bit_and); | 477 | .assign_bit_shift_left => { |
| 478 | try assignShift(gz, scope, node, .shl); | ||
| 474 | return rvalue(gz, scope, rl, .void_value, node); | 479 | return rvalue(gz, scope, rl, .void_value, node); |
| 475 | }, | 480 | }, |
| 476 | .assign_bit_or => { | 481 | .assign_bit_shift_right => { |
| 477 | try assignOp(gz, scope, node, .bit_or); | 482 | try assignShift(gz, scope, node, .shr); |
| 478 | return rvalue(gz, scope, rl, .void_value, node); | 483 | return rvalue(gz, scope, rl, .void_value, node); |
| 479 | }, | 484 | }, |
| 480 | .assign_bit_shift_left => { | 485 | |
| 481 | try assignOp(gz, scope, node, .shl); | 486 | .assign_bit_and => { |
| 487 | try assignOp(gz, scope, node, .bit_and); | ||
| 482 | return rvalue(gz, scope, rl, .void_value, node); | 488 | return rvalue(gz, scope, rl, .void_value, node); |
| 483 | }, | 489 | }, |
| 484 | .assign_bit_shift_right => { | 490 | .assign_bit_or => { |
| 485 | try assignOp(gz, scope, node, .shr); | 491 | try assignOp(gz, scope, node, .bit_or); |
| 486 | return rvalue(gz, scope, rl, .void_value, node); | 492 | return rvalue(gz, scope, rl, .void_value, node); |
| 487 | }, | 493 | }, |
| 488 | .assign_bit_xor => { | 494 | .assign_bit_xor => { |
| ... | @@ -522,51 +528,54 @@ pub fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inn | ... | @@ -522,51 +528,54 @@ pub fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inn |
| 522 | return rvalue(gz, scope, rl, .void_value, node); | 528 | return rvalue(gz, scope, rl, .void_value, node); |
| 523 | }, | 529 | }, |
| 524 | 530 | ||
| 525 | .add => return simpleBinOp(gz, scope, rl, node, .add), | 531 | // zig fmt: off |
| 532 | .bit_shift_left => return shiftOp(gz, scope, rl, node, node_datas[node].lhs, node_datas[node].rhs, .shl), | ||
| 533 | .bit_shift_right => return shiftOp(gz, scope, rl, node, node_datas[node].lhs, node_datas[node].rhs, .shr), | ||
| 534 | |||
| 535 | .add => return simpleBinOp(gz, scope, rl, node, .add), | ||
| 526 | .add_wrap => return simpleBinOp(gz, scope, rl, node, .addwrap), | 536 | .add_wrap => return simpleBinOp(gz, scope, rl, node, .addwrap), |
| 527 | .sub => return simpleBinOp(gz, scope, rl, node, .sub), | 537 | .sub => return simpleBinOp(gz, scope, rl, node, .sub), |
| 528 | .sub_wrap => return simpleBinOp(gz, scope, rl, node, .subwrap), | 538 | .sub_wrap => return simpleBinOp(gz, scope, rl, node, .subwrap), |
| 529 | .mul => return simpleBinOp(gz, scope, rl, node, .mul), | 539 | .mul => return simpleBinOp(gz, scope, rl, node, .mul), |
| 530 | .mul_wrap => return simpleBinOp(gz, scope, rl, node, .mulwrap), | 540 | .mul_wrap => return simpleBinOp(gz, scope, rl, node, .mulwrap), |
| 531 | .div => return simpleBinOp(gz, scope, rl, node, .div), | 541 | .div => return simpleBinOp(gz, scope, rl, node, .div), |
| 532 | .mod => return simpleBinOp(gz, scope, rl, node, .mod_rem), | 542 | .mod => return simpleBinOp(gz, scope, rl, node, .mod_rem), |
| 533 | .bit_and => return simpleBinOp(gz, scope, rl, node, .bit_and), | 543 | .bit_and => return simpleBinOp(gz, scope, rl, node, .bit_and), |
| 534 | .bit_or => return simpleBinOp(gz, scope, rl, node, .bit_or), | 544 | .bit_or => return simpleBinOp(gz, scope, rl, node, .bit_or), |
| 535 | .bit_shift_left => return simpleBinOp(gz, scope, rl, node, .shl), | 545 | .bit_xor => return simpleBinOp(gz, scope, rl, node, .xor), |
| 536 | .bit_shift_right => return simpleBinOp(gz, scope, rl, node, .shr), | 546 | |
| 537 | .bit_xor => return simpleBinOp(gz, scope, rl, node, .xor), | 547 | .bang_equal => return simpleBinOp(gz, scope, rl, node, .cmp_neq), |
| 538 | 548 | .equal_equal => return simpleBinOp(gz, scope, rl, node, .cmp_eq), | |
| 539 | .bang_equal => return simpleBinOp(gz, scope, rl, node, .cmp_neq), | 549 | .greater_than => return simpleBinOp(gz, scope, rl, node, .cmp_gt), |
| 540 | .equal_equal => return simpleBinOp(gz, scope, rl, node, .cmp_eq), | ||
| 541 | .greater_than => return simpleBinOp(gz, scope, rl, node, .cmp_gt), | ||
| 542 | .greater_or_equal => return simpleBinOp(gz, scope, rl, node, .cmp_gte), | 550 | .greater_or_equal => return simpleBinOp(gz, scope, rl, node, .cmp_gte), |
| 543 | .less_than => return simpleBinOp(gz, scope, rl, node, .cmp_lt), | 551 | .less_than => return simpleBinOp(gz, scope, rl, node, .cmp_lt), |
| 544 | .less_or_equal => return simpleBinOp(gz, scope, rl, node, .cmp_lte), | 552 | .less_or_equal => return simpleBinOp(gz, scope, rl, node, .cmp_lte), |
| 545 | 553 | ||
| 546 | .array_cat => return simpleBinOp(gz, scope, rl, node, .array_cat), | 554 | .array_cat => return simpleBinOp(gz, scope, rl, node, .array_cat), |
| 547 | .array_mult => return simpleBinOp(gz, scope, rl, node, .array_mul), | 555 | .array_mult => return simpleBinOp(gz, scope, rl, node, .array_mul), |
| 548 | 556 | ||
| 549 | .error_union => return simpleBinOp(gz, scope, rl, node, .error_union_type), | 557 | .error_union => return simpleBinOp(gz, scope, rl, node, .error_union_type), |
| 550 | .merge_error_sets => return simpleBinOp(gz, scope, rl, node, .merge_error_sets), | 558 | .merge_error_sets => return simpleBinOp(gz, scope, rl, node, .merge_error_sets), |
| 551 | 559 | ||
| 552 | .bool_and => return boolBinOp(gz, scope, rl, node, .bool_br_and), | 560 | .bool_and => return boolBinOp(gz, scope, rl, node, .bool_br_and), |
| 553 | .bool_or => return boolBinOp(gz, scope, rl, node, .bool_br_or), | 561 | .bool_or => return boolBinOp(gz, scope, rl, node, .bool_br_or), |
| 554 | 562 | ||
| 555 | .bool_not => return boolNot(gz, scope, rl, node), | 563 | .bool_not => return boolNot(gz, scope, rl, node), |
| 556 | .bit_not => return bitNot(gz, scope, rl, node), | 564 | .bit_not => return bitNot(gz, scope, rl, node), |
| 557 | 565 | ||
| 558 | .negation => return negation(gz, scope, rl, node, .negate), | 566 | .negation => return negation(gz, scope, rl, node, .negate), |
| 559 | .negation_wrap => return negation(gz, scope, rl, node, .negate_wrap), | 567 | .negation_wrap => return negation(gz, scope, rl, node, .negate_wrap), |
| 560 | 568 | ||
| 561 | .identifier => return identifier(gz, scope, rl, node), | 569 | .identifier => return identifier(gz, scope, rl, node), |
| 562 | 570 | ||
| 563 | .asm_simple => return asmExpr(gz, scope, rl, node, tree.asmSimple(node)), | 571 | .asm_simple => return asmExpr(gz, scope, rl, node, tree.asmSimple(node)), |
| 564 | .@"asm" => return asmExpr(gz, scope, rl, node, tree.asmFull(node)), | 572 | .@"asm" => return asmExpr(gz, scope, rl, node, tree.asmFull(node)), |
| 565 | 573 | ||
| 566 | .string_literal => return stringLiteral(gz, scope, rl, node), | 574 | .string_literal => return stringLiteral(gz, scope, rl, node), |
| 567 | .multiline_string_literal => return multilineStringLiteral(gz, scope, rl, node), | 575 | .multiline_string_literal => return multilineStringLiteral(gz, scope, rl, node), |
| 568 | 576 | ||
| 569 | .integer_literal => return integerLiteral(gz, scope, rl, node), | 577 | .integer_literal => return integerLiteral(gz, scope, rl, node), |
| 578 | // zig fmt: on | ||
| 570 | 579 | ||
| 571 | .builtin_call_two, .builtin_call_two_comma => { | 580 | .builtin_call_two, .builtin_call_two_comma => { |
| 572 | if (node_datas[node].lhs == 0) { | 581 | if (node_datas[node].lhs == 0) { |
| ... | @@ -1181,13 +1190,14 @@ fn labeledBlockExpr( | ... | @@ -1181,13 +1190,14 @@ fn labeledBlockExpr( |
| 1181 | // All break operands are values that did not use the result location pointer. | 1190 | // All break operands are values that did not use the result location pointer. |
| 1182 | if (strat.elide_store_to_block_ptr_instructions) { | 1191 | if (strat.elide_store_to_block_ptr_instructions) { |
| 1183 | for (block_scope.labeled_store_to_block_ptr_list.items) |inst| { | 1192 | for (block_scope.labeled_store_to_block_ptr_list.items) |inst| { |
| 1184 | zir_tags[inst] = .elided; | 1193 | // Mark as elided for removal below. |
| 1185 | zir_datas[inst] = undefined; | 1194 | assert(zir_tags[inst] == .store_to_block_ptr); |
| 1195 | zir_datas[inst].bin.lhs = .none; | ||
| 1186 | } | 1196 | } |
| 1187 | // TODO technically not needed since we changed the tag to elided but | 1197 | try block_scope.setBlockBodyEliding(block_inst); |
| 1188 | // would be better still to elide the ones that are in this list. | 1198 | } else { |
| 1199 | try block_scope.setBlockBody(block_inst); | ||
| 1189 | } | 1200 | } |
| 1190 | try block_scope.setBlockBody(block_inst); | ||
| 1191 | const block_ref = gz.indexToRef(block_inst); | 1201 | const block_ref = gz.indexToRef(block_inst); |
| 1192 | switch (rl) { | 1202 | switch (rl) { |
| 1193 | .ref => return block_ref, | 1203 | .ref => return block_ref, |
| ... | @@ -1222,20 +1232,24 @@ fn blockExprStmts( | ... | @@ -1222,20 +1232,24 @@ fn blockExprStmts( |
| 1222 | .simple_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.simpleVarDecl(statement)), | 1232 | .simple_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.simpleVarDecl(statement)), |
| 1223 | .aligned_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.alignedVarDecl(statement)), | 1233 | .aligned_var_decl => scope = try varDecl(gz, scope, statement, &block_arena.allocator, tree.alignedVarDecl(statement)), |
| 1224 | 1234 | ||
| 1235 | // zig fmt: off | ||
| 1225 | .assign => try assign(gz, scope, statement), | 1236 | .assign => try assign(gz, scope, statement), |
| 1226 | .assign_bit_and => try assignOp(gz, scope, statement, .bit_and), | 1237 | |
| 1227 | .assign_bit_or => try assignOp(gz, scope, statement, .bit_or), | 1238 | .assign_bit_shift_left => try assignShift(gz, scope, statement, .shl), |
| 1228 | .assign_bit_shift_left => try assignOp(gz, scope, statement, .shl), | 1239 | .assign_bit_shift_right => try assignShift(gz, scope, statement, .shr), |
| 1229 | .assign_bit_shift_right => try assignOp(gz, scope, statement, .shr), | 1240 | |
| 1230 | .assign_bit_xor => try assignOp(gz, scope, statement, .xor), | 1241 | .assign_bit_and => try assignOp(gz, scope, statement, .bit_and), |
| 1231 | .assign_div => try assignOp(gz, scope, statement, .div), | 1242 | .assign_bit_or => try assignOp(gz, scope, statement, .bit_or), |
| 1232 | .assign_sub => try assignOp(gz, scope, statement, .sub), | 1243 | .assign_bit_xor => try assignOp(gz, scope, statement, .xor), |
| 1244 | .assign_div => try assignOp(gz, scope, statement, .div), | ||
| 1245 | .assign_sub => try assignOp(gz, scope, statement, .sub), | ||
| 1233 | .assign_sub_wrap => try assignOp(gz, scope, statement, .subwrap), | 1246 | .assign_sub_wrap => try assignOp(gz, scope, statement, .subwrap), |
| 1234 | .assign_mod => try assignOp(gz, scope, statement, .mod_rem), | 1247 | .assign_mod => try assignOp(gz, scope, statement, .mod_rem), |
| 1235 | .assign_add => try assignOp(gz, scope, statement, .add), | 1248 | .assign_add => try assignOp(gz, scope, statement, .add), |
| 1236 | .assign_add_wrap => try assignOp(gz, scope, statement, .addwrap), | 1249 | .assign_add_wrap => try assignOp(gz, scope, statement, .addwrap), |
| 1237 | .assign_mul => try assignOp(gz, scope, statement, .mul), | 1250 | .assign_mul => try assignOp(gz, scope, statement, .mul), |
| 1238 | .assign_mul_wrap => try assignOp(gz, scope, statement, .mulwrap), | 1251 | .assign_mul_wrap => try assignOp(gz, scope, statement, .mulwrap), |
| 1252 | // zig fmt: on | ||
| 1239 | 1253 | ||
| 1240 | else => { | 1254 | else => { |
| 1241 | // We need to emit an error if the result is not `noreturn` or `void`, but | 1255 | // We need to emit an error if the result is not `noreturn` or `void`, but |
| ... | @@ -1313,7 +1327,6 @@ fn blockExprStmts( | ... | @@ -1313,7 +1327,6 @@ fn blockExprStmts( |
| 1313 | .func_var_args, | 1327 | .func_var_args, |
| 1314 | .func_extra, | 1328 | .func_extra, |
| 1315 | .func_extra_var_args, | 1329 | .func_extra_var_args, |
| 1316 | .has_decl, | ||
| 1317 | .int, | 1330 | .int, |
| 1318 | .float, | 1331 | .float, |
| 1319 | .float128, | 1332 | .float128, |
| ... | @@ -1390,6 +1403,7 @@ fn blockExprStmts( | ... | @@ -1390,6 +1403,7 @@ fn blockExprStmts( |
| 1390 | .switch_capture_else_ref, | 1403 | .switch_capture_else_ref, |
| 1391 | .struct_init_empty, | 1404 | .struct_init_empty, |
| 1392 | .struct_init, | 1405 | .struct_init, |
| 1406 | .union_init_ptr, | ||
| 1393 | .field_type, | 1407 | .field_type, |
| 1394 | .struct_decl, | 1408 | .struct_decl, |
| 1395 | .struct_decl_packed, | 1409 | .struct_decl_packed, |
| ... | @@ -1404,7 +1418,6 @@ fn blockExprStmts( | ... | @@ -1404,7 +1418,6 @@ fn blockExprStmts( |
| 1404 | .size_of, | 1418 | .size_of, |
| 1405 | .bit_size_of, | 1419 | .bit_size_of, |
| 1406 | .this, | 1420 | .this, |
| 1407 | .fence, | ||
| 1408 | .ret_addr, | 1421 | .ret_addr, |
| 1409 | .builtin_src, | 1422 | .builtin_src, |
| 1410 | .add_with_overflow, | 1423 | .add_with_overflow, |
| ... | @@ -1412,10 +1425,80 @@ fn blockExprStmts( | ... | @@ -1412,10 +1425,80 @@ fn blockExprStmts( |
| 1412 | .mul_with_overflow, | 1425 | .mul_with_overflow, |
| 1413 | .shl_with_overflow, | 1426 | .shl_with_overflow, |
| 1414 | .log2_int_type, | 1427 | .log2_int_type, |
| 1428 | .typeof_log2_int_type, | ||
| 1429 | .error_return_trace, | ||
| 1430 | .frame, | ||
| 1431 | .frame_address, | ||
| 1432 | .ptr_to_int, | ||
| 1433 | .align_of, | ||
| 1434 | .bool_to_int, | ||
| 1435 | .embed_file, | ||
| 1436 | .error_name, | ||
| 1437 | .sqrt, | ||
| 1438 | .sin, | ||
| 1439 | .cos, | ||
| 1440 | .exp, | ||
| 1441 | .exp2, | ||
| 1442 | .log, | ||
| 1443 | .log2, | ||
| 1444 | .log10, | ||
| 1445 | .fabs, | ||
| 1446 | .floor, | ||
| 1447 | .ceil, | ||
| 1448 | .trunc, | ||
| 1449 | .round, | ||
| 1450 | .tag_name, | ||
| 1451 | .reify, | ||
| 1452 | .type_name, | ||
| 1453 | .frame_type, | ||
| 1454 | .frame_size, | ||
| 1455 | .float_to_int, | ||
| 1456 | .int_to_float, | ||
| 1457 | .int_to_ptr, | ||
| 1458 | .float_cast, | ||
| 1459 | .int_cast, | ||
| 1460 | .err_set_cast, | ||
| 1461 | .ptr_cast, | ||
| 1462 | .truncate, | ||
| 1463 | .align_cast, | ||
| 1464 | .has_decl, | ||
| 1465 | .has_field, | ||
| 1466 | .clz, | ||
| 1467 | .ctz, | ||
| 1468 | .pop_count, | ||
| 1469 | .byte_swap, | ||
| 1470 | .bit_reverse, | ||
| 1471 | .div_exact, | ||
| 1472 | .div_floor, | ||
| 1473 | .div_trunc, | ||
| 1474 | .mod, | ||
| 1475 | .rem, | ||
| 1476 | .shl_exact, | ||
| 1477 | .shr_exact, | ||
| 1478 | .bit_offset_of, | ||
| 1479 | .byte_offset_of, | ||
| 1480 | .cmpxchg_strong, | ||
| 1481 | .cmpxchg_weak, | ||
| 1482 | .splat, | ||
| 1483 | .reduce, | ||
| 1484 | .shuffle, | ||
| 1485 | .atomic_load, | ||
| 1486 | .atomic_rmw, | ||
| 1487 | .atomic_store, | ||
| 1488 | .mul_add, | ||
| 1489 | .builtin_call, | ||
| 1490 | .field_ptr_type, | ||
| 1491 | .field_parent_ptr, | ||
| 1492 | .memcpy, | ||
| 1493 | .memset, | ||
| 1494 | .builtin_async_call, | ||
| 1495 | .c_import, | ||
| 1496 | .extended, | ||
| 1415 | => break :b false, | 1497 | => break :b false, |
| 1416 | 1498 | ||
| 1417 | // ZIR instructions that are always either `noreturn` or `void`. | 1499 | // ZIR instructions that are always either `noreturn` or `void`. |
| 1418 | .breakpoint, | 1500 | .breakpoint, |
| 1501 | .fence, | ||
| 1419 | .dbg_stmt_node, | 1502 | .dbg_stmt_node, |
| 1420 | .ensure_result_used, | 1503 | .ensure_result_used, |
| 1421 | .ensure_result_non_error, | 1504 | .ensure_result_non_error, |
| ... | @@ -1432,7 +1515,6 @@ fn blockExprStmts( | ... | @@ -1432,7 +1515,6 @@ fn blockExprStmts( |
| 1432 | .ret_tok, | 1515 | .ret_tok, |
| 1433 | .ret_coerce, | 1516 | .ret_coerce, |
| 1434 | .@"unreachable", | 1517 | .@"unreachable", |
| 1435 | .elided, | ||
| 1436 | .store, | 1518 | .store, |
| 1437 | .store_node, | 1519 | .store_node, |
| 1438 | .store_to_block_ptr, | 1520 | .store_to_block_ptr, |
| ... | @@ -1441,6 +1523,11 @@ fn blockExprStmts( | ... | @@ -1441,6 +1523,11 @@ fn blockExprStmts( |
| 1441 | .repeat, | 1523 | .repeat, |
| 1442 | .repeat_inline, | 1524 | .repeat_inline, |
| 1443 | .validate_struct_init_ptr, | 1525 | .validate_struct_init_ptr, |
| 1526 | .panic, | ||
| 1527 | .set_align_stack, | ||
| 1528 | .set_cold, | ||
| 1529 | .set_float_mode, | ||
| 1530 | .set_runtime_safety, | ||
| 1444 | => break :b true, | 1531 | => break :b true, |
| 1445 | } | 1532 | } |
| 1446 | } else switch (maybe_unused_result) { | 1533 | } else switch (maybe_unused_result) { |
| ... | @@ -1702,12 +1789,34 @@ fn assignOp( | ... | @@ -1702,12 +1789,34 @@ fn assignOp( |
| 1702 | _ = try gz.addBin(.store, lhs_ptr, result); | 1789 | _ = try gz.addBin(.store, lhs_ptr, result); |
| 1703 | } | 1790 | } |
| 1704 | 1791 | ||
| 1792 | fn assignShift( | ||
| 1793 | gz: *GenZir, | ||
| 1794 | scope: *Scope, | ||
| 1795 | infix_node: ast.Node.Index, | ||
| 1796 | op_inst_tag: Zir.Inst.Tag, | ||
| 1797 | ) InnerError!void { | ||
| 1798 | const astgen = gz.astgen; | ||
| 1799 | const tree = &astgen.file.tree; | ||
| 1800 | const node_datas = tree.nodes.items(.data); | ||
| 1801 | |||
| 1802 | const lhs_ptr = try lvalExpr(gz, scope, node_datas[infix_node].lhs); | ||
| 1803 | const lhs = try gz.addUnNode(.load, lhs_ptr, infix_node); | ||
| 1804 | const rhs_type = try gz.addUnNode(.typeof_log2_int_type, lhs, infix_node); | ||
| 1805 | const rhs = try expr(gz, scope, .{ .ty = rhs_type }, node_datas[infix_node].rhs); | ||
| 1806 | |||
| 1807 | const result = try gz.addPlNode(op_inst_tag, infix_node, Zir.Inst.Bin{ | ||
| 1808 | .lhs = lhs, | ||
| 1809 | .rhs = rhs, | ||
| 1810 | }); | ||
| 1811 | _ = try gz.addBin(.store, lhs_ptr, result); | ||
| 1812 | } | ||
| 1813 | |||
| 1705 | fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { | 1814 | fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { |
| 1706 | const astgen = gz.astgen; | 1815 | const astgen = gz.astgen; |
| 1707 | const tree = &astgen.file.tree; | 1816 | const tree = &astgen.file.tree; |
| 1708 | const node_datas = tree.nodes.items(.data); | 1817 | const node_datas = tree.nodes.items(.data); |
| 1709 | 1818 | ||
| 1710 | const operand = try expr(gz, scope, .{ .ty = .bool_type }, node_datas[node].lhs); | 1819 | const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs); |
| 1711 | const result = try gz.addUnNode(.bool_not, operand, node); | 1820 | const result = try gz.addUnNode(.bool_not, operand, node); |
| 1712 | return rvalue(gz, scope, rl, result, node); | 1821 | return rvalue(gz, scope, rl, result, node); |
| 1713 | } | 1822 | } |
| ... | @@ -1778,7 +1887,7 @@ fn ptrType( | ... | @@ -1778,7 +1887,7 @@ fn ptrType( |
| 1778 | trailing_count += 1; | 1887 | trailing_count += 1; |
| 1779 | } | 1888 | } |
| 1780 | if (ptr_info.ast.align_node != 0) { | 1889 | if (ptr_info.ast.align_node != 0) { |
| 1781 | align_ref = try expr(gz, scope, .none, ptr_info.ast.align_node); | 1890 | align_ref = try expr(gz, scope, align_rl, ptr_info.ast.align_node); |
| 1782 | trailing_count += 1; | 1891 | trailing_count += 1; |
| 1783 | } | 1892 | } |
| 1784 | if (ptr_info.ast.bit_range_start != 0) { | 1893 | if (ptr_info.ast.bit_range_start != 0) { |
| ... | @@ -1978,19 +2087,16 @@ fn fnDecl( | ... | @@ -1978,19 +2087,16 @@ fn fnDecl( |
| 1978 | ); | 2087 | ); |
| 1979 | 2088 | ||
| 1980 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) | 2089 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) |
| 1981 | // TODO instead of enum literal type, this needs to be the | ||
| 1982 | // std.builtin.CallingConvention enum. We need to implement importing other files | ||
| 1983 | // and enums in order to fix this. | ||
| 1984 | try AstGen.expr( | 2090 | try AstGen.expr( |
| 1985 | &decl_gz, | 2091 | &decl_gz, |
| 1986 | &decl_gz.base, | 2092 | &decl_gz.base, |
| 1987 | .{ .ty = .enum_literal_type }, | 2093 | .{ .ty = .calling_convention_type }, |
| 1988 | fn_proto.ast.callconv_expr, | 2094 | fn_proto.ast.callconv_expr, |
| 1989 | ) | 2095 | ) |
| 1990 | else if (is_extern) // note: https://github.com/ziglang/zig/issues/5269 | 2096 | else if (is_extern) // note: https://github.com/ziglang/zig/issues/5269 |
| 1991 | try decl_gz.addSmallStr(.enum_literal_small, "C") | 2097 | Zir.Inst.Ref.calling_convention_c |
| 1992 | else | 2098 | else |
| 1993 | .none; | 2099 | Zir.Inst.Ref.none; |
| 1994 | 2100 | ||
| 1995 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { | 2101 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { |
| 1996 | if (is_extern) { | 2102 | if (is_extern) { |
| ... | @@ -3079,7 +3185,7 @@ fn boolBinOp( | ... | @@ -3079,7 +3185,7 @@ fn boolBinOp( |
| 3079 | ) InnerError!Zir.Inst.Ref { | 3185 | ) InnerError!Zir.Inst.Ref { |
| 3080 | const node_datas = gz.tree().nodes.items(.data); | 3186 | const node_datas = gz.tree().nodes.items(.data); |
| 3081 | 3187 | ||
| 3082 | const lhs = try expr(gz, scope, .{ .ty = .bool_type }, node_datas[node].lhs); | 3188 | const lhs = try expr(gz, scope, bool_rl, node_datas[node].lhs); |
| 3083 | const bool_br = try gz.addBoolBr(zir_tag, lhs); | 3189 | const bool_br = try gz.addBoolBr(zir_tag, lhs); |
| 3084 | 3190 | ||
| 3085 | var rhs_scope: GenZir = .{ | 3191 | var rhs_scope: GenZir = .{ |
| ... | @@ -3089,7 +3195,7 @@ fn boolBinOp( | ... | @@ -3089,7 +3195,7 @@ fn boolBinOp( |
| 3089 | .force_comptime = gz.force_comptime, | 3195 | .force_comptime = gz.force_comptime, |
| 3090 | }; | 3196 | }; |
| 3091 | defer rhs_scope.instructions.deinit(gz.astgen.gpa); | 3197 | defer rhs_scope.instructions.deinit(gz.astgen.gpa); |
| 3092 | const rhs = try expr(&rhs_scope, &rhs_scope.base, .{ .ty = .bool_type }, node_datas[node].rhs); | 3198 | const rhs = try expr(&rhs_scope, &rhs_scope.base, bool_rl, node_datas[node].rhs); |
| 3093 | _ = try rhs_scope.addBreak(.break_inline, bool_br, rhs); | 3199 | _ = try rhs_scope.addBreak(.break_inline, bool_br, rhs); |
| 3094 | try rhs_scope.setBoolBrBody(bool_br); | 3200 | try rhs_scope.setBoolBrBody(bool_br); |
| 3095 | 3201 | ||
| ... | @@ -3122,7 +3228,7 @@ fn ifExpr( | ... | @@ -3122,7 +3228,7 @@ fn ifExpr( |
| 3122 | } else if (if_full.payload_token) |payload_token| { | 3228 | } else if (if_full.payload_token) |payload_token| { |
| 3123 | return astgen.failTok(payload_token, "TODO implement if optional", .{}); | 3229 | return astgen.failTok(payload_token, "TODO implement if optional", .{}); |
| 3124 | } else { | 3230 | } else { |
| 3125 | break :c try expr(&block_scope, &block_scope.base, .{ .ty = .bool_type }, if_full.ast.cond_expr); | 3231 | break :c try expr(&block_scope, &block_scope.base, bool_rl, if_full.ast.cond_expr); |
| 3126 | } | 3232 | } |
| 3127 | }; | 3233 | }; |
| 3128 | 3234 | ||
| ... | @@ -3291,8 +3397,7 @@ fn whileExpr( | ... | @@ -3291,8 +3397,7 @@ fn whileExpr( |
| 3291 | } else if (while_full.payload_token) |payload_token| { | 3397 | } else if (while_full.payload_token) |payload_token| { |
| 3292 | return astgen.failTok(payload_token, "TODO implement while optional", .{}); | 3398 | return astgen.failTok(payload_token, "TODO implement while optional", .{}); |
| 3293 | } else { | 3399 | } else { |
| 3294 | const bool_type_rl: ResultLoc = .{ .ty = .bool_type }; | 3400 | break :c try expr(&continue_scope, &continue_scope.base, bool_rl, while_full.ast.cond_expr); |
| 3295 | break :c try expr(&continue_scope, &continue_scope.base, bool_type_rl, while_full.ast.cond_expr); | ||
| 3296 | } | 3401 | } |
| 3297 | }; | 3402 | }; |
| 3298 | 3403 | ||
| ... | @@ -4758,37 +4863,8 @@ fn builtinCall( | ... | @@ -4758,37 +4863,8 @@ fn builtinCall( |
| 4758 | } | 4863 | } |
| 4759 | } | 4864 | } |
| 4760 | 4865 | ||
| 4866 | // zig fmt: off | ||
| 4761 | switch (info.tag) { | 4867 | switch (info.tag) { |
| 4762 | .ptr_to_int => { | ||
| 4763 | const operand = try expr(gz, scope, .none, params[0]); | ||
| 4764 | const result = try gz.addUnNode(.ptrtoint, operand, node); | ||
| 4765 | return rvalue(gz, scope, rl, result, node); | ||
| 4766 | }, | ||
| 4767 | .float_cast => { | ||
| 4768 | const dest_type = try typeExpr(gz, scope, params[0]); | ||
| 4769 | const rhs = try expr(gz, scope, .none, params[1]); | ||
| 4770 | const result = try gz.addPlNode(.floatcast, node, Zir.Inst.Bin{ | ||
| 4771 | .lhs = dest_type, | ||
| 4772 | .rhs = rhs, | ||
| 4773 | }); | ||
| 4774 | return rvalue(gz, scope, rl, result, node); | ||
| 4775 | }, | ||
| 4776 | .int_cast => { | ||
| 4777 | const dest_type = try typeExpr(gz, scope, params[0]); | ||
| 4778 | const rhs = try expr(gz, scope, .none, params[1]); | ||
| 4779 | const result = try gz.addPlNode(.intcast, node, Zir.Inst.Bin{ | ||
| 4780 | .lhs = dest_type, | ||
| 4781 | .rhs = rhs, | ||
| 4782 | }); | ||
| 4783 | return rvalue(gz, scope, rl, result, node); | ||
| 4784 | }, | ||
| 4785 | .breakpoint => { | ||
| 4786 | _ = try gz.add(.{ | ||
| 4787 | .tag = .breakpoint, | ||
| 4788 | .data = .{ .node = gz.nodeIndexToRelative(node) }, | ||
| 4789 | }); | ||
| 4790 | return rvalue(gz, scope, rl, .void_value, node); | ||
| 4791 | }, | ||
| 4792 | .import => { | 4868 | .import => { |
| 4793 | const node_tags = tree.nodes.items(.tag); | 4869 | const node_tags = tree.nodes.items(.tag); |
| 4794 | const node_datas = tree.nodes.items(.data); | 4870 | const node_datas = tree.nodes.items(.data); |
| ... | @@ -4804,26 +4880,6 @@ fn builtinCall( | ... | @@ -4804,26 +4880,6 @@ fn builtinCall( |
| 4804 | const result = try gz.addStrTok(.import, str.index, str_lit_token); | 4880 | const result = try gz.addStrTok(.import, str.index, str_lit_token); |
| 4805 | return rvalue(gz, scope, rl, result, node); | 4881 | return rvalue(gz, scope, rl, result, node); |
| 4806 | }, | 4882 | }, |
| 4807 | .error_to_int => { | ||
| 4808 | const target = try expr(gz, scope, .none, params[0]); | ||
| 4809 | const result = try gz.addUnNode(.error_to_int, target, node); | ||
| 4810 | return rvalue(gz, scope, rl, result, node); | ||
| 4811 | }, | ||
| 4812 | .int_to_error => { | ||
| 4813 | const target = try expr(gz, scope, .{ .ty = .u16_type }, params[0]); | ||
| 4814 | const result = try gz.addUnNode(.int_to_error, target, node); | ||
| 4815 | return rvalue(gz, scope, rl, result, node); | ||
| 4816 | }, | ||
| 4817 | .compile_error => { | ||
| 4818 | const target = try expr(gz, scope, .none, params[0]); | ||
| 4819 | const result = try gz.addUnNode(.compile_error, target, node); | ||
| 4820 | return rvalue(gz, scope, rl, result, node); | ||
| 4821 | }, | ||
| 4822 | .set_eval_branch_quota => { | ||
| 4823 | const quota = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); | ||
| 4824 | const result = try gz.addUnNode(.set_eval_branch_quota, quota, node); | ||
| 4825 | return rvalue(gz, scope, rl, result, node); | ||
| 4826 | }, | ||
| 4827 | .compile_log => { | 4883 | .compile_log => { |
| 4828 | const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len); | 4884 | const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len); |
| 4829 | defer astgen.gpa.free(arg_refs); | 4885 | defer astgen.gpa.free(arg_refs); |
| ... | @@ -4850,23 +4906,11 @@ fn builtinCall( | ... | @@ -4850,23 +4906,11 @@ fn builtinCall( |
| 4850 | }); | 4906 | }); |
| 4851 | return rvalue(gz, scope, rl, result, node); | 4907 | return rvalue(gz, scope, rl, result, node); |
| 4852 | }, | 4908 | }, |
| 4853 | .as => return as(gz, scope, rl, node, params[0], params[1]), | 4909 | .as => return as( gz, scope, rl, node, params[0], params[1]), |
| 4854 | .bit_cast => return bitCast(gz, scope, rl, node, params[0], params[1]), | 4910 | .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]), |
| 4855 | .TypeOf => return typeOf(gz, scope, rl, node, params), | 4911 | .TypeOf => return typeOf( gz, scope, rl, node, params), |
| 4856 | 4912 | .union_init => return unionInit(gz, scope, rl, node, params), | |
| 4857 | .int_to_enum => { | 4913 | .c_import => return cImport( gz, scope, rl, node, params[0]), |
| 4858 | const result = try gz.addPlNode(.int_to_enum, node, Zir.Inst.Bin{ | ||
| 4859 | .lhs = try typeExpr(gz, scope, params[0]), | ||
| 4860 | .rhs = try expr(gz, scope, .none, params[1]), | ||
| 4861 | }); | ||
| 4862 | return rvalue(gz, scope, rl, result, node); | ||
| 4863 | }, | ||
| 4864 | |||
| 4865 | .enum_to_int => { | ||
| 4866 | const operand = try expr(gz, scope, .none, params[0]); | ||
| 4867 | const result = try gz.addUnNode(.enum_to_int, operand, node); | ||
| 4868 | return rvalue(gz, scope, rl, result, node); | ||
| 4869 | }, | ||
| 4870 | 4914 | ||
| 4871 | .@"export" => { | 4915 | .@"export" => { |
| 4872 | // TODO: @export is supposed to be able to export things other than functions. | 4916 | // TODO: @export is supposed to be able to export things other than functions. |
| ... | @@ -4882,38 +4926,147 @@ fn builtinCall( | ... | @@ -4882,38 +4926,147 @@ fn builtinCall( |
| 4882 | return rvalue(gz, scope, rl, .void_value, node); | 4926 | return rvalue(gz, scope, rl, .void_value, node); |
| 4883 | }, | 4927 | }, |
| 4884 | 4928 | ||
| 4885 | .has_decl => { | 4929 | .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint), |
| 4886 | const container_type = try typeExpr(gz, scope, params[0]); | 4930 | .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence), |
| 4887 | const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); | 4931 | |
| 4888 | const result = try gz.addPlNode(.has_decl, node, Zir.Inst.Bin{ | 4932 | .This => return rvalue(gz, scope, rl, try gz.addNode(.this, node), node), |
| 4889 | .lhs = container_type, | 4933 | .return_address => return rvalue(gz, scope, rl, try gz.addNode(.ret_addr, node), node), |
| 4890 | .rhs = name, | 4934 | .src => return rvalue(gz, scope, rl, try gz.addNode(.builtin_src, node), node), |
| 4935 | .error_return_trace => return rvalue(gz, scope, rl, try gz.addNode(.error_return_trace, node), node), | ||
| 4936 | .frame => return rvalue(gz, scope, rl, try gz.addNode(.frame, node), node), | ||
| 4937 | .frame_address => return rvalue(gz, scope, rl, try gz.addNode(.frame_address, node), node), | ||
| 4938 | |||
| 4939 | .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info), | ||
| 4940 | .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of), | ||
| 4941 | .bit_size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .bit_size_of), | ||
| 4942 | .align_of => return simpleUnOpType(gz, scope, rl, node, params[0], .align_of), | ||
| 4943 | |||
| 4944 | .ptr_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .ptr_to_int), | ||
| 4945 | .error_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .error_to_int), | ||
| 4946 | .int_to_error => return simpleUnOp(gz, scope, rl, node, .{ .ty = .u16_type }, params[0], .int_to_error), | ||
| 4947 | .compile_error => return simpleUnOp(gz, scope, rl, node, .{ .ty = .const_slice_u8_type }, params[0], .compile_error), | ||
| 4948 | .set_eval_branch_quota => return simpleUnOp(gz, scope, rl, node, .{ .ty = .u32_type }, params[0], .set_eval_branch_quota), | ||
| 4949 | .enum_to_int => return simpleUnOp(gz, scope, rl, node, .none, params[0], .enum_to_int), | ||
| 4950 | .bool_to_int => return simpleUnOp(gz, scope, rl, node, bool_rl, params[0], .bool_to_int), | ||
| 4951 | .embed_file => return simpleUnOp(gz, scope, rl, node, .{ .ty = .const_slice_u8_type }, params[0], .embed_file), | ||
| 4952 | .error_name => return simpleUnOp(gz, scope, rl, node, .{ .ty = .anyerror_type }, params[0], .error_name), | ||
| 4953 | .panic => return simpleUnOp(gz, scope, rl, node, .{ .ty = .const_slice_u8_type }, params[0], .panic), | ||
| 4954 | .set_align_stack => return simpleUnOp(gz, scope, rl, node, align_rl, params[0], .set_align_stack), | ||
| 4955 | .set_cold => return simpleUnOp(gz, scope, rl, node, bool_rl, params[0], .set_cold), | ||
| 4956 | .set_float_mode => return simpleUnOp(gz, scope, rl, node, .{ .ty = .float_mode_type }, params[0], .set_float_mode), | ||
| 4957 | .set_runtime_safety => return simpleUnOp(gz, scope, rl, node, bool_rl, params[0], .set_runtime_safety), | ||
| 4958 | .sqrt => return simpleUnOp(gz, scope, rl, node, .none, params[0], .sqrt), | ||
| 4959 | .sin => return simpleUnOp(gz, scope, rl, node, .none, params[0], .sin), | ||
| 4960 | .cos => return simpleUnOp(gz, scope, rl, node, .none, params[0], .cos), | ||
| 4961 | .exp => return simpleUnOp(gz, scope, rl, node, .none, params[0], .exp), | ||
| 4962 | .exp2 => return simpleUnOp(gz, scope, rl, node, .none, params[0], .exp2), | ||
| 4963 | .log => return simpleUnOp(gz, scope, rl, node, .none, params[0], .log), | ||
| 4964 | .log2 => return simpleUnOp(gz, scope, rl, node, .none, params[0], .log2), | ||
| 4965 | .log10 => return simpleUnOp(gz, scope, rl, node, .none, params[0], .log10), | ||
| 4966 | .fabs => return simpleUnOp(gz, scope, rl, node, .none, params[0], .fabs), | ||
| 4967 | .floor => return simpleUnOp(gz, scope, rl, node, .none, params[0], .floor), | ||
| 4968 | .ceil => return simpleUnOp(gz, scope, rl, node, .none, params[0], .ceil), | ||
| 4969 | .trunc => return simpleUnOp(gz, scope, rl, node, .none, params[0], .trunc), | ||
| 4970 | .round => return simpleUnOp(gz, scope, rl, node, .none, params[0], .round), | ||
| 4971 | .tag_name => return simpleUnOp(gz, scope, rl, node, .none, params[0], .tag_name), | ||
| 4972 | .Type => return simpleUnOp(gz, scope, rl, node, .none, params[0], .reify), | ||
| 4973 | .type_name => return simpleUnOp(gz, scope, rl, node, .none, params[0], .type_name), | ||
| 4974 | .Frame => return simpleUnOp(gz, scope, rl, node, .none, params[0], .frame_type), | ||
| 4975 | .frame_size => return simpleUnOp(gz, scope, rl, node, .none, params[0], .frame_size), | ||
| 4976 | |||
| 4977 | .float_to_int => return typeCast(gz, scope, rl, node, params[0], params[1], .float_to_int), | ||
| 4978 | .int_to_float => return typeCast(gz, scope, rl, node, params[0], params[1], .int_to_float), | ||
| 4979 | .int_to_ptr => return typeCast(gz, scope, rl, node, params[0], params[1], .int_to_ptr), | ||
| 4980 | .int_to_enum => return typeCast(gz, scope, rl, node, params[0], params[1], .int_to_enum), | ||
| 4981 | .float_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .float_cast), | ||
| 4982 | .int_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .int_cast), | ||
| 4983 | .err_set_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .err_set_cast), | ||
| 4984 | .ptr_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .ptr_cast), | ||
| 4985 | .truncate => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate), | ||
| 4986 | .align_cast => { | ||
| 4987 | const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]); | ||
| 4988 | const rhs = try expr(gz, scope, .none, params[1]); | ||
| 4989 | const result = try gz.addPlNode(.align_cast, node, Zir.Inst.Bin{ | ||
| 4990 | .lhs = dest_align, | ||
| 4991 | .rhs = rhs, | ||
| 4891 | }); | 4992 | }); |
| 4892 | return rvalue(gz, scope, rl, result, node); | 4993 | return rvalue(gz, scope, rl, result, node); |
| 4893 | }, | 4994 | }, |
| 4894 | 4995 | ||
| 4895 | .type_info => { | 4996 | .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl), |
| 4896 | const operand = try typeExpr(gz, scope, params[0]); | 4997 | .has_field => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_field), |
| 4897 | const result = try gz.addUnNode(.type_info, operand, node); | 4998 | |
| 4999 | .clz => return bitBuiltin(gz, scope, rl, node, params[0], params[1], .clz), | ||
| 5000 | .ctz => return bitBuiltin(gz, scope, rl, node, params[0], params[1], .ctz), | ||
| 5001 | .pop_count => return bitBuiltin(gz, scope, rl, node, params[0], params[1], .pop_count), | ||
| 5002 | .byte_swap => return bitBuiltin(gz, scope, rl, node, params[0], params[1], .byte_swap), | ||
| 5003 | .bit_reverse => return bitBuiltin(gz, scope, rl, node, params[0], params[1], .bit_reverse), | ||
| 5004 | |||
| 5005 | .div_exact => return divBuiltin(gz, scope, rl, node, params[0], params[1], .div_exact), | ||
| 5006 | .div_floor => return divBuiltin(gz, scope, rl, node, params[0], params[1], .div_floor), | ||
| 5007 | .div_trunc => return divBuiltin(gz, scope, rl, node, params[0], params[1], .div_trunc), | ||
| 5008 | .mod => return divBuiltin(gz, scope, rl, node, params[0], params[1], .mod), | ||
| 5009 | .rem => return divBuiltin(gz, scope, rl, node, params[0], params[1], .rem), | ||
| 5010 | |||
| 5011 | .shl_exact => return shiftOp(gz, scope, rl, node, params[0], params[1], .shl_exact), | ||
| 5012 | .shr_exact => return shiftOp(gz, scope, rl, node, params[0], params[1], .shr_exact), | ||
| 5013 | |||
| 5014 | .bit_offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .bit_offset_of), | ||
| 5015 | .byte_offset_of => return offsetOf(gz, scope, rl, node, params[0], params[1], .byte_offset_of), | ||
| 5016 | |||
| 5017 | .c_undef => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_undef), | ||
| 5018 | .c_include => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_include), | ||
| 5019 | |||
| 5020 | .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_strong), | ||
| 5021 | .cmpxchg_weak => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_weak), | ||
| 5022 | |||
| 5023 | .wasm_memory_size => { | ||
| 5024 | const operand = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); | ||
| 5025 | const result = try gz.addExtendedPayload(.wasm_memory_size, Zir.Inst.UnNode{ | ||
| 5026 | .node = gz.nodeIndexToRelative(node), | ||
| 5027 | .operand = operand, | ||
| 5028 | }); | ||
| 4898 | return rvalue(gz, scope, rl, result, node); | 5029 | return rvalue(gz, scope, rl, result, node); |
| 4899 | }, | 5030 | }, |
| 4900 | 5031 | .wasm_memory_grow => { | |
| 4901 | .size_of => { | 5032 | const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); |
| 4902 | const operand = try typeExpr(gz, scope, params[0]); | 5033 | const delta_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[1]); |
| 4903 | const result = try gz.addUnNode(.size_of, operand, node); | 5034 | const result = try gz.addExtendedPayload(.wasm_memory_grow, Zir.Inst.BinNode{ |
| 5035 | .node = gz.nodeIndexToRelative(node), | ||
| 5036 | .lhs = index_arg, | ||
| 5037 | .rhs = delta_arg, | ||
| 5038 | }); | ||
| 4904 | return rvalue(gz, scope, rl, result, node); | 5039 | return rvalue(gz, scope, rl, result, node); |
| 4905 | }, | 5040 | }, |
| 4906 | 5041 | .c_define => { | |
| 4907 | .bit_size_of => { | 5042 | const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]); |
| 4908 | const operand = try typeExpr(gz, scope, params[0]); | 5043 | const value = try comptimeExpr(gz, scope, .none, params[1]); |
| 4909 | const result = try gz.addUnNode(.bit_size_of, operand, node); | 5044 | const result = try gz.addExtendedPayload(.c_define, Zir.Inst.BinNode{ |
| 5045 | .node = gz.nodeIndexToRelative(node), | ||
| 5046 | .lhs = name, | ||
| 5047 | .rhs = value, | ||
| 5048 | }); | ||
| 4910 | return rvalue(gz, scope, rl, result, node); | 5049 | return rvalue(gz, scope, rl, result, node); |
| 4911 | }, | 5050 | }, |
| 4912 | 5051 | ||
| 4913 | .This => return rvalue(gz, scope, rl, try gz.addNode(.this, node), node), | 5052 | .splat => { |
| 4914 | .fence => return rvalue(gz, scope, rl, try gz.addNode(.fence, node), node), | 5053 | const len = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); |
| 4915 | .return_address => return rvalue(gz, scope, rl, try gz.addNode(.ret_addr, node), node), | 5054 | const scalar = try expr(gz, scope, .none, params[1]); |
| 4916 | .src => return rvalue(gz, scope, rl, try gz.addNode(.builtin_src, node), node), | 5055 | const result = try gz.addPlNode(.splat, node, Zir.Inst.Bin{ |
| 5056 | .lhs = len, | ||
| 5057 | .rhs = scalar, | ||
| 5058 | }); | ||
| 5059 | return rvalue(gz, scope, rl, result, node); | ||
| 5060 | }, | ||
| 5061 | .reduce => { | ||
| 5062 | const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]); | ||
| 5063 | const scalar = try expr(gz, scope, .none, params[1]); | ||
| 5064 | const result = try gz.addPlNode(.reduce, node, Zir.Inst.Bin{ | ||
| 5065 | .lhs = op, | ||
| 5066 | .rhs = scalar, | ||
| 5067 | }); | ||
| 5068 | return rvalue(gz, scope, rl, result, node); | ||
| 5069 | }, | ||
| 4917 | 5070 | ||
| 4918 | .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow), | 5071 | .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow), |
| 4919 | .sub_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .sub_with_overflow), | 5072 | .sub_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .sub_with_overflow), |
| ... | @@ -4941,83 +5094,373 @@ fn builtinCall( | ... | @@ -4941,83 +5094,373 @@ fn builtinCall( |
| 4941 | return rvalue(gz, scope, rl, result, node); | 5094 | return rvalue(gz, scope, rl, result, node); |
| 4942 | }, | 5095 | }, |
| 4943 | 5096 | ||
| 4944 | .align_cast, | 5097 | .atomic_load => { |
| 4945 | .align_of, | 5098 | const int_type = try typeExpr(gz, scope, params[0]); |
| 4946 | .atomic_load, | 5099 | const ptr_type = try gz.add(.{ .tag = .ptr_type_simple, .data = .{ |
| 4947 | .atomic_rmw, | 5100 | .ptr_type_simple = .{ |
| 4948 | .atomic_store, | 5101 | .is_allowzero = false, |
| 4949 | .bit_offset_of, | 5102 | .is_mutable = false, |
| 4950 | .bool_to_int, | 5103 | .is_volatile = false, |
| 4951 | .mul_add, | 5104 | .size = .One, |
| 4952 | .byte_swap, | 5105 | .elem_type = int_type, |
| 4953 | .bit_reverse, | 5106 | }, |
| 4954 | .byte_offset_of, | 5107 | } }); |
| 4955 | .call, | 5108 | const ptr = try expr(gz, scope, .{ .ty = ptr_type }, params[1]); |
| 4956 | .c_define, | 5109 | const ordering = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[2]); |
| 4957 | .c_import, | 5110 | const result = try gz.addPlNode(.atomic_load, node, Zir.Inst.Bin{ |
| 4958 | .c_include, | 5111 | .lhs = ptr, |
| 4959 | .clz, | 5112 | .rhs = ordering, |
| 4960 | .cmpxchg_strong, | 5113 | }); |
| 4961 | .cmpxchg_weak, | 5114 | return rvalue(gz, scope, rl, result, node); |
| 4962 | .ctz, | 5115 | }, |
| 4963 | .c_undef, | 5116 | .atomic_rmw => { |
| 4964 | .div_exact, | 5117 | const int_type = try typeExpr(gz, scope, params[0]); |
| 4965 | .div_floor, | 5118 | const ptr_type = try gz.add(.{ .tag = .ptr_type_simple, .data = .{ |
| 4966 | .div_trunc, | 5119 | .ptr_type_simple = .{ |
| 4967 | .embed_file, | 5120 | .is_allowzero = false, |
| 4968 | .error_name, | 5121 | .is_mutable = true, |
| 4969 | .error_return_trace, | 5122 | .is_volatile = false, |
| 4970 | .err_set_cast, | 5123 | .size = .One, |
| 4971 | .field_parent_ptr, | 5124 | .elem_type = int_type, |
| 4972 | .float_to_int, | 5125 | }, |
| 4973 | .has_field, | 5126 | } }); |
| 4974 | .int_to_float, | 5127 | const ptr = try expr(gz, scope, .{ .ty = ptr_type }, params[1]); |
| 4975 | .int_to_ptr, | 5128 | const operation = try expr(gz, scope, .{ .ty = .atomic_rmw_op_type }, params[2]); |
| 4976 | .memcpy, | 5129 | const operand = try expr(gz, scope, .{ .ty = int_type }, params[3]); |
| 4977 | .memset, | 5130 | const ordering = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[4]); |
| 4978 | .wasm_memory_size, | 5131 | const result = try gz.addPlNode(.atomic_rmw, node, Zir.Inst.AtomicRmw{ |
| 4979 | .wasm_memory_grow, | 5132 | .ptr = ptr, |
| 4980 | .mod, | 5133 | .operation = operation, |
| 4981 | .panic, | 5134 | .operand = operand, |
| 4982 | .pop_count, | 5135 | .ordering = ordering, |
| 4983 | .ptr_cast, | 5136 | }); |
| 4984 | .rem, | 5137 | return rvalue(gz, scope, rl, result, node); |
| 4985 | .set_align_stack, | 5138 | }, |
| 4986 | .set_cold, | 5139 | .atomic_store => { |
| 4987 | .set_float_mode, | 5140 | const int_type = try typeExpr(gz, scope, params[0]); |
| 4988 | .set_runtime_safety, | 5141 | const ptr_type = try gz.add(.{ .tag = .ptr_type_simple, .data = .{ |
| 4989 | .shl_exact, | 5142 | .ptr_type_simple = .{ |
| 4990 | .shr_exact, | 5143 | .is_allowzero = false, |
| 4991 | .shuffle, | 5144 | .is_mutable = true, |
| 4992 | .splat, | 5145 | .is_volatile = false, |
| 4993 | .reduce, | 5146 | .size = .One, |
| 4994 | .sqrt, | 5147 | .elem_type = int_type, |
| 4995 | .sin, | 5148 | }, |
| 4996 | .cos, | 5149 | } }); |
| 4997 | .exp, | 5150 | const ptr = try expr(gz, scope, .{ .ty = ptr_type }, params[1]); |
| 4998 | .exp2, | 5151 | const operand = try expr(gz, scope, .{ .ty = int_type }, params[2]); |
| 4999 | .log, | 5152 | const ordering = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[3]); |
| 5000 | .log2, | 5153 | const result = try gz.addPlNode(.atomic_store, node, Zir.Inst.AtomicStore{ |
| 5001 | .log10, | 5154 | .ptr = ptr, |
| 5002 | .fabs, | 5155 | .operand = operand, |
| 5003 | .floor, | 5156 | .ordering = ordering, |
| 5004 | .ceil, | 5157 | }); |
| 5005 | .trunc, | 5158 | return rvalue(gz, scope, rl, result, node); |
| 5006 | .round, | 5159 | }, |
| 5007 | .tag_name, | 5160 | .mul_add => { |
| 5008 | .truncate, | 5161 | const float_type = try typeExpr(gz, scope, params[0]); |
| 5009 | .Type, | 5162 | const mulend1 = try expr(gz, scope, .{ .ty = float_type }, params[1]); |
| 5010 | .type_name, | 5163 | const mulend2 = try expr(gz, scope, .{ .ty = float_type }, params[2]); |
| 5011 | .union_init, | 5164 | const addend = try expr(gz, scope, .{ .ty = float_type }, params[3]); |
| 5012 | .async_call, | 5165 | const result = try gz.addPlNode(.mul_add, node, Zir.Inst.MulAdd{ |
| 5013 | .frame, | 5166 | .mulend1 = mulend1, |
| 5014 | .Frame, | 5167 | .mulend2 = mulend2, |
| 5015 | .frame_address, | 5168 | .addend = addend, |
| 5016 | .frame_size, | 5169 | }); |
| 5017 | => return astgen.failNode(node, "TODO: implement builtin function {s}", .{ | 5170 | return rvalue(gz, scope, rl, result, node); |
| 5018 | builtin_name, | 5171 | }, |
| 5019 | }), | 5172 | .call => { |
| 5173 | const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]); | ||
| 5174 | const callee = try expr(gz, scope, .none, params[1]); | ||
| 5175 | const args = try expr(gz, scope, .none, params[2]); | ||
| 5176 | const result = try gz.addPlNode(.builtin_call, node, Zir.Inst.BuiltinCall{ | ||
| 5177 | .options = options, | ||
| 5178 | .callee = callee, | ||
| 5179 | .args = args, | ||
| 5180 | }); | ||
| 5181 | return rvalue(gz, scope, rl, result, node); | ||
| 5182 | }, | ||
| 5183 | .field_parent_ptr => { | ||
| 5184 | const parent_type = try typeExpr(gz, scope, params[0]); | ||
| 5185 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); | ||
| 5186 | const field_ptr_type = try gz.addBin(.field_ptr_type, parent_type, field_name); | ||
| 5187 | const result = try gz.addPlNode(.field_parent_ptr, node, Zir.Inst.FieldParentPtr{ | ||
| 5188 | .parent_type = parent_type, | ||
| 5189 | .field_name = field_name, | ||
| 5190 | .field_ptr = try expr(gz, scope, .{ .ty = field_ptr_type }, params[2]), | ||
| 5191 | }); | ||
| 5192 | return rvalue(gz, scope, rl, result, node); | ||
| 5193 | }, | ||
| 5194 | .memcpy => { | ||
| 5195 | const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{ | ||
| 5196 | .dest = try expr(gz, scope, .{ .ty = .manyptr_u8_type }, params[0]), | ||
| 5197 | .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]), | ||
| 5198 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), | ||
| 5199 | }); | ||
| 5200 | return rvalue(gz, scope, rl, result, node); | ||
| 5201 | }, | ||
| 5202 | .memset => { | ||
| 5203 | const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{ | ||
| 5204 | .dest = try expr(gz, scope, .{ .ty = .manyptr_u8_type }, params[0]), | ||
| 5205 | .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]), | ||
| 5206 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), | ||
| 5207 | }); | ||
| 5208 | return rvalue(gz, scope, rl, result, node); | ||
| 5209 | }, | ||
| 5210 | .shuffle => { | ||
| 5211 | const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{ | ||
| 5212 | .elem_type = try typeExpr(gz, scope, params[0]), | ||
| 5213 | .a = try expr(gz, scope, .none, params[1]), | ||
| 5214 | .b = try expr(gz, scope, .none, params[2]), | ||
| 5215 | .mask = try comptimeExpr(gz, scope, .none, params[3]), | ||
| 5216 | }); | ||
| 5217 | return rvalue(gz, scope, rl, result, node); | ||
| 5218 | }, | ||
| 5219 | .async_call => { | ||
| 5220 | const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{ | ||
| 5221 | .frame_buffer = try expr(gz, scope, .none, params[0]), | ||
| 5222 | .result_ptr = try expr(gz, scope, .none, params[1]), | ||
| 5223 | .fn_ptr = try expr(gz, scope, .none, params[2]), | ||
| 5224 | .args = try expr(gz, scope, .none, params[3]), | ||
| 5225 | }); | ||
| 5226 | return rvalue(gz, scope, rl, result, node); | ||
| 5227 | }, | ||
| 5020 | } | 5228 | } |
| 5229 | // zig fmt: on | ||
| 5230 | } | ||
| 5231 | |||
| 5232 | fn simpleNoOpVoid( | ||
| 5233 | gz: *GenZir, | ||
| 5234 | scope: *Scope, | ||
| 5235 | rl: ResultLoc, | ||
| 5236 | node: ast.Node.Index, | ||
| 5237 | tag: Zir.Inst.Tag, | ||
| 5238 | ) InnerError!Zir.Inst.Ref { | ||
| 5239 | _ = try gz.addNode(tag, node); | ||
| 5240 | return rvalue(gz, scope, rl, .void_value, node); | ||
| 5241 | } | ||
| 5242 | |||
| 5243 | fn hasDeclOrField( | ||
| 5244 | gz: *GenZir, | ||
| 5245 | scope: *Scope, | ||
| 5246 | rl: ResultLoc, | ||
| 5247 | node: ast.Node.Index, | ||
| 5248 | lhs_node: ast.Node.Index, | ||
| 5249 | rhs_node: ast.Node.Index, | ||
| 5250 | tag: Zir.Inst.Tag, | ||
| 5251 | ) InnerError!Zir.Inst.Ref { | ||
| 5252 | const container_type = try typeExpr(gz, scope, lhs_node); | ||
| 5253 | const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, rhs_node); | ||
| 5254 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ | ||
| 5255 | .lhs = container_type, | ||
| 5256 | .rhs = name, | ||
| 5257 | }); | ||
| 5258 | return rvalue(gz, scope, rl, result, node); | ||
| 5259 | } | ||
| 5260 | |||
| 5261 | fn typeCast( | ||
| 5262 | gz: *GenZir, | ||
| 5263 | scope: *Scope, | ||
| 5264 | rl: ResultLoc, | ||
| 5265 | node: ast.Node.Index, | ||
| 5266 | lhs_node: ast.Node.Index, | ||
| 5267 | rhs_node: ast.Node.Index, | ||
| 5268 | tag: Zir.Inst.Tag, | ||
| 5269 | ) InnerError!Zir.Inst.Ref { | ||
| 5270 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ | ||
| 5271 | .lhs = try typeExpr(gz, scope, lhs_node), | ||
| 5272 | .rhs = try expr(gz, scope, .none, rhs_node), | ||
| 5273 | }); | ||
| 5274 | return rvalue(gz, scope, rl, result, node); | ||
| 5275 | } | ||
| 5276 | |||
| 5277 | fn simpleUnOpType( | ||
| 5278 | gz: *GenZir, | ||
| 5279 | scope: *Scope, | ||
| 5280 | rl: ResultLoc, | ||
| 5281 | node: ast.Node.Index, | ||
| 5282 | operand_node: ast.Node.Index, | ||
| 5283 | tag: Zir.Inst.Tag, | ||
| 5284 | ) InnerError!Zir.Inst.Ref { | ||
| 5285 | const operand = try typeExpr(gz, scope, operand_node); | ||
| 5286 | const result = try gz.addUnNode(tag, operand, node); | ||
| 5287 | return rvalue(gz, scope, rl, result, node); | ||
| 5288 | } | ||
| 5289 | |||
| 5290 | fn simpleUnOp( | ||
| 5291 | gz: *GenZir, | ||
| 5292 | scope: *Scope, | ||
| 5293 | rl: ResultLoc, | ||
| 5294 | node: ast.Node.Index, | ||
| 5295 | operand_rl: ResultLoc, | ||
| 5296 | operand_node: ast.Node.Index, | ||
| 5297 | tag: Zir.Inst.Tag, | ||
| 5298 | ) InnerError!Zir.Inst.Ref { | ||
| 5299 | const operand = try expr(gz, scope, operand_rl, operand_node); | ||
| 5300 | const result = try gz.addUnNode(tag, operand, node); | ||
| 5301 | return rvalue(gz, scope, rl, result, node); | ||
| 5302 | } | ||
| 5303 | |||
| 5304 | fn cmpxchg( | ||
| 5305 | gz: *GenZir, | ||
| 5306 | scope: *Scope, | ||
| 5307 | rl: ResultLoc, | ||
| 5308 | node: ast.Node.Index, | ||
| 5309 | params: []const ast.Node.Index, | ||
| 5310 | tag: Zir.Inst.Tag, | ||
| 5311 | ) InnerError!Zir.Inst.Ref { | ||
| 5312 | const int_type = try typeExpr(gz, scope, params[0]); | ||
| 5313 | const ptr_type = try gz.add(.{ .tag = .ptr_type_simple, .data = .{ | ||
| 5314 | .ptr_type_simple = .{ | ||
| 5315 | .is_allowzero = false, | ||
| 5316 | .is_mutable = true, | ||
| 5317 | .is_volatile = false, | ||
| 5318 | .size = .One, | ||
| 5319 | .elem_type = int_type, | ||
| 5320 | }, | ||
| 5321 | } }); | ||
| 5322 | const result = try gz.addPlNode(tag, node, Zir.Inst.Cmpxchg{ | ||
| 5323 | // zig fmt: off | ||
| 5324 | .ptr = try expr(gz, scope, .{ .ty = ptr_type }, params[1]), | ||
| 5325 | .expected_value = try expr(gz, scope, .{ .ty = int_type }, params[2]), | ||
| 5326 | .new_value = try expr(gz, scope, .{ .ty = int_type }, params[3]), | ||
| 5327 | .success_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[4]), | ||
| 5328 | .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]), | ||
| 5329 | // zig fmt: on | ||
| 5330 | }); | ||
| 5331 | return rvalue(gz, scope, rl, result, node); | ||
| 5332 | } | ||
| 5333 | |||
| 5334 | fn bitBuiltin( | ||
| 5335 | gz: *GenZir, | ||
| 5336 | scope: *Scope, | ||
| 5337 | rl: ResultLoc, | ||
| 5338 | node: ast.Node.Index, | ||
| 5339 | int_type_node: ast.Node.Index, | ||
| 5340 | operand_node: ast.Node.Index, | ||
| 5341 | tag: Zir.Inst.Tag, | ||
| 5342 | ) InnerError!Zir.Inst.Ref { | ||
| 5343 | const int_type = try typeExpr(gz, scope, int_type_node); | ||
| 5344 | const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node); | ||
| 5345 | const result = try gz.addUnNode(tag, operand, node); | ||
| 5346 | return rvalue(gz, scope, rl, result, node); | ||
| 5347 | } | ||
| 5348 | |||
| 5349 | fn divBuiltin( | ||
| 5350 | gz: *GenZir, | ||
| 5351 | scope: *Scope, | ||
| 5352 | rl: ResultLoc, | ||
| 5353 | node: ast.Node.Index, | ||
| 5354 | lhs_node: ast.Node.Index, | ||
| 5355 | rhs_node: ast.Node.Index, | ||
| 5356 | tag: Zir.Inst.Tag, | ||
| 5357 | ) InnerError!Zir.Inst.Ref { | ||
| 5358 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ | ||
| 5359 | .lhs = try expr(gz, scope, .none, lhs_node), | ||
| 5360 | .rhs = try expr(gz, scope, .none, rhs_node), | ||
| 5361 | }); | ||
| 5362 | return rvalue(gz, scope, rl, result, node); | ||
| 5363 | } | ||
| 5364 | |||
| 5365 | fn simpleCBuiltin( | ||
| 5366 | gz: *GenZir, | ||
| 5367 | scope: *Scope, | ||
| 5368 | rl: ResultLoc, | ||
| 5369 | node: ast.Node.Index, | ||
| 5370 | operand_node: ast.Node.Index, | ||
| 5371 | tag: Zir.Inst.Extended, | ||
| 5372 | ) InnerError!Zir.Inst.Ref { | ||
| 5373 | const operand = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, operand_node); | ||
| 5374 | _ = try gz.addExtendedPayload(tag, Zir.Inst.UnNode{ | ||
| 5375 | .node = gz.nodeIndexToRelative(node), | ||
| 5376 | .operand = operand, | ||
| 5377 | }); | ||
| 5378 | return rvalue(gz, scope, rl, .void_value, node); | ||
| 5379 | } | ||
| 5380 | |||
| 5381 | fn offsetOf( | ||
| 5382 | gz: *GenZir, | ||
| 5383 | scope: *Scope, | ||
| 5384 | rl: ResultLoc, | ||
| 5385 | node: ast.Node.Index, | ||
| 5386 | lhs_node: ast.Node.Index, | ||
| 5387 | rhs_node: ast.Node.Index, | ||
| 5388 | tag: Zir.Inst.Tag, | ||
| 5389 | ) InnerError!Zir.Inst.Ref { | ||
| 5390 | const type_inst = try typeExpr(gz, scope, lhs_node); | ||
| 5391 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, rhs_node); | ||
| 5392 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ | ||
| 5393 | .lhs = type_inst, | ||
| 5394 | .rhs = field_name, | ||
| 5395 | }); | ||
| 5396 | return rvalue(gz, scope, rl, result, node); | ||
| 5397 | } | ||
| 5398 | |||
| 5399 | fn shiftOp( | ||
| 5400 | gz: *GenZir, | ||
| 5401 | scope: *Scope, | ||
| 5402 | rl: ResultLoc, | ||
| 5403 | node: ast.Node.Index, | ||
| 5404 | lhs_node: ast.Node.Index, | ||
| 5405 | rhs_node: ast.Node.Index, | ||
| 5406 | tag: Zir.Inst.Tag, | ||
| 5407 | ) InnerError!Zir.Inst.Ref { | ||
| 5408 | const lhs = try expr(gz, scope, .none, lhs_node); | ||
| 5409 | const log2_int_type = try gz.addUnNode(.typeof_log2_int_type, lhs, lhs_node); | ||
| 5410 | const rhs = try expr(gz, scope, .{ .ty = log2_int_type }, rhs_node); | ||
| 5411 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ | ||
| 5412 | .lhs = lhs, | ||
| 5413 | .rhs = rhs, | ||
| 5414 | }); | ||
| 5415 | return rvalue(gz, scope, rl, result, node); | ||
| 5416 | } | ||
| 5417 | |||
| 5418 | fn cImport( | ||
| 5419 | gz: *GenZir, | ||
| 5420 | scope: *Scope, | ||
| 5421 | rl: ResultLoc, | ||
| 5422 | node: ast.Node.Index, | ||
| 5423 | body_node: ast.Node.Index, | ||
| 5424 | ) InnerError!Zir.Inst.Ref { | ||
| 5425 | const astgen = gz.astgen; | ||
| 5426 | const gpa = astgen.gpa; | ||
| 5427 | |||
| 5428 | var block_scope: GenZir = .{ | ||
| 5429 | .parent = scope, | ||
| 5430 | .decl_node_index = gz.decl_node_index, | ||
| 5431 | .astgen = astgen, | ||
| 5432 | .force_comptime = true, | ||
| 5433 | .instructions = .{}, | ||
| 5434 | }; | ||
| 5435 | defer block_scope.instructions.deinit(gpa); | ||
| 5436 | |||
| 5437 | const block_inst = try gz.addBlock(.c_import, node); | ||
| 5438 | const block_result = try expr(&block_scope, &block_scope.base, .none, body_node); | ||
| 5439 | if (!gz.refIsNoReturn(block_result)) { | ||
| 5440 | _ = try block_scope.addBreak(.break_inline, block_inst, .void_value); | ||
| 5441 | } | ||
| 5442 | try block_scope.setBlockBody(block_inst); | ||
| 5443 | try gz.instructions.append(gpa, block_inst); | ||
| 5444 | |||
| 5445 | return rvalue(gz, scope, rl, .void_value, node); | ||
| 5446 | } | ||
| 5447 | |||
| 5448 | fn unionInit( | ||
| 5449 | gz: *GenZir, | ||
| 5450 | scope: *Scope, | ||
| 5451 | rl: ResultLoc, | ||
| 5452 | node: ast.Node.Index, | ||
| 5453 | params: []const ast.Node.Index, | ||
| 5454 | ) InnerError!Zir.Inst.Ref { | ||
| 5455 | const union_type = try typeExpr(gz, scope, params[0]); | ||
| 5456 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); | ||
| 5457 | const union_init_ptr = try gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{ | ||
| 5458 | .union_type = union_type, | ||
| 5459 | .field_name = field_name, | ||
| 5460 | }); | ||
| 5461 | // TODO: set up a store_to_block_ptr elision thing here | ||
| 5462 | const result = try expr(gz, scope, .{ .ptr = union_init_ptr }, params[2]); | ||
| 5463 | return rvalue(gz, scope, rl, result, node); | ||
| 5021 | } | 5464 | } |
| 5022 | 5465 | ||
| 5023 | fn overflowArithmetic( | 5466 | fn overflowArithmetic( |
src/Module.zig+48| ... | @@ -1198,6 +1198,30 @@ pub const Scope = struct { | ... | @@ -1198,6 +1198,30 @@ pub const Scope = struct { |
| 1198 | gz.astgen.extra.appendSliceAssumeCapacity(gz.instructions.items); | 1198 | gz.astgen.extra.appendSliceAssumeCapacity(gz.instructions.items); |
| 1199 | } | 1199 | } |
| 1200 | 1200 | ||
| 1201 | /// Same as `setBlockBody` except we don't copy instructions which are | ||
| 1202 | /// `store_to_block_ptr` instructions with lhs set to .none. | ||
| 1203 | pub fn setBlockBodyEliding(gz: GenZir, inst: Zir.Inst.Index) !void { | ||
| 1204 | const gpa = gz.astgen.gpa; | ||
| 1205 | try gz.astgen.extra.ensureCapacity(gpa, gz.astgen.extra.items.len + | ||
| 1206 | @typeInfo(Zir.Inst.Block).Struct.fields.len + gz.instructions.items.len); | ||
| 1207 | const zir_datas = gz.astgen.instructions.items(.data); | ||
| 1208 | const zir_tags = gz.astgen.instructions.items(.tag); | ||
| 1209 | const block_pl_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Block{ | ||
| 1210 | .body_len = @intCast(u32, gz.instructions.items.len), | ||
| 1211 | }); | ||
| 1212 | zir_datas[inst].pl_node.payload_index = block_pl_index; | ||
| 1213 | for (gz.instructions.items) |sub_inst| { | ||
| 1214 | if (zir_tags[sub_inst] == .store_to_block_ptr and | ||
| 1215 | zir_datas[sub_inst].bin.lhs == .none) | ||
| 1216 | { | ||
| 1217 | // Decrement `body_len`. | ||
| 1218 | gz.astgen.extra.items[block_pl_index] -= 1; | ||
| 1219 | continue; | ||
| 1220 | } | ||
| 1221 | gz.astgen.extra.appendAssumeCapacity(sub_inst); | ||
| 1222 | } | ||
| 1223 | } | ||
| 1224 | |||
| 1201 | pub fn identAsString(gz: *GenZir, ident_token: ast.TokenIndex) !u32 { | 1225 | pub fn identAsString(gz: *GenZir, ident_token: ast.TokenIndex) !u32 { |
| 1202 | const astgen = gz.astgen; | 1226 | const astgen = gz.astgen; |
| 1203 | const gpa = astgen.gpa; | 1227 | const gpa = astgen.gpa; |
| ... | @@ -1445,6 +1469,30 @@ pub const Scope = struct { | ... | @@ -1445,6 +1469,30 @@ pub const Scope = struct { |
| 1445 | return gz.indexToRef(new_index); | 1469 | return gz.indexToRef(new_index); |
| 1446 | } | 1470 | } |
| 1447 | 1471 | ||
| 1472 | pub fn addExtendedPayload( | ||
| 1473 | gz: *GenZir, | ||
| 1474 | opcode: Zir.Inst.Extended, | ||
| 1475 | extra: anytype, | ||
| 1476 | ) !Zir.Inst.Ref { | ||
| 1477 | const gpa = gz.astgen.gpa; | ||
| 1478 | |||
| 1479 | try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1); | ||
| 1480 | try gz.astgen.instructions.ensureCapacity(gpa, gz.astgen.instructions.len + 1); | ||
| 1481 | |||
| 1482 | const payload_index = try gz.astgen.addExtra(extra); | ||
| 1483 | const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len); | ||
| 1484 | gz.astgen.instructions.appendAssumeCapacity(.{ | ||
| 1485 | .tag = .extended, | ||
| 1486 | .data = .{ .extended = .{ | ||
| 1487 | .opcode = opcode, | ||
| 1488 | .small = undefined, | ||
| 1489 | .operand = payload_index, | ||
| 1490 | } }, | ||
| 1491 | }); | ||
| 1492 | gz.instructions.appendAssumeCapacity(new_index); | ||
| 1493 | return gz.indexToRef(new_index); | ||
| 1494 | } | ||
| 1495 | |||
| 1448 | pub fn addArrayTypeSentinel( | 1496 | pub fn addArrayTypeSentinel( |
| 1449 | gz: *GenZir, | 1497 | gz: *GenZir, |
| 1450 | len: Zir.Inst.Ref, | 1498 | len: Zir.Inst.Ref, |
src/Sema.zig+687-162| ... | @@ -131,159 +131,227 @@ pub fn analyzeBody( | ... | @@ -131,159 +131,227 @@ pub fn analyzeBody( |
| 131 | while (true) : (i += 1) { | 131 | while (true) : (i += 1) { |
| 132 | const inst = body[i]; | 132 | const inst = body[i]; |
| 133 | map[inst] = switch (tags[inst]) { | 133 | map[inst] = switch (tags[inst]) { |
| 134 | .elided => continue, | 134 | // zig fmt: off |
| 135 | 135 | .alloc => try sema.zirAlloc(block, inst), | |
| 136 | .alloc => try sema.zirAlloc(block, inst), | 136 | .alloc_inferred => try sema.zirAllocInferred(block, inst, Type.initTag(.inferred_alloc_const)), |
| 137 | .alloc_inferred => try sema.zirAllocInferred(block, inst, Type.initTag(.inferred_alloc_const)), | 137 | .alloc_inferred_mut => try sema.zirAllocInferred(block, inst, Type.initTag(.inferred_alloc_mut)), |
| 138 | .alloc_inferred_mut => try sema.zirAllocInferred(block, inst, Type.initTag(.inferred_alloc_mut)), | 138 | .alloc_mut => try sema.zirAllocMut(block, inst), |
| 139 | .alloc_mut => try sema.zirAllocMut(block, inst), | 139 | .array_cat => try sema.zirArrayCat(block, inst), |
| 140 | .array_cat => try sema.zirArrayCat(block, inst), | 140 | .array_mul => try sema.zirArrayMul(block, inst), |
| 141 | .array_mul => try sema.zirArrayMul(block, inst), | 141 | .array_type => try sema.zirArrayType(block, inst), |
| 142 | .array_type => try sema.zirArrayType(block, inst), | 142 | .array_type_sentinel => try sema.zirArrayTypeSentinel(block, inst), |
| 143 | .array_type_sentinel => try sema.zirArrayTypeSentinel(block, inst), | 143 | .as => try sema.zirAs(block, inst), |
| 144 | .as => try sema.zirAs(block, inst), | 144 | .as_node => try sema.zirAsNode(block, inst), |
| 145 | .as_node => try sema.zirAsNode(block, inst), | 145 | .@"asm" => try sema.zirAsm(block, inst, false), |
| 146 | .@"asm" => try sema.zirAsm(block, inst, false), | 146 | .asm_volatile => try sema.zirAsm(block, inst, true), |
| 147 | .asm_volatile => try sema.zirAsm(block, inst, true), | 147 | .bit_and => try sema.zirBitwise(block, inst, .bit_and), |
| 148 | .bit_and => try sema.zirBitwise(block, inst, .bit_and), | 148 | .bit_not => try sema.zirBitNot(block, inst), |
| 149 | .bit_not => try sema.zirBitNot(block, inst), | 149 | .bit_or => try sema.zirBitwise(block, inst, .bit_or), |
| 150 | .bit_or => try sema.zirBitwise(block, inst, .bit_or), | 150 | .bitcast => try sema.zirBitcast(block, inst), |
| 151 | .bitcast => try sema.zirBitcast(block, inst), | 151 | .bitcast_result_ptr => try sema.zirBitcastResultPtr(block, inst), |
| 152 | .bitcast_result_ptr => try sema.zirBitcastResultPtr(block, inst), | 152 | .block => try sema.zirBlock(block, inst), |
| 153 | .block => try sema.zirBlock(block, inst), | 153 | .bool_not => try sema.zirBoolNot(block, inst), |
| 154 | .bool_not => try sema.zirBoolNot(block, inst), | 154 | .bool_and => try sema.zirBoolOp(block, inst, false), |
| 155 | .bool_and => try sema.zirBoolOp(block, inst, false), | 155 | .bool_or => try sema.zirBoolOp(block, inst, true), |
| 156 | .bool_or => try sema.zirBoolOp(block, inst, true), | 156 | .bool_br_and => try sema.zirBoolBr(block, inst, false), |
| 157 | .bool_br_and => try sema.zirBoolBr(block, inst, false), | 157 | .bool_br_or => try sema.zirBoolBr(block, inst, true), |
| 158 | .bool_br_or => try sema.zirBoolBr(block, inst, true), | 158 | .c_import => try sema.zirCImport(block, inst), |
| 159 | .call => try sema.zirCall(block, inst, .auto, false), | 159 | .call => try sema.zirCall(block, inst, .auto, false), |
| 160 | .call_chkused => try sema.zirCall(block, inst, .auto, true), | 160 | .call_chkused => try sema.zirCall(block, inst, .auto, true), |
| 161 | .call_compile_time => try sema.zirCall(block, inst, .compile_time, false), | 161 | .call_compile_time => try sema.zirCall(block, inst, .compile_time, false), |
| 162 | .call_none => try sema.zirCallNone(block, inst, false), | 162 | .call_none => try sema.zirCallNone(block, inst, false), |
| 163 | .call_none_chkused => try sema.zirCallNone(block, inst, true), | 163 | .call_none_chkused => try sema.zirCallNone(block, inst, true), |
| 164 | .cmp_eq => try sema.zirCmp(block, inst, .eq), | 164 | .cmp_eq => try sema.zirCmp(block, inst, .eq), |
| 165 | .cmp_gt => try sema.zirCmp(block, inst, .gt), | 165 | .cmp_gt => try sema.zirCmp(block, inst, .gt), |
| 166 | .cmp_gte => try sema.zirCmp(block, inst, .gte), | 166 | .cmp_gte => try sema.zirCmp(block, inst, .gte), |
| 167 | .cmp_lt => try sema.zirCmp(block, inst, .lt), | 167 | .cmp_lt => try sema.zirCmp(block, inst, .lt), |
| 168 | .cmp_lte => try sema.zirCmp(block, inst, .lte), | 168 | .cmp_lte => try sema.zirCmp(block, inst, .lte), |
| 169 | .cmp_neq => try sema.zirCmp(block, inst, .neq), | 169 | .cmp_neq => try sema.zirCmp(block, inst, .neq), |
| 170 | .coerce_result_ptr => try sema.zirCoerceResultPtr(block, inst), | 170 | .coerce_result_ptr => try sema.zirCoerceResultPtr(block, inst), |
| 171 | .decl_ref => try sema.zirDeclRef(block, inst), | 171 | .decl_ref => try sema.zirDeclRef(block, inst), |
| 172 | .decl_val => try sema.zirDeclVal(block, inst), | 172 | .decl_val => try sema.zirDeclVal(block, inst), |
| 173 | .load => try sema.zirLoad(block, inst), | 173 | .load => try sema.zirLoad(block, inst), |
| 174 | .elem_ptr => try sema.zirElemPtr(block, inst), | 174 | .elem_ptr => try sema.zirElemPtr(block, inst), |
| 175 | .elem_ptr_node => try sema.zirElemPtrNode(block, inst), | 175 | .elem_ptr_node => try sema.zirElemPtrNode(block, inst), |
| 176 | .elem_val => try sema.zirElemVal(block, inst), | 176 | .elem_val => try sema.zirElemVal(block, inst), |
| 177 | .elem_val_node => try sema.zirElemValNode(block, inst), | 177 | .elem_val_node => try sema.zirElemValNode(block, inst), |
| 178 | .enum_literal => try sema.zirEnumLiteral(block, inst), | 178 | .enum_literal => try sema.zirEnumLiteral(block, inst), |
| 179 | .enum_literal_small => try sema.zirEnumLiteralSmall(block, inst), | 179 | .enum_literal_small => try sema.zirEnumLiteralSmall(block, inst), |
| 180 | .enum_to_int => try sema.zirEnumToInt(block, inst), | 180 | .enum_to_int => try sema.zirEnumToInt(block, inst), |
| 181 | .int_to_enum => try sema.zirIntToEnum(block, inst), | 181 | .int_to_enum => try sema.zirIntToEnum(block, inst), |
| 182 | .err_union_code => try sema.zirErrUnionCode(block, inst), | 182 | .err_union_code => try sema.zirErrUnionCode(block, inst), |
| 183 | .err_union_code_ptr => try sema.zirErrUnionCodePtr(block, inst), | 183 | .err_union_code_ptr => try sema.zirErrUnionCodePtr(block, inst), |
| 184 | .err_union_payload_safe => try sema.zirErrUnionPayload(block, inst, true), | 184 | .err_union_payload_safe => try sema.zirErrUnionPayload(block, inst, true), |
| 185 | .err_union_payload_safe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, true), | 185 | .err_union_payload_safe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, true), |
| 186 | .err_union_payload_unsafe => try sema.zirErrUnionPayload(block, inst, false), | 186 | .err_union_payload_unsafe => try sema.zirErrUnionPayload(block, inst, false), |
| 187 | .err_union_payload_unsafe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, false), | 187 | .err_union_payload_unsafe_ptr => try sema.zirErrUnionPayloadPtr(block, inst, false), |
| 188 | .error_union_type => try sema.zirErrorUnionType(block, inst), | 188 | .error_union_type => try sema.zirErrorUnionType(block, inst), |
| 189 | .error_value => try sema.zirErrorValue(block, inst), | 189 | .error_value => try sema.zirErrorValue(block, inst), |
| 190 | .error_to_int => try sema.zirErrorToInt(block, inst), | 190 | .error_to_int => try sema.zirErrorToInt(block, inst), |
| 191 | .int_to_error => try sema.zirIntToError(block, inst), | 191 | .int_to_error => try sema.zirIntToError(block, inst), |
| 192 | .field_ptr => try sema.zirFieldPtr(block, inst), | 192 | .field_ptr => try sema.zirFieldPtr(block, inst), |
| 193 | .field_ptr_named => try sema.zirFieldPtrNamed(block, inst), | 193 | .field_ptr_named => try sema.zirFieldPtrNamed(block, inst), |
| 194 | .field_val => try sema.zirFieldVal(block, inst), | 194 | .field_val => try sema.zirFieldVal(block, inst), |
| 195 | .field_val_named => try sema.zirFieldValNamed(block, inst), | 195 | .field_val_named => try sema.zirFieldValNamed(block, inst), |
| 196 | .floatcast => try sema.zirFloatcast(block, inst), | 196 | .floatcast => try sema.zirFloatcast(block, inst), |
| 197 | .func => try sema.zirFunc(block, inst, false), | 197 | .func => try sema.zirFunc(block, inst, false), |
| 198 | .func_extra => try sema.zirFuncExtra(block, inst, false), | 198 | .func_extra => try sema.zirFuncExtra(block, inst, false), |
| 199 | .func_extra_var_args => try sema.zirFuncExtra(block, inst, true), | 199 | .func_extra_var_args => try sema.zirFuncExtra(block, inst, true), |
| 200 | .func_var_args => try sema.zirFunc(block, inst, true), | 200 | .func_var_args => try sema.zirFunc(block, inst, true), |
| 201 | .has_decl => try sema.zirHasDecl(block, inst), | 201 | .import => try sema.zirImport(block, inst), |
| 202 | .import => try sema.zirImport(block, inst), | 202 | .indexable_ptr_len => try sema.zirIndexablePtrLen(block, inst), |
| 203 | .indexable_ptr_len => try sema.zirIndexablePtrLen(block, inst), | 203 | .int => try sema.zirInt(block, inst), |
| 204 | .int => try sema.zirInt(block, inst), | 204 | .float => try sema.zirFloat(block, inst), |
| 205 | .float => try sema.zirFloat(block, inst), | 205 | .float128 => try sema.zirFloat128(block, inst), |
| 206 | .float128 => try sema.zirFloat128(block, inst), | 206 | .int_type => try sema.zirIntType(block, inst), |
| 207 | .int_type => try sema.zirIntType(block, inst), | 207 | .intcast => try sema.zirIntcast(block, inst), |
| 208 | .intcast => try sema.zirIntcast(block, inst), | 208 | .is_err => try sema.zirIsErr(block, inst), |
| 209 | .is_err => try sema.zirIsErr(block, inst), | 209 | .is_err_ptr => try sema.zirIsErrPtr(block, inst), |
| 210 | .is_err_ptr => try sema.zirIsErrPtr(block, inst), | 210 | .is_non_null => try sema.zirIsNull(block, inst, true), |
| 211 | .is_non_null => try sema.zirIsNull(block, inst, true), | 211 | .is_non_null_ptr => try sema.zirIsNullPtr(block, inst, true), |
| 212 | .is_non_null_ptr => try sema.zirIsNullPtr(block, inst, true), | 212 | .is_null => try sema.zirIsNull(block, inst, false), |
| 213 | .is_null => try sema.zirIsNull(block, inst, false), | 213 | .is_null_ptr => try sema.zirIsNullPtr(block, inst, false), |
| 214 | .is_null_ptr => try sema.zirIsNullPtr(block, inst, false), | 214 | .loop => try sema.zirLoop(block, inst), |
| 215 | .loop => try sema.zirLoop(block, inst), | 215 | .merge_error_sets => try sema.zirMergeErrorSets(block, inst), |
| 216 | .merge_error_sets => try sema.zirMergeErrorSets(block, inst), | 216 | .negate => try sema.zirNegate(block, inst, .sub), |
| 217 | .negate => try sema.zirNegate(block, inst, .sub), | 217 | .negate_wrap => try sema.zirNegate(block, inst, .subwrap), |
| 218 | .negate_wrap => try sema.zirNegate(block, inst, .subwrap), | 218 | .optional_payload_safe => try sema.zirOptionalPayload(block, inst, true), |
| 219 | .optional_payload_safe => try sema.zirOptionalPayload(block, inst, true), | 219 | .optional_payload_safe_ptr => try sema.zirOptionalPayloadPtr(block, inst, true), |
| 220 | .optional_payload_safe_ptr => try sema.zirOptionalPayloadPtr(block, inst, true), | 220 | .optional_payload_unsafe => try sema.zirOptionalPayload(block, inst, false), |
| 221 | .optional_payload_unsafe => try sema.zirOptionalPayload(block, inst, false), | 221 | .optional_payload_unsafe_ptr => try sema.zirOptionalPayloadPtr(block, inst, false), |
| 222 | .optional_payload_unsafe_ptr => try sema.zirOptionalPayloadPtr(block, inst, false), | 222 | .optional_type => try sema.zirOptionalType(block, inst), |
| 223 | .optional_type => try sema.zirOptionalType(block, inst), | 223 | .optional_type_from_ptr_elem => try sema.zirOptionalTypeFromPtrElem(block, inst), |
| 224 | .optional_type_from_ptr_elem => try sema.zirOptionalTypeFromPtrElem(block, inst), | 224 | .param_type => try sema.zirParamType(block, inst), |
| 225 | .param_type => try sema.zirParamType(block, inst), | 225 | .ptr_type => try sema.zirPtrType(block, inst), |
| 226 | .ptr_type => try sema.zirPtrType(block, inst), | 226 | .ptr_type_simple => try sema.zirPtrTypeSimple(block, inst), |
| 227 | .ptr_type_simple => try sema.zirPtrTypeSimple(block, inst), | 227 | .ptrtoint => try sema.zirPtrtoint(block, inst), |
| 228 | .ptrtoint => try sema.zirPtrtoint(block, inst), | 228 | .ref => try sema.zirRef(block, inst), |
| 229 | .ref => try sema.zirRef(block, inst), | 229 | .ret_ptr => try sema.zirRetPtr(block, inst), |
| 230 | .ret_ptr => try sema.zirRetPtr(block, inst), | 230 | .ret_type => try sema.zirRetType(block, inst), |
| 231 | .ret_type => try sema.zirRetType(block, inst), | 231 | .shl => try sema.zirShl(block, inst), |
| 232 | .shl => try sema.zirShl(block, inst), | 232 | .shr => try sema.zirShr(block, inst), |
| 233 | .shr => try sema.zirShr(block, inst), | 233 | .slice_end => try sema.zirSliceEnd(block, inst), |
| 234 | .slice_end => try sema.zirSliceEnd(block, inst), | 234 | .slice_sentinel => try sema.zirSliceSentinel(block, inst), |
| 235 | .slice_sentinel => try sema.zirSliceSentinel(block, inst), | 235 | .slice_start => try sema.zirSliceStart(block, inst), |
| 236 | .slice_start => try sema.zirSliceStart(block, inst), | 236 | .str => try sema.zirStr(block, inst), |
| 237 | .str => try sema.zirStr(block, inst), | 237 | .switch_block => try sema.zirSwitchBlock(block, inst, false, .none), |
| 238 | .switch_block => try sema.zirSwitchBlock(block, inst, false, .none), | 238 | .switch_block_multi => try sema.zirSwitchBlockMulti(block, inst, false, .none), |
| 239 | .switch_block_multi => try sema.zirSwitchBlockMulti(block, inst, false, .none), | 239 | .switch_block_else => try sema.zirSwitchBlock(block, inst, false, .@"else"), |
| 240 | .switch_block_else => try sema.zirSwitchBlock(block, inst, false, .@"else"), | 240 | .switch_block_else_multi => try sema.zirSwitchBlockMulti(block, inst, false, .@"else"), |
| 241 | .switch_block_else_multi => try sema.zirSwitchBlockMulti(block, inst, false, .@"else"), | 241 | .switch_block_under => try sema.zirSwitchBlock(block, inst, false, .under), |
| 242 | .switch_block_under => try sema.zirSwitchBlock(block, inst, false, .under), | 242 | .switch_block_under_multi => try sema.zirSwitchBlockMulti(block, inst, false, .under), |
| 243 | .switch_block_under_multi => try sema.zirSwitchBlockMulti(block, inst, false, .under), | 243 | .switch_block_ref => try sema.zirSwitchBlock(block, inst, true, .none), |
| 244 | .switch_block_ref => try sema.zirSwitchBlock(block, inst, true, .none), | 244 | .switch_block_ref_multi => try sema.zirSwitchBlockMulti(block, inst, true, .none), |
| 245 | .switch_block_ref_multi => try sema.zirSwitchBlockMulti(block, inst, true, .none), | 245 | .switch_block_ref_else => try sema.zirSwitchBlock(block, inst, true, .@"else"), |
| 246 | .switch_block_ref_else => try sema.zirSwitchBlock(block, inst, true, .@"else"), | 246 | .switch_block_ref_else_multi => try sema.zirSwitchBlockMulti(block, inst, true, .@"else"), |
| 247 | .switch_block_ref_else_multi => try sema.zirSwitchBlockMulti(block, inst, true, .@"else"), | 247 | .switch_block_ref_under => try sema.zirSwitchBlock(block, inst, true, .under), |
| 248 | .switch_block_ref_under => try sema.zirSwitchBlock(block, inst, true, .under), | ||
| 249 | .switch_block_ref_under_multi => try sema.zirSwitchBlockMulti(block, inst, true, .under), | 248 | .switch_block_ref_under_multi => try sema.zirSwitchBlockMulti(block, inst, true, .under), |
| 250 | .switch_capture => try sema.zirSwitchCapture(block, inst, false, false), | 249 | .switch_capture => try sema.zirSwitchCapture(block, inst, false, false), |
| 251 | .switch_capture_ref => try sema.zirSwitchCapture(block, inst, false, true), | 250 | .switch_capture_ref => try sema.zirSwitchCapture(block, inst, false, true), |
| 252 | .switch_capture_multi => try sema.zirSwitchCapture(block, inst, true, false), | 251 | .switch_capture_multi => try sema.zirSwitchCapture(block, inst, true, false), |
| 253 | .switch_capture_multi_ref => try sema.zirSwitchCapture(block, inst, true, true), | 252 | .switch_capture_multi_ref => try sema.zirSwitchCapture(block, inst, true, true), |
| 254 | .switch_capture_else => try sema.zirSwitchCaptureElse(block, inst, false), | 253 | .switch_capture_else => try sema.zirSwitchCaptureElse(block, inst, false), |
| 255 | .switch_capture_else_ref => try sema.zirSwitchCaptureElse(block, inst, true), | 254 | .switch_capture_else_ref => try sema.zirSwitchCaptureElse(block, inst, true), |
| 256 | .type_info => try sema.zirTypeInfo(block, inst), | 255 | .type_info => try sema.zirTypeInfo(block, inst), |
| 257 | .size_of => try sema.zirSizeOf(block, inst), | 256 | .size_of => try sema.zirSizeOf(block, inst), |
| 258 | .bit_size_of => try sema.zirBitSizeOf(block, inst), | 257 | .bit_size_of => try sema.zirBitSizeOf(block, inst), |
| 259 | .this => try sema.zirThis(block, inst), | 258 | .this => try sema.zirThis(block, inst), |
| 260 | .fence => try sema.zirFence(block, inst), | 259 | .ret_addr => try sema.zirRetAddr(block, inst), |
| 261 | .ret_addr => try sema.zirRetAddr(block, inst), | 260 | .builtin_src => try sema.zirBuiltinSrc(block, inst), |
| 262 | .builtin_src => try sema.zirBuiltinSrc(block, inst), | 261 | .typeof => try sema.zirTypeof(block, inst), |
| 263 | .typeof => try sema.zirTypeof(block, inst), | 262 | .typeof_elem => try sema.zirTypeofElem(block, inst), |
| 264 | .typeof_elem => try sema.zirTypeofElem(block, inst), | 263 | .typeof_peer => try sema.zirTypeofPeer(block, inst), |
| 265 | .typeof_peer => try sema.zirTypeofPeer(block, inst), | 264 | .log2_int_type => try sema.zirLog2IntType(block, inst), |
| 266 | .log2_int_type => try sema.zirLog2IntType(block, inst), | 265 | .typeof_log2_int_type => try sema.zirTypeofLog2IntType(block, inst), |
| 267 | .xor => try sema.zirBitwise(block, inst, .xor), | 266 | .xor => try sema.zirBitwise(block, inst, .xor), |
| 268 | .struct_init_empty => try sema.zirStructInitEmpty(block, inst), | 267 | .struct_init_empty => try sema.zirStructInitEmpty(block, inst), |
| 269 | .struct_init => try sema.zirStructInit(block, inst), | 268 | .struct_init => try sema.zirStructInit(block, inst), |
| 270 | .field_type => try sema.zirFieldType(block, inst), | 269 | .union_init_ptr => try sema.zirUnionInitPtr(block, inst), |
| 271 | 270 | .field_type => try sema.zirFieldType(block, inst), | |
| 272 | .struct_decl => try sema.zirStructDecl(block, inst, .Auto), | 271 | .error_return_trace => try sema.zirErrorReturnTrace(block, inst), |
| 273 | .struct_decl_packed => try sema.zirStructDecl(block, inst, .Packed), | 272 | .frame => try sema.zirFrame(block, inst), |
| 274 | .struct_decl_extern => try sema.zirStructDecl(block, inst, .Extern), | 273 | .frame_address => try sema.zirFrameAddress(block, inst), |
| 275 | .enum_decl => try sema.zirEnumDecl(block, inst, false), | 274 | .ptr_to_int => try sema.zirPtrToInt(block, inst), |
| 275 | .align_of => try sema.zirAlignOf(block, inst), | ||
| 276 | .bool_to_int => try sema.zirBoolToInt(block, inst), | ||
| 277 | .embed_file => try sema.zirEmbedFile(block, inst), | ||
| 278 | .error_name => try sema.zirErrorName(block, inst), | ||
| 279 | .tag_name => try sema.zirTagName(block, inst), | ||
| 280 | .reify => try sema.zirReify(block, inst), | ||
| 281 | .type_name => try sema.zirTypeName(block, inst), | ||
| 282 | .frame_type => try sema.zirFrameType(block, inst), | ||
| 283 | .frame_size => try sema.zirFrameSize(block, inst), | ||
| 284 | .float_to_int => try sema.zirFloatToInt(block, inst), | ||
| 285 | .int_to_float => try sema.zirIntToFloat(block, inst), | ||
| 286 | .int_to_ptr => try sema.zirIntToPtr(block, inst), | ||
| 287 | .float_cast => try sema.zirFloatCast(block, inst), | ||
| 288 | .int_cast => try sema.zirIntCast(block, inst), | ||
| 289 | .err_set_cast => try sema.zirErrSetCast(block, inst), | ||
| 290 | .ptr_cast => try sema.zirPtrCast(block, inst), | ||
| 291 | .truncate => try sema.zirTruncate(block, inst), | ||
| 292 | .align_cast => try sema.zirAlignCast(block, inst), | ||
| 293 | .has_decl => try sema.zirHasDecl(block, inst), | ||
| 294 | .has_field => try sema.zirHasField(block, inst), | ||
| 295 | .clz => try sema.zirClz(block, inst), | ||
| 296 | .ctz => try sema.zirCtz(block, inst), | ||
| 297 | .pop_count => try sema.zirPopCount(block, inst), | ||
| 298 | .byte_swap => try sema.zirByteSwap(block, inst), | ||
| 299 | .bit_reverse => try sema.zirBitReverse(block, inst), | ||
| 300 | .div_exact => try sema.zirDivExact(block, inst), | ||
| 301 | .div_floor => try sema.zirDivFloor(block, inst), | ||
| 302 | .div_trunc => try sema.zirDivTrunc(block, inst), | ||
| 303 | .mod => try sema.zirMod(block, inst), | ||
| 304 | .rem => try sema.zirRem(block, inst), | ||
| 305 | .shl_exact => try sema.zirShlExact(block, inst), | ||
| 306 | .shr_exact => try sema.zirShrExact(block, inst), | ||
| 307 | .bit_offset_of => try sema.zirBitOffsetOf(block, inst), | ||
| 308 | .byte_offset_of => try sema.zirByteOffsetOf(block, inst), | ||
| 309 | .cmpxchg_strong => try sema.zirCmpxchg(block, inst), | ||
| 310 | .cmpxchg_weak => try sema.zirCmpxchg(block, inst), | ||
| 311 | .splat => try sema.zirSplat(block, inst), | ||
| 312 | .reduce => try sema.zirReduce(block, inst), | ||
| 313 | .shuffle => try sema.zirShuffle(block, inst), | ||
| 314 | .atomic_load => try sema.zirAtomicLoad(block, inst), | ||
| 315 | .atomic_rmw => try sema.zirAtomicRmw(block, inst), | ||
| 316 | .atomic_store => try sema.zirAtomicStore(block, inst), | ||
| 317 | .mul_add => try sema.zirMulAdd(block, inst), | ||
| 318 | .builtin_call => try sema.zirBuiltinCall(block, inst), | ||
| 319 | .field_ptr_type => try sema.zirFieldPtrType(block, inst), | ||
| 320 | .field_parent_ptr => try sema.zirFieldParentPtr(block, inst), | ||
| 321 | .memcpy => try sema.zirMemcpy(block, inst), | ||
| 322 | .memset => try sema.zirMemset(block, inst), | ||
| 323 | .builtin_async_call => try sema.zirBuiltinAsyncCall(block, inst), | ||
| 324 | .extended => try sema.zirExtended(block, inst), | ||
| 325 | |||
| 326 | .sqrt => try sema.zirUnaryMath(block, inst), | ||
| 327 | .sin => try sema.zirUnaryMath(block, inst), | ||
| 328 | .cos => try sema.zirUnaryMath(block, inst), | ||
| 329 | .exp => try sema.zirUnaryMath(block, inst), | ||
| 330 | .exp2 => try sema.zirUnaryMath(block, inst), | ||
| 331 | .log => try sema.zirUnaryMath(block, inst), | ||
| 332 | .log2 => try sema.zirUnaryMath(block, inst), | ||
| 333 | .log10 => try sema.zirUnaryMath(block, inst), | ||
| 334 | .fabs => try sema.zirUnaryMath(block, inst), | ||
| 335 | .floor => try sema.zirUnaryMath(block, inst), | ||
| 336 | .ceil => try sema.zirUnaryMath(block, inst), | ||
| 337 | .trunc => try sema.zirUnaryMath(block, inst), | ||
| 338 | .round => try sema.zirUnaryMath(block, inst), | ||
| 339 | |||
| 340 | .struct_decl => try sema.zirStructDecl(block, inst, .Auto), | ||
| 341 | .struct_decl_packed => try sema.zirStructDecl(block, inst, .Packed), | ||
| 342 | .struct_decl_extern => try sema.zirStructDecl(block, inst, .Extern), | ||
| 343 | .enum_decl => try sema.zirEnumDecl(block, inst, false), | ||
| 276 | .enum_decl_nonexhaustive => try sema.zirEnumDecl(block, inst, true), | 344 | .enum_decl_nonexhaustive => try sema.zirEnumDecl(block, inst, true), |
| 277 | .union_decl => try sema.zirUnionDecl(block, inst), | 345 | .union_decl => try sema.zirUnionDecl(block, inst), |
| 278 | .opaque_decl => try sema.zirOpaqueDecl(block, inst), | 346 | .opaque_decl => try sema.zirOpaqueDecl(block, inst), |
| 279 | 347 | ||
| 280 | .add => try sema.zirArithmetic(block, inst), | 348 | .add => try sema.zirArithmetic(block, inst), |
| 281 | .addwrap => try sema.zirArithmetic(block, inst), | 349 | .addwrap => try sema.zirArithmetic(block, inst), |
| 282 | .div => try sema.zirArithmetic(block, inst), | 350 | .div => try sema.zirArithmetic(block, inst), |
| 283 | .mod_rem => try sema.zirArithmetic(block, inst), | 351 | .mod_rem => try sema.zirArithmetic(block, inst), |
| 284 | .mul => try sema.zirArithmetic(block, inst), | 352 | .mul => try sema.zirArithmetic(block, inst), |
| 285 | .mulwrap => try sema.zirArithmetic(block, inst), | 353 | .mulwrap => try sema.zirArithmetic(block, inst), |
| 286 | .sub => try sema.zirArithmetic(block, inst), | 354 | .sub => try sema.zirArithmetic(block, inst), |
| 287 | .subwrap => try sema.zirArithmetic(block, inst), | 355 | .subwrap => try sema.zirArithmetic(block, inst), |
| 288 | 356 | ||
| 289 | .add_with_overflow => try sema.zirOverflowArithmetic(block, inst), | 357 | .add_with_overflow => try sema.zirOverflowArithmetic(block, inst), |
| ... | @@ -294,15 +362,17 @@ pub fn analyzeBody( | ... | @@ -294,15 +362,17 @@ pub fn analyzeBody( |
| 294 | // Instructions that we know to *always* be noreturn based solely on their tag. | 362 | // Instructions that we know to *always* be noreturn based solely on their tag. |
| 295 | // These functions match the return type of analyzeBody so that we can | 363 | // These functions match the return type of analyzeBody so that we can |
| 296 | // tail call them here. | 364 | // tail call them here. |
| 297 | .condbr => return sema.zirCondbr(block, inst), | 365 | .break_inline => return inst, |
| 298 | .@"break" => return sema.zirBreak(block, inst), | 366 | .condbr => return sema.zirCondbr(block, inst), |
| 299 | .break_inline => return inst, | 367 | .@"break" => return sema.zirBreak(block, inst), |
| 300 | .compile_error => return sema.zirCompileError(block, inst), | 368 | .compile_error => return sema.zirCompileError(block, inst), |
| 301 | .ret_coerce => return sema.zirRetTok(block, inst, true), | 369 | .ret_coerce => return sema.zirRetTok(block, inst, true), |
| 302 | .ret_node => return sema.zirRetNode(block, inst), | 370 | .ret_node => return sema.zirRetNode(block, inst), |
| 303 | .ret_tok => return sema.zirRetTok(block, inst, false), | 371 | .ret_tok => return sema.zirRetTok(block, inst, false), |
| 304 | .@"unreachable" => return sema.zirUnreachable(block, inst), | 372 | .@"unreachable" => return sema.zirUnreachable(block, inst), |
| 305 | .repeat => return sema.zirRepeat(block, inst), | 373 | .repeat => return sema.zirRepeat(block, inst), |
| 374 | .panic => return sema.zirPanic(block, inst), | ||
| 375 | // zig fmt: on | ||
| 306 | 376 | ||
| 307 | // Instructions that we know can *never* be noreturn based solely on | 377 | // Instructions that we know can *never* be noreturn based solely on |
| 308 | // their tag. We avoid needlessly checking if they are noreturn and | 378 | // their tag. We avoid needlessly checking if they are noreturn and |
| ... | @@ -313,6 +383,10 @@ pub fn analyzeBody( | ... | @@ -313,6 +383,10 @@ pub fn analyzeBody( |
| 313 | try sema.zirBreakpoint(block, inst); | 383 | try sema.zirBreakpoint(block, inst); |
| 314 | continue; | 384 | continue; |
| 315 | }, | 385 | }, |
| 386 | .fence => { | ||
| 387 | try sema.zirFence(block, inst); | ||
| 388 | continue; | ||
| 389 | }, | ||
| 316 | .dbg_stmt_node => { | 390 | .dbg_stmt_node => { |
| 317 | try sema.zirDbgStmtNode(block, inst); | 391 | try sema.zirDbgStmtNode(block, inst); |
| 318 | continue; | 392 | continue; |
| ... | @@ -365,6 +439,22 @@ pub fn analyzeBody( | ... | @@ -365,6 +439,22 @@ pub fn analyzeBody( |
| 365 | try sema.zirExport(block, inst); | 439 | try sema.zirExport(block, inst); |
| 366 | continue; | 440 | continue; |
| 367 | }, | 441 | }, |
| 442 | .set_align_stack => { | ||
| 443 | try sema.zirSetAlignStack(block, inst); | ||
| 444 | continue; | ||
| 445 | }, | ||
| 446 | .set_cold => { | ||
| 447 | try sema.zirSetAlignStack(block, inst); | ||
| 448 | continue; | ||
| 449 | }, | ||
| 450 | .set_float_mode => { | ||
| 451 | try sema.zirSetFloatMode(block, inst); | ||
| 452 | continue; | ||
| 453 | }, | ||
| 454 | .set_runtime_safety => { | ||
| 455 | try sema.zirSetRuntimeSafety(block, inst); | ||
| 456 | continue; | ||
| 457 | }, | ||
| 368 | 458 | ||
| 369 | // Special case instructions to handle comptime control flow. | 459 | // Special case instructions to handle comptime control flow. |
| 370 | .repeat_inline => { | 460 | .repeat_inline => { |
| ... | @@ -1382,6 +1472,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -1382,6 +1472,13 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1382 | return always_noreturn; | 1472 | return always_noreturn; |
| 1383 | } | 1473 | } |
| 1384 | 1474 | ||
| 1475 | fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { | ||
| 1476 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 1477 | const src: LazySrcLoc = inst_data.src(); | ||
| 1478 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirPanic", .{}); | ||
| 1479 | //return always_noreturn; | ||
| 1480 | } | ||
| 1481 | |||
| 1385 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1482 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1386 | const tracy = trace(@src()); | 1483 | const tracy = trace(@src()); |
| 1387 | defer tracy.end(); | 1484 | defer tracy.end(); |
| ... | @@ -1443,6 +1540,16 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -1443,6 +1540,16 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 1443 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); | 1540 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); |
| 1444 | } | 1541 | } |
| 1445 | 1542 | ||
| 1543 | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 1544 | const tracy = trace(@src()); | ||
| 1545 | defer tracy.end(); | ||
| 1546 | |||
| 1547 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 1548 | const src = inst_data.src(); | ||
| 1549 | |||
| 1550 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{}); | ||
| 1551 | } | ||
| 1552 | |||
| 1446 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1553 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 1447 | const tracy = trace(@src()); | 1554 | const tracy = trace(@src()); |
| 1448 | defer tracy.end(); | 1555 | defer tracy.end(); |
| ... | @@ -1597,6 +1704,30 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -1597,6 +1704,30 @@ fn zirExport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1597 | try sema.mod.analyzeExport(&block.base, src, export_name, actual_fn.owner_decl); | 1704 | try sema.mod.analyzeExport(&block.base, src, export_name, actual_fn.owner_decl); |
| 1598 | } | 1705 | } |
| 1599 | 1706 | ||
| 1707 | fn zirSetAlignStack(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | ||
| 1708 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 1709 | const src: LazySrcLoc = inst_data.src(); | ||
| 1710 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetAlignStack", .{}); | ||
| 1711 | } | ||
| 1712 | |||
| 1713 | fn zirSetCold(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | ||
| 1714 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 1715 | const src: LazySrcLoc = inst_data.src(); | ||
| 1716 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetCold", .{}); | ||
| 1717 | } | ||
| 1718 | |||
| 1719 | fn zirSetFloatMode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | ||
| 1720 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 1721 | const src: LazySrcLoc = inst_data.src(); | ||
| 1722 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetFloatMode", .{}); | ||
| 1723 | } | ||
| 1724 | |||
| 1725 | fn zirSetRuntimeSafety(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | ||
| 1726 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 1727 | const src: LazySrcLoc = inst_data.src(); | ||
| 1728 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirSetRuntimeSafety", .{}); | ||
| 1729 | } | ||
| 1730 | |||
| 1600 | fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | 1731 | fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { |
| 1601 | const tracy = trace(@src()); | 1732 | const tracy = trace(@src()); |
| 1602 | defer tracy.end(); | 1733 | defer tracy.end(); |
| ... | @@ -1607,6 +1738,12 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -1607,6 +1738,12 @@ fn zirBreakpoint(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 1607 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); | 1738 | _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); |
| 1608 | } | 1739 | } |
| 1609 | 1740 | ||
| 1741 | fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!void { | ||
| 1742 | const src_node = sema.code.instructions.items(.data)[inst].node; | ||
| 1743 | const src: LazySrcLoc = .{ .node_offset = src_node }; | ||
| 1744 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirFence", .{}); | ||
| 1745 | } | ||
| 1746 | |||
| 1610 | fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { | 1747 | fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 1611 | const tracy = trace(@src()); | 1748 | const tracy = trace(@src()); |
| 1612 | defer tracy.end(); | 1749 | defer tracy.end(); |
| ... | @@ -3874,10 +4011,15 @@ fn validateSwitchNoRange( | ... | @@ -3874,10 +4011,15 @@ fn validateSwitchNoRange( |
| 3874 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); | 4011 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); |
| 3875 | } | 4012 | } |
| 3876 | 4013 | ||
| 3877 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4014 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 3878 | const tracy = trace(@src()); | 4015 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3879 | defer tracy.end(); | 4016 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4017 | const src = inst_data.src(); | ||
| 4018 | |||
| 4019 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); | ||
| 4020 | } | ||
| 3880 | 4021 | ||
| 4022 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 3881 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4023 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3882 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4024 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3883 | const src = inst_data.src(); | 4025 | const src = inst_data.src(); |
| ... | @@ -4382,16 +4524,13 @@ fn zirThis(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*I | ... | @@ -4382,16 +4524,13 @@ fn zirThis(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*I |
| 4382 | const src: LazySrcLoc = .{ .node_offset = src_node }; | 4524 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| 4383 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); | 4525 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); |
| 4384 | } | 4526 | } |
| 4385 | fn zirFence(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4527 | |
| 4386 | const src_node = sema.code.instructions.items(.data)[inst].node; | ||
| 4387 | const src: LazySrcLoc = .{ .node_offset = src_node }; | ||
| 4388 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirFence", .{}); | ||
| 4389 | } | ||
| 4390 | fn zirRetAddr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4528 | fn zirRetAddr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4391 | const src_node = sema.code.instructions.items(.data)[inst].node; | 4529 | const src_node = sema.code.instructions.items(.data)[inst].node; |
| 4392 | const src: LazySrcLoc = .{ .node_offset = src_node }; | 4530 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| 4393 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); | 4531 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); |
| 4394 | } | 4532 | } |
| 4533 | |||
| 4395 | fn zirBuiltinSrc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4534 | fn zirBuiltinSrc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4396 | const src_node = sema.code.instructions.items(.data)[inst].node; | 4535 | const src_node = sema.code.instructions.items(.data)[inst].node; |
| 4397 | const src: LazySrcLoc = .{ .node_offset = src_node }; | 4536 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| ... | @@ -4419,6 +4558,12 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -4419,6 +4558,12 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 4419 | return sema.mod.constType(sema.arena, src, elem_ty); | 4558 | return sema.mod.constType(sema.arena, src, elem_ty); |
| 4420 | } | 4559 | } |
| 4421 | 4560 | ||
| 4561 | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 4562 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 4563 | const src = inst_data.src(); | ||
| 4564 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{}); | ||
| 4565 | } | ||
| 4566 | |||
| 4422 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4567 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4423 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4568 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4424 | const src = inst_data.src(); | 4569 | const src = inst_data.src(); |
| ... | @@ -4827,6 +4972,12 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -4827,6 +4972,12 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 4827 | }); | 4972 | }); |
| 4828 | } | 4973 | } |
| 4829 | 4974 | ||
| 4975 | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 4976 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 4977 | const src = inst_data.src(); | ||
| 4978 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{}); | ||
| 4979 | } | ||
| 4980 | |||
| 4830 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4981 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { |
| 4831 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4982 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4832 | const src = inst_data.src(); | 4983 | const src = inst_data.src(); |
| ... | @@ -4839,6 +4990,380 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -4839,6 +4990,380 @@ fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 4839 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldType", .{}); | 4990 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldType", .{}); |
| 4840 | } | 4991 | } |
| 4841 | 4992 | ||
| 4993 | fn zirErrorReturnTrace(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 4994 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 4995 | const src = inst_data.src(); | ||
| 4996 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); | ||
| 4997 | } | ||
| 4998 | |||
| 4999 | fn zirFrame(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5000 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5001 | const src = inst_data.src(); | ||
| 5002 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); | ||
| 5003 | } | ||
| 5004 | |||
| 5005 | fn zirFrameAddress(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5006 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5007 | const src = inst_data.src(); | ||
| 5008 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{}); | ||
| 5009 | } | ||
| 5010 | |||
| 5011 | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5012 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5013 | const src = inst_data.src(); | ||
| 5014 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrToInt", .{}); | ||
| 5015 | } | ||
| 5016 | |||
| 5017 | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5018 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5019 | const src = inst_data.src(); | ||
| 5020 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{}); | ||
| 5021 | } | ||
| 5022 | |||
| 5023 | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5024 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5025 | const src = inst_data.src(); | ||
| 5026 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{}); | ||
| 5027 | } | ||
| 5028 | |||
| 5029 | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5030 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5031 | const src = inst_data.src(); | ||
| 5032 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{}); | ||
| 5033 | } | ||
| 5034 | |||
| 5035 | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5036 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5037 | const src = inst_data.src(); | ||
| 5038 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{}); | ||
| 5039 | } | ||
| 5040 | |||
| 5041 | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5042 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5043 | const src = inst_data.src(); | ||
| 5044 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{}); | ||
| 5045 | } | ||
| 5046 | |||
| 5047 | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5048 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5049 | const src = inst_data.src(); | ||
| 5050 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{}); | ||
| 5051 | } | ||
| 5052 | |||
| 5053 | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5054 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5055 | const src = inst_data.src(); | ||
| 5056 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{}); | ||
| 5057 | } | ||
| 5058 | |||
| 5059 | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5060 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5061 | const src = inst_data.src(); | ||
| 5062 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{}); | ||
| 5063 | } | ||
| 5064 | |||
| 5065 | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5066 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5067 | const src = inst_data.src(); | ||
| 5068 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{}); | ||
| 5069 | } | ||
| 5070 | |||
| 5071 | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5072 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5073 | const src = inst_data.src(); | ||
| 5074 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{}); | ||
| 5075 | } | ||
| 5076 | |||
| 5077 | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5078 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5079 | const src = inst_data.src(); | ||
| 5080 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{}); | ||
| 5081 | } | ||
| 5082 | |||
| 5083 | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5084 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5085 | const src = inst_data.src(); | ||
| 5086 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{}); | ||
| 5087 | } | ||
| 5088 | |||
| 5089 | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5090 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5091 | const src = inst_data.src(); | ||
| 5092 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToPtr", .{}); | ||
| 5093 | } | ||
| 5094 | |||
| 5095 | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5096 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5097 | const src = inst_data.src(); | ||
| 5098 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatCast", .{}); | ||
| 5099 | } | ||
| 5100 | |||
| 5101 | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5102 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5103 | const src = inst_data.src(); | ||
| 5104 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntCast", .{}); | ||
| 5105 | } | ||
| 5106 | |||
| 5107 | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5108 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5109 | const src = inst_data.src(); | ||
| 5110 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{}); | ||
| 5111 | } | ||
| 5112 | |||
| 5113 | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5114 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5115 | const src = inst_data.src(); | ||
| 5116 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{}); | ||
| 5117 | } | ||
| 5118 | |||
| 5119 | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5120 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5121 | const src = inst_data.src(); | ||
| 5122 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{}); | ||
| 5123 | } | ||
| 5124 | |||
| 5125 | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5126 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5127 | const src = inst_data.src(); | ||
| 5128 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{}); | ||
| 5129 | } | ||
| 5130 | |||
| 5131 | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5132 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5133 | const src = inst_data.src(); | ||
| 5134 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{}); | ||
| 5135 | } | ||
| 5136 | |||
| 5137 | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5138 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5139 | const src = inst_data.src(); | ||
| 5140 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{}); | ||
| 5141 | } | ||
| 5142 | |||
| 5143 | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5144 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5145 | const src = inst_data.src(); | ||
| 5146 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{}); | ||
| 5147 | } | ||
| 5148 | |||
| 5149 | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5150 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5151 | const src = inst_data.src(); | ||
| 5152 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{}); | ||
| 5153 | } | ||
| 5154 | |||
| 5155 | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5156 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | ||
| 5157 | const src = inst_data.src(); | ||
| 5158 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{}); | ||
| 5159 | } | ||
| 5160 | |||
| 5161 | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5162 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5163 | const src = inst_data.src(); | ||
| 5164 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{}); | ||
| 5165 | } | ||
| 5166 | |||
| 5167 | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5168 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5169 | const src = inst_data.src(); | ||
| 5170 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{}); | ||
| 5171 | } | ||
| 5172 | |||
| 5173 | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5174 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5175 | const src = inst_data.src(); | ||
| 5176 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{}); | ||
| 5177 | } | ||
| 5178 | |||
| 5179 | fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5180 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5181 | const src = inst_data.src(); | ||
| 5182 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{}); | ||
| 5183 | } | ||
| 5184 | |||
| 5185 | fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5186 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5187 | const src = inst_data.src(); | ||
| 5188 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{}); | ||
| 5189 | } | ||
| 5190 | |||
| 5191 | fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5192 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5193 | const src = inst_data.src(); | ||
| 5194 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{}); | ||
| 5195 | } | ||
| 5196 | |||
| 5197 | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5198 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5199 | const src = inst_data.src(); | ||
| 5200 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{}); | ||
| 5201 | } | ||
| 5202 | |||
| 5203 | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5204 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5205 | const src = inst_data.src(); | ||
| 5206 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{}); | ||
| 5207 | } | ||
| 5208 | |||
| 5209 | fn zirByteOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5210 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5211 | const src = inst_data.src(); | ||
| 5212 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteOffsetOf", .{}); | ||
| 5213 | } | ||
| 5214 | |||
| 5215 | fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5216 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5217 | const src = inst_data.src(); | ||
| 5218 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{}); | ||
| 5219 | } | ||
| 5220 | |||
| 5221 | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5222 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5223 | const src = inst_data.src(); | ||
| 5224 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{}); | ||
| 5225 | } | ||
| 5226 | |||
| 5227 | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5228 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5229 | const src = inst_data.src(); | ||
| 5230 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{}); | ||
| 5231 | } | ||
| 5232 | |||
| 5233 | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5234 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5235 | const src = inst_data.src(); | ||
| 5236 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{}); | ||
| 5237 | } | ||
| 5238 | |||
| 5239 | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5240 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5241 | const src = inst_data.src(); | ||
| 5242 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{}); | ||
| 5243 | } | ||
| 5244 | |||
| 5245 | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5246 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5247 | const src = inst_data.src(); | ||
| 5248 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{}); | ||
| 5249 | } | ||
| 5250 | |||
| 5251 | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5252 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5253 | const src = inst_data.src(); | ||
| 5254 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{}); | ||
| 5255 | } | ||
| 5256 | |||
| 5257 | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5258 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5259 | const src = inst_data.src(); | ||
| 5260 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{}); | ||
| 5261 | } | ||
| 5262 | |||
| 5263 | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5264 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5265 | const src = inst_data.src(); | ||
| 5266 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{}); | ||
| 5267 | } | ||
| 5268 | |||
| 5269 | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5270 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5271 | const src = inst_data.src(); | ||
| 5272 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{}); | ||
| 5273 | } | ||
| 5274 | |||
| 5275 | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5276 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5277 | const src = inst_data.src(); | ||
| 5278 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{}); | ||
| 5279 | } | ||
| 5280 | |||
| 5281 | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5282 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5283 | const src = inst_data.src(); | ||
| 5284 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{}); | ||
| 5285 | } | ||
| 5286 | |||
| 5287 | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5288 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5289 | const src = inst_data.src(); | ||
| 5290 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{}); | ||
| 5291 | } | ||
| 5292 | |||
| 5293 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5294 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | ||
| 5295 | const src = inst_data.src(); | ||
| 5296 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); | ||
| 5297 | } | ||
| 5298 | |||
| 5299 | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | ||
| 5300 | const extended = sema.code.instructions.items(.data)[inst].extended; | ||
| 5301 | switch (extended.opcode) { | ||
| 5302 | // zig fmt: off | ||
| 5303 | .c_undef => return sema.zirCUndef( block, inst, extended), | ||
| 5304 | .c_include => return sema.zirCInclude( block, inst, extended), | ||
| 5305 | .c_define => return sema.zirCDefine( block, inst, extended), | ||
| 5306 | .wasm_memory_size => return sema.zirWasmMemorySize( block, inst, extended), | ||
| 5307 | .wasm_memory_grow => return sema.zirWasmMemoryGrow( block, inst, extended), | ||
| 5308 | // zig fmt: on | ||
| 5309 | } | ||
| 5310 | } | ||
| 5311 | |||
| 5312 | fn zirCUndef( | ||
| 5313 | sema: *Sema, | ||
| 5314 | block: *Scope.Block, | ||
| 5315 | inst: Zir.Inst.Index, | ||
| 5316 | extended: Zir.Inst.Extended.InstData, | ||
| 5317 | ) InnerError!*Inst { | ||
| 5318 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | ||
| 5319 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | ||
| 5320 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); | ||
| 5321 | } | ||
| 5322 | |||
| 5323 | fn zirCInclude( | ||
| 5324 | sema: *Sema, | ||
| 5325 | block: *Scope.Block, | ||
| 5326 | inst: Zir.Inst.Index, | ||
| 5327 | extended: Zir.Inst.Extended.InstData, | ||
| 5328 | ) InnerError!*Inst { | ||
| 5329 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | ||
| 5330 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | ||
| 5331 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); | ||
| 5332 | } | ||
| 5333 | |||
| 5334 | fn zirCDefine( | ||
| 5335 | sema: *Sema, | ||
| 5336 | block: *Scope.Block, | ||
| 5337 | inst: Zir.Inst.Index, | ||
| 5338 | extended: Zir.Inst.Extended.InstData, | ||
| 5339 | ) InnerError!*Inst { | ||
| 5340 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | ||
| 5341 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | ||
| 5342 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); | ||
| 5343 | } | ||
| 5344 | |||
| 5345 | fn zirWasmMemorySize( | ||
| 5346 | sema: *Sema, | ||
| 5347 | block: *Scope.Block, | ||
| 5348 | inst: Zir.Inst.Index, | ||
| 5349 | extended: Zir.Inst.Extended.InstData, | ||
| 5350 | ) InnerError!*Inst { | ||
| 5351 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | ||
| 5352 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | ||
| 5353 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); | ||
| 5354 | } | ||
| 5355 | |||
| 5356 | fn zirWasmMemoryGrow( | ||
| 5357 | sema: *Sema, | ||
| 5358 | block: *Scope.Block, | ||
| 5359 | inst: Zir.Inst.Index, | ||
| 5360 | extended: Zir.Inst.Extended.InstData, | ||
| 5361 | ) InnerError!*Inst { | ||
| 5362 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | ||
| 5363 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | ||
| 5364 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); | ||
| 5365 | } | ||
| 5366 | |||
| 4842 | fn requireFunctionBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { | 5367 | fn requireFunctionBlock(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) !void { |
| 4843 | if (sema.func == null) { | 5368 | if (sema.func == null) { |
| 4844 | return sema.mod.fail(&block.base, src, "instruction illegal outside function body", .{}); | 5369 | return sema.mod.fail(&block.base, src, "instruction illegal outside function body", .{}); |
src/Zir.zig+537-36| ... | @@ -274,9 +274,6 @@ pub const Inst = struct { | ... | @@ -274,9 +274,6 @@ pub const Inst = struct { |
| 274 | /// Uses the `bin` union field. | 274 | /// Uses the `bin` union field. |
| 275 | /// LHS is destination element type, RHS is result pointer. | 275 | /// LHS is destination element type, RHS is result pointer. |
| 276 | coerce_result_ptr, | 276 | coerce_result_ptr, |
| 277 | /// Emit an error message and fail compilation. | ||
| 278 | /// Uses the `un_node` field. | ||
| 279 | compile_error, | ||
| 280 | /// Log compile time variables and emit an error message. | 277 | /// Log compile time variables and emit an error message. |
| 281 | /// Uses the `pl_node` union field. The AST node is the compile log builtin call. | 278 | /// Uses the `pl_node` union field. The AST node is the compile log builtin call. |
| 282 | /// The payload is `MultiOp`. | 279 | /// The payload is `MultiOp`. |
| ... | @@ -339,9 +336,6 @@ pub const Inst = struct { | ... | @@ -339,9 +336,6 @@ pub const Inst = struct { |
| 339 | /// Same as `elem_val` except also stores a source location node. | 336 | /// Same as `elem_val` except also stores a source location node. |
| 340 | /// Uses the `pl_node` union field. AST node is a[b] syntax. Payload is `Bin`. | 337 | /// Uses the `pl_node` union field. AST node is a[b] syntax. Payload is `Bin`. |
| 341 | elem_val_node, | 338 | elem_val_node, |
| 342 | /// This instruction has been deleted late in the astgen phase. It must | ||
| 343 | /// be ignored, and the corresponding `Data` is undefined. | ||
| 344 | elided, | ||
| 345 | /// Emits a compile error if the operand is not `void`. | 339 | /// Emits a compile error if the operand is not `void`. |
| 346 | /// Uses the `un_node` field. | 340 | /// Uses the `un_node` field. |
| 347 | ensure_result_used, | 341 | ensure_result_used, |
| ... | @@ -391,9 +385,6 @@ pub const Inst = struct { | ... | @@ -391,9 +385,6 @@ pub const Inst = struct { |
| 391 | func_extra, | 385 | func_extra, |
| 392 | /// Same as `func_extra` but the function is variadic. | 386 | /// Same as `func_extra` but the function is variadic. |
| 393 | func_extra_var_args, | 387 | func_extra_var_args, |
| 394 | /// Implements the `@hasDecl` builtin. | ||
| 395 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 396 | has_decl, | ||
| 397 | /// Implements the `@import` builtin. | 388 | /// Implements the `@import` builtin. |
| 398 | /// Uses the `str_tok` field. | 389 | /// Uses the `str_tok` field. |
| 399 | import, | 390 | import, |
| ... | @@ -412,10 +403,6 @@ pub const Inst = struct { | ... | @@ -412,10 +403,6 @@ pub const Inst = struct { |
| 412 | /// Make an integer type out of signedness and bit count. | 403 | /// Make an integer type out of signedness and bit count. |
| 413 | /// Payload is `int_type` | 404 | /// Payload is `int_type` |
| 414 | int_type, | 405 | int_type, |
| 415 | /// Convert an error type to `u16` | ||
| 416 | error_to_int, | ||
| 417 | /// Convert a `u16` to `anyerror` | ||
| 418 | int_to_error, | ||
| 419 | /// Return a boolean false if an optional is null. `x != null` | 406 | /// Return a boolean false if an optional is null. `x != null` |
| 420 | /// Uses the `un_node` field. | 407 | /// Uses the `un_node` field. |
| 421 | is_non_null, | 408 | is_non_null, |
| ... | @@ -498,16 +485,6 @@ pub const Inst = struct { | ... | @@ -498,16 +485,6 @@ pub const Inst = struct { |
| 498 | /// Same as `ret_tok` except the operand needs to get coerced to the function's | 485 | /// Same as `ret_tok` except the operand needs to get coerced to the function's |
| 499 | /// return type. | 486 | /// return type. |
| 500 | ret_coerce, | 487 | ret_coerce, |
| 501 | /// Changes the maximum number of backwards branches that compile-time | ||
| 502 | /// code execution can use before giving up and making a compile error. | ||
| 503 | /// Uses the `un_node` union field. | ||
| 504 | set_eval_branch_quota, | ||
| 505 | /// Integer shift-left. Zeroes are shifted in from the right hand side. | ||
| 506 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 507 | shl, | ||
| 508 | /// Integer shift-right. Arithmetic or logical depending on the signedness of the integer type. | ||
| 509 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 510 | shr, | ||
| 511 | /// Create a pointer type that does not have a sentinel, alignment, or bit range specified. | 488 | /// Create a pointer type that does not have a sentinel, alignment, or bit range specified. |
| 512 | /// Uses the `ptr_type_simple` union field. | 489 | /// Uses the `ptr_type_simple` union field. |
| 513 | ptr_type_simple, | 490 | ptr_type_simple, |
| ... | @@ -573,6 +550,10 @@ pub const Inst = struct { | ... | @@ -573,6 +550,10 @@ pub const Inst = struct { |
| 573 | /// of one or more params. | 550 | /// of one or more params. |
| 574 | /// Uses the `pl_node` field. AST node is the `@TypeOf` call. Payload is `MultiOp`. | 551 | /// Uses the `pl_node` field. AST node is the `@TypeOf` call. Payload is `MultiOp`. |
| 575 | typeof_peer, | 552 | typeof_peer, |
| 553 | /// Given a value, look at the type of it, which must be an integer type. | ||
| 554 | /// Returns the integer type for the RHS of a shift operation. | ||
| 555 | /// Uses the `un_node` field. | ||
| 556 | typeof_log2_int_type, | ||
| 576 | /// Given an integer type, returns the integer type for the RHS of a shift operation. | 557 | /// Given an integer type, returns the integer type for the RHS of a shift operation. |
| 577 | /// Uses the `un_node` field. | 558 | /// Uses the `un_node` field. |
| 578 | log2_int_type, | 559 | log2_int_type, |
| ... | @@ -712,12 +693,10 @@ pub const Inst = struct { | ... | @@ -712,12 +693,10 @@ pub const Inst = struct { |
| 712 | /// struct value. | 693 | /// struct value. |
| 713 | /// Uses the `pl_node` field. Payload is `StructInit`. | 694 | /// Uses the `pl_node` field. Payload is `StructInit`. |
| 714 | struct_init, | 695 | struct_init, |
| 715 | /// Converts an integer into an enum value. | 696 | /// Given a pointer to a union and a comptime known field name, activates that field |
| 716 | /// Uses `pl_node` with payload `Bin`. `lhs` is enum type, `rhs` is operand. | 697 | /// and returns a pointer to it. |
| 717 | int_to_enum, | 698 | /// Uses the `pl_node` field. Payload is `UnionInitPtr`. |
| 718 | /// Converts an enum value into an integer. Resulting type will be the tag type | 699 | union_init_ptr, |
| 719 | /// of the enum. Uses `un_node`. | ||
| 720 | enum_to_int, | ||
| 721 | /// Implements the `@typeInfo` builtin. Uses `un_node`. | 700 | /// Implements the `@typeInfo` builtin. Uses `un_node`. |
| 722 | type_info, | 701 | type_info, |
| 723 | /// Implements the `@sizeOf` builtin. Uses `un_node`. | 702 | /// Implements the `@sizeOf` builtin. Uses `un_node`. |
| ... | @@ -741,6 +720,224 @@ pub const Inst = struct { | ... | @@ -741,6 +720,224 @@ pub const Inst = struct { |
| 741 | /// Implements the `@shlWithOverflow` builtin. Uses `pl_node` with `OverflowArithmetic`. | 720 | /// Implements the `@shlWithOverflow` builtin. Uses `pl_node` with `OverflowArithmetic`. |
| 742 | shl_with_overflow, | 721 | shl_with_overflow, |
| 743 | 722 | ||
| 723 | /// Implements the `@errorReturnTrace` builtin. | ||
| 724 | /// Uses the `un_node` field. | ||
| 725 | error_return_trace, | ||
| 726 | /// Implements the `@frame` builtin. | ||
| 727 | /// Uses the `un_node` field. | ||
| 728 | frame, | ||
| 729 | /// Implements the `@frameAddress` builtin. | ||
| 730 | /// Uses the `un_node` field. | ||
| 731 | frame_address, | ||
| 732 | |||
| 733 | /// Implement builtin `@ptrToInt`. Uses `un_node`. | ||
| 734 | ptr_to_int, | ||
| 735 | /// Implement builtin `@errToInt`. Uses `un_node`. | ||
| 736 | error_to_int, | ||
| 737 | /// Implement builtin `@intToError`. Uses `un_node`. | ||
| 738 | int_to_error, | ||
| 739 | /// Emit an error message and fail compilation. | ||
| 740 | /// Uses the `un_node` field. | ||
| 741 | compile_error, | ||
| 742 | /// Changes the maximum number of backwards branches that compile-time | ||
| 743 | /// code execution can use before giving up and making a compile error. | ||
| 744 | /// Uses the `un_node` union field. | ||
| 745 | set_eval_branch_quota, | ||
| 746 | /// Converts an enum value into an integer. Resulting type will be the tag type | ||
| 747 | /// of the enum. Uses `un_node`. | ||
| 748 | enum_to_int, | ||
| 749 | /// Implement builtin `@alignOf`. Uses `un_node`. | ||
| 750 | align_of, | ||
| 751 | /// Implement builtin `@boolToInt`. Uses `un_node`. | ||
| 752 | bool_to_int, | ||
| 753 | /// Implement builtin `@embedFile`. Uses `un_node`. | ||
| 754 | embed_file, | ||
| 755 | /// Implement builtin `@errorName`. Uses `un_node`. | ||
| 756 | error_name, | ||
| 757 | /// Implement builtin `@panic`. Uses `un_node`. | ||
| 758 | panic, | ||
| 759 | /// Implement builtin `@setAlignStack`. Uses `un_node`. | ||
| 760 | set_align_stack, | ||
| 761 | /// Implement builtin `@setCold`. Uses `un_node`. | ||
| 762 | set_cold, | ||
| 763 | /// Implement builtin `@setFloatMode`. Uses `un_node`. | ||
| 764 | set_float_mode, | ||
| 765 | /// Implement builtin `@setRuntimeSafety`. Uses `un_node`. | ||
| 766 | set_runtime_safety, | ||
| 767 | /// Implement builtin `@sqrt`. Uses `un_node`. | ||
| 768 | sqrt, | ||
| 769 | /// Implement builtin `@sin`. Uses `un_node`. | ||
| 770 | sin, | ||
| 771 | /// Implement builtin `@cos`. Uses `un_node`. | ||
| 772 | cos, | ||
| 773 | /// Implement builtin `@exp`. Uses `un_node`. | ||
| 774 | exp, | ||
| 775 | /// Implement builtin `@exp2`. Uses `un_node`. | ||
| 776 | exp2, | ||
| 777 | /// Implement builtin `@log`. Uses `un_node`. | ||
| 778 | log, | ||
| 779 | /// Implement builtin `@log2`. Uses `un_node`. | ||
| 780 | log2, | ||
| 781 | /// Implement builtin `@log10`. Uses `un_node`. | ||
| 782 | log10, | ||
| 783 | /// Implement builtin `@fabs`. Uses `un_node`. | ||
| 784 | fabs, | ||
| 785 | /// Implement builtin `@floor`. Uses `un_node`. | ||
| 786 | floor, | ||
| 787 | /// Implement builtin `@ceil`. Uses `un_node`. | ||
| 788 | ceil, | ||
| 789 | /// Implement builtin `@trunc`. Uses `un_node`. | ||
| 790 | trunc, | ||
| 791 | /// Implement builtin `@round`. Uses `un_node`. | ||
| 792 | round, | ||
| 793 | /// Implement builtin `@tagName`. Uses `un_node`. | ||
| 794 | tag_name, | ||
| 795 | /// Implement builtin `@Type`. Uses `un_node`. | ||
| 796 | reify, | ||
| 797 | /// Implement builtin `@typeName`. Uses `un_node`. | ||
| 798 | type_name, | ||
| 799 | /// Implement builtin `@Frame`. Uses `un_node`. | ||
| 800 | frame_type, | ||
| 801 | /// Implement builtin `@frameSize`. Uses `un_node`. | ||
| 802 | frame_size, | ||
| 803 | |||
| 804 | /// Implements the `@floatToInt` builtin. | ||
| 805 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 806 | float_to_int, | ||
| 807 | /// Implements the `@intToFloat` builtin. | ||
| 808 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 809 | int_to_float, | ||
| 810 | /// Implements the `@intToPtr` builtin. | ||
| 811 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 812 | int_to_ptr, | ||
| 813 | /// Converts an integer into an enum value. | ||
| 814 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 815 | int_to_enum, | ||
| 816 | /// Implements the `@floatCast` builtin. | ||
| 817 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 818 | float_cast, | ||
| 819 | /// Implements the `@intCast` builtin. | ||
| 820 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 821 | int_cast, | ||
| 822 | /// Implements the `@errSetCast` builtin. | ||
| 823 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 824 | err_set_cast, | ||
| 825 | /// Implements the `@ptrCast` builtin. | ||
| 826 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 827 | ptr_cast, | ||
| 828 | /// Implements the `@truncate` builtin. | ||
| 829 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest type, `rhs` is operand. | ||
| 830 | truncate, | ||
| 831 | /// Implements the `@alignCast` builtin. | ||
| 832 | /// Uses `pl_node` with payload `Bin`. `lhs` is dest alignment, `rhs` is operand. | ||
| 833 | align_cast, | ||
| 834 | |||
| 835 | /// Implements the `@hasDecl` builtin. | ||
| 836 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 837 | has_decl, | ||
| 838 | /// Implements the `@hasField` builtin. | ||
| 839 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 840 | has_field, | ||
| 841 | |||
| 842 | /// Implements the `@clz` builtin. Uses the `un_node` union field. | ||
| 843 | clz, | ||
| 844 | /// Implements the `@ctz` builtin. Uses the `un_node` union field. | ||
| 845 | ctz, | ||
| 846 | /// Implements the `@popCount` builtin. Uses the `un_node` union field. | ||
| 847 | pop_count, | ||
| 848 | /// Implements the `@byteSwap` builtin. Uses the `un_node` union field. | ||
| 849 | byte_swap, | ||
| 850 | /// Implements the `@bitReverse` builtin. Uses the `un_node` union field. | ||
| 851 | bit_reverse, | ||
| 852 | |||
| 853 | /// Implements the `@divExact` builtin. | ||
| 854 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 855 | div_exact, | ||
| 856 | /// Implements the `@divFloor` builtin. | ||
| 857 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 858 | div_floor, | ||
| 859 | /// Implements the `@divTrunc` builtin. | ||
| 860 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 861 | div_trunc, | ||
| 862 | /// Implements the `@mod` builtin. | ||
| 863 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 864 | mod, | ||
| 865 | /// Implements the `@rem` builtin. | ||
| 866 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 867 | rem, | ||
| 868 | |||
| 869 | /// Integer shift-left. Zeroes are shifted in from the right hand side. | ||
| 870 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 871 | shl, | ||
| 872 | /// Implements the `@shlExact` builtin. | ||
| 873 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 874 | shl_exact, | ||
| 875 | /// Integer shift-right. Arithmetic or logical depending on the signedness of the integer type. | ||
| 876 | /// Uses the `pl_node` union field. Payload is `Bin`. | ||
| 877 | shr, | ||
| 878 | /// Implements the `@shrExact` builtin. | ||
| 879 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 880 | shr_exact, | ||
| 881 | |||
| 882 | /// Implements the `@bitOffsetOf` builtin. | ||
| 883 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 884 | bit_offset_of, | ||
| 885 | /// Implements the `@byteOffsetOf` builtin. | ||
| 886 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 887 | byte_offset_of, | ||
| 888 | /// Implements the `@cmpxchgStrong` builtin. | ||
| 889 | /// Uses the `pl_node` union field with payload `Cmpxchg`. | ||
| 890 | cmpxchg_strong, | ||
| 891 | /// Implements the `@cmpxchgWeak` builtin. | ||
| 892 | /// Uses the `pl_node` union field with payload `Cmpxchg`. | ||
| 893 | cmpxchg_weak, | ||
| 894 | /// Implements the `@splat` builtin. | ||
| 895 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 896 | splat, | ||
| 897 | /// Implements the `@reduce` builtin. | ||
| 898 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 899 | reduce, | ||
| 900 | /// Implements the `@shuffle` builtin. | ||
| 901 | /// Uses the `pl_node` union field with payload `Shuffle`. | ||
| 902 | shuffle, | ||
| 903 | /// Implements the `@atomicLoad` builtin. | ||
| 904 | /// Uses the `pl_node` union field with payload `Bin`. | ||
| 905 | atomic_load, | ||
| 906 | /// Implements the `@atomicRmw` builtin. | ||
| 907 | /// Uses the `pl_node` union field with payload `AtomicRmw`. | ||
| 908 | atomic_rmw, | ||
| 909 | /// Implements the `@atomicStore` builtin. | ||
| 910 | /// Uses the `pl_node` union field with payload `AtomicStore`. | ||
| 911 | atomic_store, | ||
| 912 | /// Implements the `@mulAdd` builtin. | ||
| 913 | /// Uses the `pl_node` union field with payload `MulAdd`. | ||
| 914 | mul_add, | ||
| 915 | /// Implements the `@call` builtin. | ||
| 916 | /// Uses the `pl_node` union field with payload `BuiltinCall`. | ||
| 917 | builtin_call, | ||
| 918 | /// Given a type and a field name, returns a pointer to the field type. | ||
| 919 | /// Assumed to be part of a `@fieldParentPtr` builtin call. | ||
| 920 | /// Uses the `bin` union field. LHS is type, RHS is field name. | ||
| 921 | field_ptr_type, | ||
| 922 | /// Implements the `@fieldParentPtr` builtin. | ||
| 923 | /// Uses the `pl_node` union field with payload `FieldParentPtr`. | ||
| 924 | field_parent_ptr, | ||
| 925 | /// Implements the `@memcpy` builtin. | ||
| 926 | /// Uses the `pl_node` union field with payload `Memcpy`. | ||
| 927 | memcpy, | ||
| 928 | /// Implements the `@memset` builtin. | ||
| 929 | /// Uses the `pl_node` union field with payload `Memset`. | ||
| 930 | memset, | ||
| 931 | /// Implements the `@asyncCall` builtin. | ||
| 932 | /// Uses the `pl_node` union field with payload `AsyncCall`. | ||
| 933 | builtin_async_call, | ||
| 934 | /// Implements the `@cImport` builtin. | ||
| 935 | /// Uses the `pl_node` union field with payload `Block`. | ||
| 936 | c_import, | ||
| 937 | /// The ZIR instruction tag is one of the `Extended` ones. | ||
| 938 | /// Uses the `extended` union field. | ||
| 939 | extended, | ||
| 940 | |||
| 744 | /// Returns whether the instruction is one of the control flow "noreturn" types. | 941 | /// Returns whether the instruction is one of the control flow "noreturn" types. |
| 745 | /// Function calls do not count. | 942 | /// Function calls do not count. |
| 746 | pub fn isNoReturn(tag: Tag) bool { | 943 | pub fn isNoReturn(tag: Tag) bool { |
| ... | @@ -876,11 +1073,11 @@ pub const Inst = struct { | ... | @@ -876,11 +1073,11 @@ pub const Inst = struct { |
| 876 | .slice_sentinel, | 1073 | .slice_sentinel, |
| 877 | .import, | 1074 | .import, |
| 878 | .typeof_peer, | 1075 | .typeof_peer, |
| 1076 | .typeof_log2_int_type, | ||
| 879 | .log2_int_type, | 1077 | .log2_int_type, |
| 880 | .resolve_inferred_alloc, | 1078 | .resolve_inferred_alloc, |
| 881 | .set_eval_branch_quota, | 1079 | .set_eval_branch_quota, |
| 882 | .compile_log, | 1080 | .compile_log, |
| 883 | .elided, | ||
| 884 | .switch_capture, | 1081 | .switch_capture, |
| 885 | .switch_capture_ref, | 1082 | .switch_capture_ref, |
| 886 | .switch_capture_multi, | 1083 | .switch_capture_multi, |
| ... | @@ -902,6 +1099,7 @@ pub const Inst = struct { | ... | @@ -902,6 +1099,7 @@ pub const Inst = struct { |
| 902 | .validate_struct_init_ptr, | 1099 | .validate_struct_init_ptr, |
| 903 | .struct_init_empty, | 1100 | .struct_init_empty, |
| 904 | .struct_init, | 1101 | .struct_init, |
| 1102 | .union_init_ptr, | ||
| 905 | .field_type, | 1103 | .field_type, |
| 906 | .int_to_enum, | 1104 | .int_to_enum, |
| 907 | .enum_to_int, | 1105 | .enum_to_int, |
| ... | @@ -916,6 +1114,77 @@ pub const Inst = struct { | ... | @@ -916,6 +1114,77 @@ pub const Inst = struct { |
| 916 | .sub_with_overflow, | 1114 | .sub_with_overflow, |
| 917 | .mul_with_overflow, | 1115 | .mul_with_overflow, |
| 918 | .shl_with_overflow, | 1116 | .shl_with_overflow, |
| 1117 | .error_return_trace, | ||
| 1118 | .frame, | ||
| 1119 | .frame_address, | ||
| 1120 | .ptr_to_int, | ||
| 1121 | .align_of, | ||
| 1122 | .bool_to_int, | ||
| 1123 | .embed_file, | ||
| 1124 | .error_name, | ||
| 1125 | .set_align_stack, | ||
| 1126 | .set_cold, | ||
| 1127 | .set_float_mode, | ||
| 1128 | .set_runtime_safety, | ||
| 1129 | .sqrt, | ||
| 1130 | .sin, | ||
| 1131 | .cos, | ||
| 1132 | .exp, | ||
| 1133 | .exp2, | ||
| 1134 | .log, | ||
| 1135 | .log2, | ||
| 1136 | .log10, | ||
| 1137 | .fabs, | ||
| 1138 | .floor, | ||
| 1139 | .ceil, | ||
| 1140 | .trunc, | ||
| 1141 | .round, | ||
| 1142 | .tag_name, | ||
| 1143 | .reify, | ||
| 1144 | .type_name, | ||
| 1145 | .frame_type, | ||
| 1146 | .frame_size, | ||
| 1147 | .float_to_int, | ||
| 1148 | .int_to_float, | ||
| 1149 | .int_to_ptr, | ||
| 1150 | .float_cast, | ||
| 1151 | .int_cast, | ||
| 1152 | .err_set_cast, | ||
| 1153 | .ptr_cast, | ||
| 1154 | .truncate, | ||
| 1155 | .align_cast, | ||
| 1156 | .has_field, | ||
| 1157 | .clz, | ||
| 1158 | .ctz, | ||
| 1159 | .pop_count, | ||
| 1160 | .byte_swap, | ||
| 1161 | .bit_reverse, | ||
| 1162 | .div_exact, | ||
| 1163 | .div_floor, | ||
| 1164 | .div_trunc, | ||
| 1165 | .mod, | ||
| 1166 | .rem, | ||
| 1167 | .shl_exact, | ||
| 1168 | .shr_exact, | ||
| 1169 | .bit_offset_of, | ||
| 1170 | .byte_offset_of, | ||
| 1171 | .cmpxchg_strong, | ||
| 1172 | .cmpxchg_weak, | ||
| 1173 | .splat, | ||
| 1174 | .reduce, | ||
| 1175 | .shuffle, | ||
| 1176 | .atomic_load, | ||
| 1177 | .atomic_rmw, | ||
| 1178 | .atomic_store, | ||
| 1179 | .mul_add, | ||
| 1180 | .builtin_call, | ||
| 1181 | .field_ptr_type, | ||
| 1182 | .field_parent_ptr, | ||
| 1183 | .memcpy, | ||
| 1184 | .memset, | ||
| 1185 | .builtin_async_call, | ||
| 1186 | .c_import, | ||
| 1187 | .extended, | ||
| 919 | => false, | 1188 | => false, |
| 920 | 1189 | ||
| 921 | .@"break", | 1190 | .@"break", |
| ... | @@ -929,11 +1198,33 @@ pub const Inst = struct { | ... | @@ -929,11 +1198,33 @@ pub const Inst = struct { |
| 929 | .@"unreachable", | 1198 | .@"unreachable", |
| 930 | .repeat, | 1199 | .repeat, |
| 931 | .repeat_inline, | 1200 | .repeat_inline, |
| 1201 | .panic, | ||
| 932 | => true, | 1202 | => true, |
| 933 | }; | 1203 | }; |
| 934 | } | 1204 | } |
| 935 | }; | 1205 | }; |
| 936 | 1206 | ||
| 1207 | /// Rarer instructions are here; ones that do not fit in the 8-bit `Tag` enum. | ||
| 1208 | /// `noreturn` instructions may not go here; they must be part of the main `Tag` enum. | ||
| 1209 | pub const Extended = enum(u16) { | ||
| 1210 | /// `operand` is payload index to `UnNode`. | ||
| 1211 | c_undef, | ||
| 1212 | /// `operand` is payload index to `UnNode`. | ||
| 1213 | c_include, | ||
| 1214 | /// `operand` is payload index to `BinNode`. | ||
| 1215 | c_define, | ||
| 1216 | /// `operand` is payload index to `UnNode`. | ||
| 1217 | wasm_memory_size, | ||
| 1218 | /// `operand` is payload index to `BinNode`. | ||
| 1219 | wasm_memory_grow, | ||
| 1220 | |||
| 1221 | pub const InstData = struct { | ||
| 1222 | opcode: Extended, | ||
| 1223 | small: u16, | ||
| 1224 | operand: u32, | ||
| 1225 | }; | ||
| 1226 | }; | ||
| 1227 | |||
| 937 | /// The position of a ZIR instruction within the `Zir` instructions array. | 1228 | /// The position of a ZIR instruction within the `Zir` instructions array. |
| 938 | pub const Index = u32; | 1229 | pub const Index = u32; |
| 939 | 1230 | ||
| ... | @@ -1002,6 +1293,14 @@ pub const Inst = struct { | ... | @@ -1002,6 +1293,14 @@ pub const Inst = struct { |
| 1002 | single_const_pointer_to_comptime_int_type, | 1293 | single_const_pointer_to_comptime_int_type, |
| 1003 | const_slice_u8_type, | 1294 | const_slice_u8_type, |
| 1004 | enum_literal_type, | 1295 | enum_literal_type, |
| 1296 | manyptr_u8_type, | ||
| 1297 | manyptr_const_u8_type, | ||
| 1298 | atomic_ordering_type, | ||
| 1299 | atomic_rmw_op_type, | ||
| 1300 | calling_convention_type, | ||
| 1301 | float_mode_type, | ||
| 1302 | reduce_op_type, | ||
| 1303 | call_options_type, | ||
| 1005 | 1304 | ||
| 1006 | /// `undefined` (untyped) | 1305 | /// `undefined` (untyped) |
| 1007 | undef, | 1306 | undef, |
| ... | @@ -1025,6 +1324,8 @@ pub const Inst = struct { | ... | @@ -1025,6 +1324,8 @@ pub const Inst = struct { |
| 1025 | zero_usize, | 1324 | zero_usize, |
| 1026 | /// `1` (usize) | 1325 | /// `1` (usize) |
| 1027 | one_usize, | 1326 | one_usize, |
| 1327 | /// `std.builtin.CallingConvention.C` | ||
| 1328 | calling_convention_c, | ||
| 1028 | 1329 | ||
| 1029 | _, | 1330 | _, |
| 1030 | 1331 | ||
| ... | @@ -1191,6 +1492,38 @@ pub const Inst = struct { | ... | @@ -1191,6 +1492,38 @@ pub const Inst = struct { |
| 1191 | .ty = Type.initTag(.type), | 1492 | .ty = Type.initTag(.type), |
| 1192 | .val = Value.initTag(.enum_literal_type), | 1493 | .val = Value.initTag(.enum_literal_type), |
| 1193 | }, | 1494 | }, |
| 1495 | .manyptr_u8_type = .{ | ||
| 1496 | .ty = Type.initTag(.type), | ||
| 1497 | .val = Value.initTag(.manyptr_u8_type), | ||
| 1498 | }, | ||
| 1499 | .manyptr_const_u8_type = .{ | ||
| 1500 | .ty = Type.initTag(.type), | ||
| 1501 | .val = Value.initTag(.manyptr_const_u8_type), | ||
| 1502 | }, | ||
| 1503 | .atomic_ordering_type = .{ | ||
| 1504 | .ty = Type.initTag(.type), | ||
| 1505 | .val = Value.initTag(.atomic_ordering_type), | ||
| 1506 | }, | ||
| 1507 | .atomic_rmw_op_type = .{ | ||
| 1508 | .ty = Type.initTag(.type), | ||
| 1509 | .val = Value.initTag(.atomic_rmw_op_type), | ||
| 1510 | }, | ||
| 1511 | .calling_convention_type = .{ | ||
| 1512 | .ty = Type.initTag(.type), | ||
| 1513 | .val = Value.initTag(.calling_convention_type), | ||
| 1514 | }, | ||
| 1515 | .float_mode_type = .{ | ||
| 1516 | .ty = Type.initTag(.type), | ||
| 1517 | .val = Value.initTag(.float_mode_type), | ||
| 1518 | }, | ||
| 1519 | .reduce_op_type = .{ | ||
| 1520 | .ty = Type.initTag(.type), | ||
| 1521 | .val = Value.initTag(.reduce_op_type), | ||
| 1522 | }, | ||
| 1523 | .call_options_type = .{ | ||
| 1524 | .ty = Type.initTag(.type), | ||
| 1525 | .val = Value.initTag(.call_options_type), | ||
| 1526 | }, | ||
| 1194 | 1527 | ||
| 1195 | .undef = .{ | 1528 | .undef = .{ |
| 1196 | .ty = Type.initTag(.@"undefined"), | 1529 | .ty = Type.initTag(.@"undefined"), |
| ... | @@ -1236,13 +1569,27 @@ pub const Inst = struct { | ... | @@ -1236,13 +1569,27 @@ pub const Inst = struct { |
| 1236 | .ty = Type.initTag(.empty_struct_literal), | 1569 | .ty = Type.initTag(.empty_struct_literal), |
| 1237 | .val = Value.initTag(.empty_struct_value), | 1570 | .val = Value.initTag(.empty_struct_value), |
| 1238 | }, | 1571 | }, |
| 1572 | .calling_convention_c = .{ | ||
| 1573 | .ty = Type.initTag(.calling_convention), | ||
| 1574 | .val = .{ .ptr_otherwise = &calling_convention_c_payload.base }, | ||
| 1575 | }, | ||
| 1239 | }); | 1576 | }); |
| 1240 | }; | 1577 | }; |
| 1241 | 1578 | ||
| 1579 | /// We would like this to be const but `Value` wants a mutable pointer for | ||
| 1580 | /// its payload field. Nothing should mutate this though. | ||
| 1581 | var calling_convention_c_payload: Value.Payload.U32 = .{ | ||
| 1582 | .base = .{ .tag = .enum_field_index }, | ||
| 1583 | .data = @enumToInt(std.builtin.CallingConvention.C), | ||
| 1584 | }; | ||
| 1585 | |||
| 1242 | /// All instructions have an 8-byte payload, which is contained within | 1586 | /// All instructions have an 8-byte payload, which is contained within |
| 1243 | /// this union. `Tag` determines which union field is active, as well as | 1587 | /// this union. `Tag` determines which union field is active, as well as |
| 1244 | /// how to interpret the data within. | 1588 | /// how to interpret the data within. |
| 1245 | pub const Data = union { | 1589 | pub const Data = union { |
| 1590 | /// Used for `Tag.extended`. The extended opcode determines the meaning | ||
| 1591 | /// of the `small` and `operand` fields. | ||
| 1592 | extended: Extended.InstData, | ||
| 1246 | /// Used for unary operators, with an AST node source location. | 1593 | /// Used for unary operators, with an AST node source location. |
| 1247 | un_node: struct { | 1594 | un_node: struct { |
| 1248 | /// Offset from Decl AST node index. | 1595 | /// Offset from Decl AST node index. |
| ... | @@ -1462,6 +1809,12 @@ pub const Inst = struct { | ... | @@ -1462,6 +1809,12 @@ pub const Inst = struct { |
| 1462 | args_len: u32, | 1809 | args_len: u32, |
| 1463 | }; | 1810 | }; |
| 1464 | 1811 | ||
| 1812 | pub const BuiltinCall = struct { | ||
| 1813 | options: Ref, | ||
| 1814 | callee: Ref, | ||
| 1815 | args: Ref, | ||
| 1816 | }; | ||
| 1817 | |||
| 1465 | /// This data is stored inside extra, with two sets of trailing `Ref`: | 1818 | /// This data is stored inside extra, with two sets of trailing `Ref`: |
| 1466 | /// * 0. the then body, according to `then_body_len`. | 1819 | /// * 0. the then body, according to `then_body_len`. |
| 1467 | /// * 1. the else body, according to `else_body_len`. | 1820 | /// * 1. the else body, according to `else_body_len`. |
| ... | @@ -1510,6 +1863,17 @@ pub const Inst = struct { | ... | @@ -1510,6 +1863,17 @@ pub const Inst = struct { |
| 1510 | rhs: Ref, | 1863 | rhs: Ref, |
| 1511 | }; | 1864 | }; |
| 1512 | 1865 | ||
| 1866 | pub const BinNode = struct { | ||
| 1867 | node: i32, | ||
| 1868 | lhs: Ref, | ||
| 1869 | rhs: Ref, | ||
| 1870 | }; | ||
| 1871 | |||
| 1872 | pub const UnNode = struct { | ||
| 1873 | node: i32, | ||
| 1874 | operand: Ref, | ||
| 1875 | }; | ||
| 1876 | |||
| 1513 | /// This form is supported when there are no ranges, and exactly 1 item per block. | 1877 | /// This form is supported when there are no ranges, and exactly 1 item per block. |
| 1514 | /// Depending on zir tag and len fields, extra fields trail | 1878 | /// Depending on zir tag and len fields, extra fields trail |
| 1515 | /// this one in the extra array. | 1879 | /// this one in the extra array. |
| ... | @@ -1679,6 +2043,70 @@ pub const Inst = struct { | ... | @@ -1679,6 +2043,70 @@ pub const Inst = struct { |
| 1679 | ptr: Ref, | 2043 | ptr: Ref, |
| 1680 | }; | 2044 | }; |
| 1681 | 2045 | ||
| 2046 | pub const Cmpxchg = struct { | ||
| 2047 | ptr: Ref, | ||
| 2048 | expected_value: Ref, | ||
| 2049 | new_value: Ref, | ||
| 2050 | success_order: Ref, | ||
| 2051 | fail_order: Ref, | ||
| 2052 | }; | ||
| 2053 | |||
| 2054 | pub const AtomicRmw = struct { | ||
| 2055 | ptr: Ref, | ||
| 2056 | operation: Ref, | ||
| 2057 | operand: Ref, | ||
| 2058 | ordering: Ref, | ||
| 2059 | }; | ||
| 2060 | |||
| 2061 | pub const UnionInitPtr = struct { | ||
| 2062 | union_type: Ref, | ||
| 2063 | field_name: Ref, | ||
| 2064 | }; | ||
| 2065 | |||
| 2066 | pub const AtomicStore = struct { | ||
| 2067 | ptr: Ref, | ||
| 2068 | operand: Ref, | ||
| 2069 | ordering: Ref, | ||
| 2070 | }; | ||
| 2071 | |||
| 2072 | pub const MulAdd = struct { | ||
| 2073 | mulend1: Ref, | ||
| 2074 | mulend2: Ref, | ||
| 2075 | addend: Ref, | ||
| 2076 | }; | ||
| 2077 | |||
| 2078 | pub const FieldParentPtr = struct { | ||
| 2079 | parent_type: Ref, | ||
| 2080 | field_name: Ref, | ||
| 2081 | field_ptr: Ref, | ||
| 2082 | }; | ||
| 2083 | |||
| 2084 | pub const Memcpy = struct { | ||
| 2085 | dest: Ref, | ||
| 2086 | source: Ref, | ||
| 2087 | byte_count: Ref, | ||
| 2088 | }; | ||
| 2089 | |||
| 2090 | pub const Memset = struct { | ||
| 2091 | dest: Ref, | ||
| 2092 | byte: Ref, | ||
| 2093 | byte_count: Ref, | ||
| 2094 | }; | ||
| 2095 | |||
| 2096 | pub const Shuffle = struct { | ||
| 2097 | elem_type: Ref, | ||
| 2098 | a: Ref, | ||
| 2099 | b: Ref, | ||
| 2100 | mask: Ref, | ||
| 2101 | }; | ||
| 2102 | |||
| 2103 | pub const AsyncCall = struct { | ||
| 2104 | frame_buffer: Ref, | ||
| 2105 | result_ptr: Ref, | ||
| 2106 | fn_ptr: Ref, | ||
| 2107 | args: Ref, | ||
| 2108 | }; | ||
| 2109 | |||
| 1682 | /// Trailing: `CompileErrors.Item` for each `items_len`. | 2110 | /// Trailing: `CompileErrors.Item` for each `items_len`. |
| 1683 | pub const CompileErrors = struct { | 2111 | pub const CompileErrors = struct { |
| 1684 | items_len: u32, | 2112 | items_len: u32, |
| ... | @@ -1749,13 +2177,11 @@ const Writer = struct { | ... | @@ -1749,13 +2177,11 @@ const Writer = struct { |
| 1749 | .negate_wrap, | 2177 | .negate_wrap, |
| 1750 | .call_none, | 2178 | .call_none, |
| 1751 | .call_none_chkused, | 2179 | .call_none_chkused, |
| 1752 | .compile_error, | ||
| 1753 | .load, | 2180 | .load, |
| 1754 | .ensure_result_used, | 2181 | .ensure_result_used, |
| 1755 | .ensure_result_non_error, | 2182 | .ensure_result_non_error, |
| 1756 | .ptrtoint, | 2183 | .ptrtoint, |
| 1757 | .ret_node, | 2184 | .ret_node, |
| 1758 | .set_eval_branch_quota, | ||
| 1759 | .resolve_inferred_alloc, | 2185 | .resolve_inferred_alloc, |
| 1760 | .optional_type, | 2186 | .optional_type, |
| 1761 | .optional_type_from_ptr_elem, | 2187 | .optional_type_from_ptr_elem, |
| ... | @@ -1769,8 +2195,6 @@ const Writer = struct { | ... | @@ -1769,8 +2195,6 @@ const Writer = struct { |
| 1769 | .err_union_payload_unsafe_ptr, | 2195 | .err_union_payload_unsafe_ptr, |
| 1770 | .err_union_code, | 2196 | .err_union_code, |
| 1771 | .err_union_code_ptr, | 2197 | .err_union_code_ptr, |
| 1772 | .int_to_error, | ||
| 1773 | .error_to_int, | ||
| 1774 | .is_non_null, | 2198 | .is_non_null, |
| 1775 | .is_null, | 2199 | .is_null, |
| 1776 | .is_non_null_ptr, | 2200 | .is_non_null_ptr, |
| ... | @@ -1780,11 +2204,49 @@ const Writer = struct { | ... | @@ -1780,11 +2204,49 @@ const Writer = struct { |
| 1780 | .typeof, | 2204 | .typeof, |
| 1781 | .typeof_elem, | 2205 | .typeof_elem, |
| 1782 | .struct_init_empty, | 2206 | .struct_init_empty, |
| 1783 | .enum_to_int, | ||
| 1784 | .type_info, | 2207 | .type_info, |
| 1785 | .size_of, | 2208 | .size_of, |
| 1786 | .bit_size_of, | 2209 | .bit_size_of, |
| 2210 | .typeof_log2_int_type, | ||
| 1787 | .log2_int_type, | 2211 | .log2_int_type, |
| 2212 | .ptr_to_int, | ||
| 2213 | .error_to_int, | ||
| 2214 | .int_to_error, | ||
| 2215 | .compile_error, | ||
| 2216 | .set_eval_branch_quota, | ||
| 2217 | .enum_to_int, | ||
| 2218 | .align_of, | ||
| 2219 | .bool_to_int, | ||
| 2220 | .embed_file, | ||
| 2221 | .error_name, | ||
| 2222 | .panic, | ||
| 2223 | .set_align_stack, | ||
| 2224 | .set_cold, | ||
| 2225 | .set_float_mode, | ||
| 2226 | .set_runtime_safety, | ||
| 2227 | .sqrt, | ||
| 2228 | .sin, | ||
| 2229 | .cos, | ||
| 2230 | .exp, | ||
| 2231 | .exp2, | ||
| 2232 | .log, | ||
| 2233 | .log2, | ||
| 2234 | .log10, | ||
| 2235 | .fabs, | ||
| 2236 | .floor, | ||
| 2237 | .ceil, | ||
| 2238 | .trunc, | ||
| 2239 | .round, | ||
| 2240 | .tag_name, | ||
| 2241 | .reify, | ||
| 2242 | .type_name, | ||
| 2243 | .frame_type, | ||
| 2244 | .frame_size, | ||
| 2245 | .clz, | ||
| 2246 | .ctz, | ||
| 2247 | .pop_count, | ||
| 2248 | .byte_swap, | ||
| 2249 | .bit_reverse, | ||
| 1788 | => try self.writeUnNode(stream, inst), | 2250 | => try self.writeUnNode(stream, inst), |
| 1789 | 2251 | ||
| 1790 | .ref, | 2252 | .ref, |
| ... | @@ -1805,7 +2267,6 @@ const Writer = struct { | ... | @@ -1805,7 +2267,6 @@ const Writer = struct { |
| 1805 | .float => try self.writeFloat(stream, inst), | 2267 | .float => try self.writeFloat(stream, inst), |
| 1806 | .float128 => try self.writeFloat128(stream, inst), | 2268 | .float128 => try self.writeFloat128(stream, inst), |
| 1807 | .str => try self.writeStr(stream, inst), | 2269 | .str => try self.writeStr(stream, inst), |
| 1808 | .elided => try stream.writeAll(")"), | ||
| 1809 | .int_type => try self.writeIntType(stream, inst), | 2270 | .int_type => try self.writeIntType(stream, inst), |
| 1810 | 2271 | ||
| 1811 | .@"break", | 2272 | .@"break", |
| ... | @@ -1824,7 +2285,20 @@ const Writer = struct { | ... | @@ -1824,7 +2285,20 @@ const Writer = struct { |
| 1824 | .slice_sentinel, | 2285 | .slice_sentinel, |
| 1825 | .union_decl, | 2286 | .union_decl, |
| 1826 | .struct_init, | 2287 | .struct_init, |
| 2288 | .union_init_ptr, | ||
| 1827 | .field_type, | 2289 | .field_type, |
| 2290 | .cmpxchg_strong, | ||
| 2291 | .cmpxchg_weak, | ||
| 2292 | .shuffle, | ||
| 2293 | .atomic_rmw, | ||
| 2294 | .atomic_store, | ||
| 2295 | .mul_add, | ||
| 2296 | .builtin_call, | ||
| 2297 | .field_ptr_type, | ||
| 2298 | .field_parent_ptr, | ||
| 2299 | .memcpy, | ||
| 2300 | .memset, | ||
| 2301 | .builtin_async_call, | ||
| 1828 | => try self.writePlNode(stream, inst), | 2302 | => try self.writePlNode(stream, inst), |
| 1829 | 2303 | ||
| 1830 | .add_with_overflow, | 2304 | .add_with_overflow, |
| ... | @@ -1851,9 +2325,12 @@ const Writer = struct { | ... | @@ -1851,9 +2325,12 @@ const Writer = struct { |
| 1851 | .cmp_neq, | 2325 | .cmp_neq, |
| 1852 | .div, | 2326 | .div, |
| 1853 | .has_decl, | 2327 | .has_decl, |
| 2328 | .has_field, | ||
| 1854 | .mod_rem, | 2329 | .mod_rem, |
| 1855 | .shl, | 2330 | .shl, |
| 2331 | .shl_exact, | ||
| 1856 | .shr, | 2332 | .shr, |
| 2333 | .shr_exact, | ||
| 1857 | .xor, | 2334 | .xor, |
| 1858 | .store_node, | 2335 | .store_node, |
| 1859 | .error_union_type, | 2336 | .error_union_type, |
| ... | @@ -1861,7 +2338,26 @@ const Writer = struct { | ... | @@ -1861,7 +2338,26 @@ const Writer = struct { |
| 1861 | .merge_error_sets, | 2338 | .merge_error_sets, |
| 1862 | .bit_and, | 2339 | .bit_and, |
| 1863 | .bit_or, | 2340 | .bit_or, |
| 2341 | .float_to_int, | ||
| 2342 | .int_to_float, | ||
| 2343 | .int_to_ptr, | ||
| 1864 | .int_to_enum, | 2344 | .int_to_enum, |
| 2345 | .float_cast, | ||
| 2346 | .int_cast, | ||
| 2347 | .err_set_cast, | ||
| 2348 | .ptr_cast, | ||
| 2349 | .truncate, | ||
| 2350 | .align_cast, | ||
| 2351 | .div_exact, | ||
| 2352 | .div_floor, | ||
| 2353 | .div_trunc, | ||
| 2354 | .mod, | ||
| 2355 | .rem, | ||
| 2356 | .bit_offset_of, | ||
| 2357 | .byte_offset_of, | ||
| 2358 | .splat, | ||
| 2359 | .reduce, | ||
| 2360 | .atomic_load, | ||
| 1865 | => try self.writePlNodeBin(stream, inst), | 2361 | => try self.writePlNodeBin(stream, inst), |
| 1866 | 2362 | ||
| 1867 | .call, | 2363 | .call, |
| ... | @@ -1874,6 +2370,7 @@ const Writer = struct { | ... | @@ -1874,6 +2370,7 @@ const Writer = struct { |
| 1874 | .block_inline_var, | 2370 | .block_inline_var, |
| 1875 | .loop, | 2371 | .loop, |
| 1876 | .validate_struct_init_ptr, | 2372 | .validate_struct_init_ptr, |
| 2373 | .c_import, | ||
| 1877 | => try self.writePlNodeBlock(stream, inst), | 2374 | => try self.writePlNodeBlock(stream, inst), |
| 1878 | 2375 | ||
| 1879 | .condbr, | 2376 | .condbr, |
| ... | @@ -1926,6 +2423,9 @@ const Writer = struct { | ... | @@ -1926,6 +2423,9 @@ const Writer = struct { |
| 1926 | .fence, | 2423 | .fence, |
| 1927 | .ret_addr, | 2424 | .ret_addr, |
| 1928 | .builtin_src, | 2425 | .builtin_src, |
| 2426 | .error_return_trace, | ||
| 2427 | .frame, | ||
| 2428 | .frame_address, | ||
| 1929 | => try self.writeNode(stream, inst), | 2429 | => try self.writeNode(stream, inst), |
| 1930 | 2430 | ||
| 1931 | .error_value, | 2431 | .error_value, |
| ... | @@ -1954,6 +2454,7 @@ const Writer = struct { | ... | @@ -1954,6 +2454,7 @@ const Writer = struct { |
| 1954 | 2454 | ||
| 1955 | .bitcast, | 2455 | .bitcast, |
| 1956 | .bitcast_result_ptr, | 2456 | .bitcast_result_ptr, |
| 2457 | .extended, | ||
| 1957 | => try stream.writeAll("TODO)"), | 2458 | => try stream.writeAll("TODO)"), |
| 1958 | } | 2459 | } |
| 1959 | } | 2460 | } |
src/type.zig+185-3| ... | @@ -83,6 +83,8 @@ pub const Type = extern union { | ... | @@ -83,6 +83,8 @@ pub const Type = extern union { |
| 83 | .pointer, | 83 | .pointer, |
| 84 | .inferred_alloc_const, | 84 | .inferred_alloc_const, |
| 85 | .inferred_alloc_mut, | 85 | .inferred_alloc_mut, |
| 86 | .manyptr_u8, | ||
| 87 | .manyptr_const_u8, | ||
| 86 | => return .Pointer, | 88 | => return .Pointer, |
| 87 | 89 | ||
| 88 | .optional, | 90 | .optional, |
| ... | @@ -96,11 +98,17 @@ pub const Type = extern union { | ... | @@ -96,11 +98,17 @@ pub const Type = extern union { |
| 96 | .empty_struct, | 98 | .empty_struct, |
| 97 | .empty_struct_literal, | 99 | .empty_struct_literal, |
| 98 | .@"struct", | 100 | .@"struct", |
| 101 | .call_options, | ||
| 99 | => return .Struct, | 102 | => return .Struct, |
| 100 | 103 | ||
| 101 | .enum_full, | 104 | .enum_full, |
| 102 | .enum_nonexhaustive, | 105 | .enum_nonexhaustive, |
| 103 | .enum_simple, | 106 | .enum_simple, |
| 107 | .atomic_ordering, | ||
| 108 | .atomic_rmw_op, | ||
| 109 | .calling_convention, | ||
| 110 | .float_mode, | ||
| 111 | .reduce_op, | ||
| 104 | => return .Enum, | 112 | => return .Enum, |
| 105 | 113 | ||
| 106 | .var_args_param => unreachable, // can be any type | 114 | .var_args_param => unreachable, // can be any type |
| ... | @@ -205,6 +213,8 @@ pub const Type = extern union { | ... | @@ -205,6 +213,8 @@ pub const Type = extern union { |
| 205 | .mut_slice, | 213 | .mut_slice, |
| 206 | .optional_single_const_pointer, | 214 | .optional_single_const_pointer, |
| 207 | .optional_single_mut_pointer, | 215 | .optional_single_mut_pointer, |
| 216 | .manyptr_u8, | ||
| 217 | .manyptr_const_u8, | ||
| 208 | => self.cast(Payload.ElemType), | 218 | => self.cast(Payload.ElemType), |
| 209 | 219 | ||
| 210 | .inferred_alloc_const => unreachable, | 220 | .inferred_alloc_const => unreachable, |
| ... | @@ -271,6 +281,17 @@ pub const Type = extern union { | ... | @@ -271,6 +281,17 @@ pub const Type = extern union { |
| 271 | .@"volatile" = false, | 281 | .@"volatile" = false, |
| 272 | .size = .Many, | 282 | .size = .Many, |
| 273 | } }, | 283 | } }, |
| 284 | .manyptr_const_u8 => return .{ .data = .{ | ||
| 285 | .pointee_type = Type.initTag(.u8), | ||
| 286 | .sentinel = null, | ||
| 287 | .@"align" = 0, | ||
| 288 | .bit_offset = 0, | ||
| 289 | .host_size = 0, | ||
| 290 | .@"allowzero" = false, | ||
| 291 | .mutable = false, | ||
| 292 | .@"volatile" = false, | ||
| 293 | .size = .Many, | ||
| 294 | } }, | ||
| 274 | .many_mut_pointer => return .{ .data = .{ | 295 | .many_mut_pointer => return .{ .data = .{ |
| 275 | .pointee_type = self.castPointer().?.data, | 296 | .pointee_type = self.castPointer().?.data, |
| 276 | .sentinel = null, | 297 | .sentinel = null, |
| ... | @@ -282,6 +303,17 @@ pub const Type = extern union { | ... | @@ -282,6 +303,17 @@ pub const Type = extern union { |
| 282 | .@"volatile" = false, | 303 | .@"volatile" = false, |
| 283 | .size = .Many, | 304 | .size = .Many, |
| 284 | } }, | 305 | } }, |
| 306 | .manyptr_u8 => return .{ .data = .{ | ||
| 307 | .pointee_type = Type.initTag(.u8), | ||
| 308 | .sentinel = null, | ||
| 309 | .@"align" = 0, | ||
| 310 | .bit_offset = 0, | ||
| 311 | .host_size = 0, | ||
| 312 | .@"allowzero" = false, | ||
| 313 | .mutable = true, | ||
| 314 | .@"volatile" = false, | ||
| 315 | .size = .Many, | ||
| 316 | } }, | ||
| 285 | .c_const_pointer => return .{ .data = .{ | 317 | .c_const_pointer => return .{ .data = .{ |
| 286 | .pointee_type = self.castPointer().?.data, | 318 | .pointee_type = self.castPointer().?.data, |
| 287 | .sentinel = null, | 319 | .sentinel = null, |
| ... | @@ -576,6 +608,14 @@ pub const Type = extern union { | ... | @@ -576,6 +608,14 @@ pub const Type = extern union { |
| 576 | .inferred_alloc_mut, | 608 | .inferred_alloc_mut, |
| 577 | .var_args_param, | 609 | .var_args_param, |
| 578 | .empty_struct_literal, | 610 | .empty_struct_literal, |
| 611 | .manyptr_u8, | ||
| 612 | .manyptr_const_u8, | ||
| 613 | .atomic_ordering, | ||
| 614 | .atomic_rmw_op, | ||
| 615 | .calling_convention, | ||
| 616 | .float_mode, | ||
| 617 | .reduce_op, | ||
| 618 | .call_options, | ||
| 579 | => unreachable, | 619 | => unreachable, |
| 580 | 620 | ||
| 581 | .array_u8, | 621 | .array_u8, |
| ... | @@ -746,6 +786,14 @@ pub const Type = extern union { | ... | @@ -746,6 +786,14 @@ pub const Type = extern union { |
| 746 | .fn_naked_noreturn_no_args => return writer.writeAll("fn() callconv(.Naked) noreturn"), | 786 | .fn_naked_noreturn_no_args => return writer.writeAll("fn() callconv(.Naked) noreturn"), |
| 747 | .fn_ccc_void_no_args => return writer.writeAll("fn() callconv(.C) void"), | 787 | .fn_ccc_void_no_args => return writer.writeAll("fn() callconv(.C) void"), |
| 748 | .single_const_pointer_to_comptime_int => return writer.writeAll("*const comptime_int"), | 788 | .single_const_pointer_to_comptime_int => return writer.writeAll("*const comptime_int"), |
| 789 | .manyptr_u8 => return writer.writeAll("[*]u8"), | ||
| 790 | .manyptr_const_u8 => return writer.writeAll("[*]const u8"), | ||
| 791 | .atomic_ordering => return writer.writeAll("std.builtin.AtomicOrdering"), | ||
| 792 | .atomic_rmw_op => return writer.writeAll("std.builtin.AtomicRmwOp"), | ||
| 793 | .calling_convention => return writer.writeAll("std.builtin.CallingConvention"), | ||
| 794 | .float_mode => return writer.writeAll("std.builtin.FloatMode"), | ||
| 795 | .reduce_op => return writer.writeAll("std.builtin.ReduceOp"), | ||
| 796 | .call_options => return writer.writeAll("std.builtin.CallOptions"), | ||
| 749 | .function => { | 797 | .function => { |
| 750 | const payload = ty.castTag(.function).?.data; | 798 | const payload = ty.castTag(.function).?.data; |
| 751 | try writer.writeAll("fn("); | 799 | try writer.writeAll("fn("); |
| ... | @@ -952,6 +1000,14 @@ pub const Type = extern union { | ... | @@ -952,6 +1000,14 @@ pub const Type = extern union { |
| 952 | .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type), | 1000 | .single_const_pointer_to_comptime_int => return Value.initTag(.single_const_pointer_to_comptime_int_type), |
| 953 | .const_slice_u8 => return Value.initTag(.const_slice_u8_type), | 1001 | .const_slice_u8 => return Value.initTag(.const_slice_u8_type), |
| 954 | .enum_literal => return Value.initTag(.enum_literal_type), | 1002 | .enum_literal => return Value.initTag(.enum_literal_type), |
| 1003 | .manyptr_u8 => return Value.initTag(.manyptr_u8_type), | ||
| 1004 | .manyptr_const_u8 => return Value.initTag(.manyptr_const_u8_type), | ||
| 1005 | .atomic_ordering => return Value.initTag(.atomic_ordering_type), | ||
| 1006 | .atomic_rmw_op => return Value.initTag(.atomic_rmw_op_type), | ||
| 1007 | .calling_convention => return Value.initTag(.calling_convention_type), | ||
| 1008 | .float_mode => return Value.initTag(.float_mode_type), | ||
| 1009 | .reduce_op => return Value.initTag(.reduce_op_type), | ||
| 1010 | .call_options => return Value.initTag(.call_options_type), | ||
| 955 | .inferred_alloc_const => unreachable, | 1011 | .inferred_alloc_const => unreachable, |
| 956 | .inferred_alloc_mut => unreachable, | 1012 | .inferred_alloc_mut => unreachable, |
| 957 | else => return Value.Tag.ty.create(allocator, self), | 1013 | else => return Value.Tag.ty.create(allocator, self), |
| ... | @@ -1001,6 +1057,14 @@ pub const Type = extern union { | ... | @@ -1001,6 +1057,14 @@ pub const Type = extern union { |
| 1001 | .anyerror_void_error_union, | 1057 | .anyerror_void_error_union, |
| 1002 | .error_set, | 1058 | .error_set, |
| 1003 | .error_set_single, | 1059 | .error_set_single, |
| 1060 | .manyptr_u8, | ||
| 1061 | .manyptr_const_u8, | ||
| 1062 | .atomic_ordering, | ||
| 1063 | .atomic_rmw_op, | ||
| 1064 | .calling_convention, | ||
| 1065 | .float_mode, | ||
| 1066 | .reduce_op, | ||
| 1067 | .call_options, | ||
| 1004 | => true, | 1068 | => true, |
| 1005 | 1069 | ||
| 1006 | .@"struct" => { | 1070 | .@"struct" => { |
| ... | @@ -1079,7 +1143,10 @@ pub const Type = extern union { | ... | @@ -1079,7 +1143,10 @@ pub const Type = extern union { |
| 1079 | .optional_single_mut_pointer, | 1143 | .optional_single_mut_pointer, |
| 1080 | => return self.cast(Payload.ElemType).?.data.abiAlignment(target), | 1144 | => return self.cast(Payload.ElemType).?.data.abiAlignment(target), |
| 1081 | 1145 | ||
| 1082 | .const_slice_u8 => return 1, | 1146 | .manyptr_u8, |
| 1147 | .manyptr_const_u8, | ||
| 1148 | .const_slice_u8, | ||
| 1149 | => return 1, | ||
| 1083 | 1150 | ||
| 1084 | .pointer => { | 1151 | .pointer => { |
| 1085 | const ptr_info = self.castTag(.pointer).?.data; | 1152 | const ptr_info = self.castTag(.pointer).?.data; |
| ... | @@ -1102,6 +1169,12 @@ pub const Type = extern union { | ... | @@ -1102,6 +1169,12 @@ pub const Type = extern union { |
| 1102 | .bool, | 1169 | .bool, |
| 1103 | .array_u8_sentinel_0, | 1170 | .array_u8_sentinel_0, |
| 1104 | .array_u8, | 1171 | .array_u8, |
| 1172 | .atomic_ordering, | ||
| 1173 | .atomic_rmw_op, | ||
| 1174 | .calling_convention, | ||
| 1175 | .float_mode, | ||
| 1176 | .reduce_op, | ||
| 1177 | .call_options, | ||
| 1105 | => return 1, | 1178 | => return 1, |
| 1106 | 1179 | ||
| 1107 | .fn_noreturn_no_args, // represents machine code; not a pointer | 1180 | .fn_noreturn_no_args, // represents machine code; not a pointer |
| ... | @@ -1136,6 +1209,8 @@ pub const Type = extern union { | ... | @@ -1136,6 +1209,8 @@ pub const Type = extern union { |
| 1136 | .optional_single_const_pointer, | 1209 | .optional_single_const_pointer, |
| 1137 | .optional_single_mut_pointer, | 1210 | .optional_single_mut_pointer, |
| 1138 | .pointer, | 1211 | .pointer, |
| 1212 | .manyptr_u8, | ||
| 1213 | .manyptr_const_u8, | ||
| 1139 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), | 1214 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), |
| 1140 | 1215 | ||
| 1141 | .c_short => return @divExact(CType.short.sizeInBits(target), 8), | 1216 | .c_short => return @divExact(CType.short.sizeInBits(target), 8), |
| ... | @@ -1271,6 +1346,12 @@ pub const Type = extern union { | ... | @@ -1271,6 +1346,12 @@ pub const Type = extern union { |
| 1271 | .u8, | 1346 | .u8, |
| 1272 | .i8, | 1347 | .i8, |
| 1273 | .bool, | 1348 | .bool, |
| 1349 | .atomic_ordering, | ||
| 1350 | .atomic_rmw_op, | ||
| 1351 | .calling_convention, | ||
| 1352 | .float_mode, | ||
| 1353 | .reduce_op, | ||
| 1354 | .call_options, | ||
| 1274 | => return 1, | 1355 | => return 1, |
| 1275 | 1356 | ||
| 1276 | .array_u8 => self.castTag(.array_u8).?.data, | 1357 | .array_u8 => self.castTag(.array_u8).?.data, |
| ... | @@ -1322,6 +1403,10 @@ pub const Type = extern union { | ... | @@ -1322,6 +1403,10 @@ pub const Type = extern union { |
| 1322 | return @divExact(target.cpu.arch.ptrBitWidth(), 8); | 1403 | return @divExact(target.cpu.arch.ptrBitWidth(), 8); |
| 1323 | }, | 1404 | }, |
| 1324 | 1405 | ||
| 1406 | .manyptr_u8, | ||
| 1407 | .manyptr_const_u8, | ||
| 1408 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), | ||
| 1409 | |||
| 1325 | .c_short => return @divExact(CType.short.sizeInBits(target), 8), | 1410 | .c_short => return @divExact(CType.short.sizeInBits(target), 8), |
| 1326 | .c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8), | 1411 | .c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8), |
| 1327 | .c_int => return @divExact(CType.int.sizeInBits(target), 8), | 1412 | .c_int => return @divExact(CType.int.sizeInBits(target), 8), |
| ... | @@ -1475,6 +1560,10 @@ pub const Type = extern union { | ... | @@ -1475,6 +1560,10 @@ pub const Type = extern union { |
| 1475 | } | 1560 | } |
| 1476 | }, | 1561 | }, |
| 1477 | 1562 | ||
| 1563 | .manyptr_u8, | ||
| 1564 | .manyptr_const_u8, | ||
| 1565 | => return target.cpu.arch.ptrBitWidth(), | ||
| 1566 | |||
| 1478 | .c_short => return CType.short.sizeInBits(target), | 1567 | .c_short => return CType.short.sizeInBits(target), |
| 1479 | .c_ushort => return CType.ushort.sizeInBits(target), | 1568 | .c_ushort => return CType.ushort.sizeInBits(target), |
| 1480 | .c_int => return CType.int.sizeInBits(target), | 1569 | .c_int => return CType.int.sizeInBits(target), |
| ... | @@ -1517,8 +1606,16 @@ pub const Type = extern union { | ... | @@ -1517,8 +1606,16 @@ pub const Type = extern union { |
| 1517 | } else if (!payload.payload.hasCodeGenBits()) { | 1606 | } else if (!payload.payload.hasCodeGenBits()) { |
| 1518 | return payload.error_set.bitSize(target); | 1607 | return payload.error_set.bitSize(target); |
| 1519 | } | 1608 | } |
| 1520 | @panic("TODO abiSize error union"); | 1609 | @panic("TODO bitSize error union"); |
| 1521 | }, | 1610 | }, |
| 1611 | |||
| 1612 | .atomic_ordering, | ||
| 1613 | .atomic_rmw_op, | ||
| 1614 | .calling_convention, | ||
| 1615 | .float_mode, | ||
| 1616 | .reduce_op, | ||
| 1617 | .call_options, | ||
| 1618 | => @panic("TODO at some point we gotta resolve builtin types"), | ||
| 1522 | }; | 1619 | }; |
| 1523 | } | 1620 | } |
| 1524 | 1621 | ||
| ... | @@ -1564,6 +1661,8 @@ pub const Type = extern union { | ... | @@ -1564,6 +1661,8 @@ pub const Type = extern union { |
| 1564 | 1661 | ||
| 1565 | .many_const_pointer, | 1662 | .many_const_pointer, |
| 1566 | .many_mut_pointer, | 1663 | .many_mut_pointer, |
| 1664 | .manyptr_u8, | ||
| 1665 | .manyptr_const_u8, | ||
| 1567 | => .Many, | 1666 | => .Many, |
| 1568 | 1667 | ||
| 1569 | .c_const_pointer, | 1668 | .c_const_pointer, |
| ... | @@ -1604,6 +1703,7 @@ pub const Type = extern union { | ... | @@ -1604,6 +1703,7 @@ pub const Type = extern union { |
| 1604 | .single_const_pointer_to_comptime_int, | 1703 | .single_const_pointer_to_comptime_int, |
| 1605 | .const_slice_u8, | 1704 | .const_slice_u8, |
| 1606 | .const_slice, | 1705 | .const_slice, |
| 1706 | .manyptr_const_u8, | ||
| 1607 | => true, | 1707 | => true, |
| 1608 | 1708 | ||
| 1609 | .pointer => !self.castTag(.pointer).?.data.mutable, | 1709 | .pointer => !self.castTag(.pointer).?.data.mutable, |
| ... | @@ -1718,7 +1818,13 @@ pub const Type = extern union { | ... | @@ -1718,7 +1818,13 @@ pub const Type = extern union { |
| 1718 | .mut_slice, | 1818 | .mut_slice, |
| 1719 | => self.castPointer().?.data, | 1819 | => self.castPointer().?.data, |
| 1720 | 1820 | ||
| 1721 | .array_u8, .array_u8_sentinel_0, .const_slice_u8 => Type.initTag(.u8), | 1821 | .array_u8, |
| 1822 | .array_u8_sentinel_0, | ||
| 1823 | .const_slice_u8, | ||
| 1824 | .manyptr_u8, | ||
| 1825 | .manyptr_const_u8, | ||
| 1826 | => Type.initTag(.u8), | ||
| 1827 | |||
| 1722 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), | 1828 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), |
| 1723 | .pointer => self.castTag(.pointer).?.data.pointee_type, | 1829 | .pointer => self.castTag(.pointer).?.data.pointee_type, |
| 1724 | 1830 | ||
| ... | @@ -1811,6 +1917,8 @@ pub const Type = extern union { | ... | @@ -1811,6 +1917,8 @@ pub const Type = extern union { |
| 1811 | .single_const_pointer_to_comptime_int, | 1917 | .single_const_pointer_to_comptime_int, |
| 1812 | .array, | 1918 | .array, |
| 1813 | .array_u8, | 1919 | .array_u8, |
| 1920 | .manyptr_u8, | ||
| 1921 | .manyptr_const_u8, | ||
| 1814 | => return null, | 1922 | => return null, |
| 1815 | 1923 | ||
| 1816 | .pointer => return self.castTag(.pointer).?.data.sentinel, | 1924 | .pointer => return self.castTag(.pointer).?.data.sentinel, |
| ... | @@ -2122,6 +2230,14 @@ pub const Type = extern union { | ... | @@ -2122,6 +2230,14 @@ pub const Type = extern union { |
| 2122 | .error_set_single, | 2230 | .error_set_single, |
| 2123 | .@"opaque", | 2231 | .@"opaque", |
| 2124 | .var_args_param, | 2232 | .var_args_param, |
| 2233 | .manyptr_u8, | ||
| 2234 | .manyptr_const_u8, | ||
| 2235 | .atomic_ordering, | ||
| 2236 | .atomic_rmw_op, | ||
| 2237 | .calling_convention, | ||
| 2238 | .float_mode, | ||
| 2239 | .reduce_op, | ||
| 2240 | .call_options, | ||
| 2125 | => return null, | 2241 | => return null, |
| 2126 | 2242 | ||
| 2127 | .@"struct" => { | 2243 | .@"struct" => { |
| ... | @@ -2281,6 +2397,14 @@ pub const Type = extern union { | ... | @@ -2281,6 +2397,14 @@ pub const Type = extern union { |
| 2281 | const enum_simple = ty.castTag(.enum_simple).?.data; | 2397 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 2282 | return enum_simple.fields.count(); | 2398 | return enum_simple.fields.count(); |
| 2283 | }, | 2399 | }, |
| 2400 | .atomic_ordering, | ||
| 2401 | .atomic_rmw_op, | ||
| 2402 | .calling_convention, | ||
| 2403 | .float_mode, | ||
| 2404 | .reduce_op, | ||
| 2405 | .call_options, | ||
| 2406 | => @panic("TODO resolve std.builtin types"), | ||
| 2407 | |||
| 2284 | else => unreachable, | 2408 | else => unreachable, |
| 2285 | } | 2409 | } |
| 2286 | } | 2410 | } |
| ... | @@ -2295,6 +2419,13 @@ pub const Type = extern union { | ... | @@ -2295,6 +2419,13 @@ pub const Type = extern union { |
| 2295 | const enum_simple = ty.castTag(.enum_simple).?.data; | 2419 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 2296 | return enum_simple.fields.entries.items[field_index].key; | 2420 | return enum_simple.fields.entries.items[field_index].key; |
| 2297 | }, | 2421 | }, |
| 2422 | .atomic_ordering, | ||
| 2423 | .atomic_rmw_op, | ||
| 2424 | .calling_convention, | ||
| 2425 | .float_mode, | ||
| 2426 | .reduce_op, | ||
| 2427 | .call_options, | ||
| 2428 | => @panic("TODO resolve std.builtin types"), | ||
| 2298 | else => unreachable, | 2429 | else => unreachable, |
| 2299 | } | 2430 | } |
| 2300 | } | 2431 | } |
| ... | @@ -2309,6 +2440,13 @@ pub const Type = extern union { | ... | @@ -2309,6 +2440,13 @@ pub const Type = extern union { |
| 2309 | const enum_simple = ty.castTag(.enum_simple).?.data; | 2440 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 2310 | return enum_simple.fields.getIndex(field_name); | 2441 | return enum_simple.fields.getIndex(field_name); |
| 2311 | }, | 2442 | }, |
| 2443 | .atomic_ordering, | ||
| 2444 | .atomic_rmw_op, | ||
| 2445 | .calling_convention, | ||
| 2446 | .float_mode, | ||
| 2447 | .reduce_op, | ||
| 2448 | .call_options, | ||
| 2449 | => @panic("TODO resolve std.builtin types"), | ||
| 2312 | else => unreachable, | 2450 | else => unreachable, |
| 2313 | } | 2451 | } |
| 2314 | } | 2452 | } |
| ... | @@ -2345,6 +2483,13 @@ pub const Type = extern union { | ... | @@ -2345,6 +2483,13 @@ pub const Type = extern union { |
| 2345 | const enum_simple = ty.castTag(.enum_simple).?.data; | 2483 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 2346 | return S.fieldWithRange(enum_tag, enum_simple.fields.count()); | 2484 | return S.fieldWithRange(enum_tag, enum_simple.fields.count()); |
| 2347 | }, | 2485 | }, |
| 2486 | .atomic_ordering, | ||
| 2487 | .atomic_rmw_op, | ||
| 2488 | .calling_convention, | ||
| 2489 | .float_mode, | ||
| 2490 | .reduce_op, | ||
| 2491 | .call_options, | ||
| 2492 | => @panic("TODO resolve std.builtin types"), | ||
| 2348 | else => unreachable, | 2493 | else => unreachable, |
| 2349 | } | 2494 | } |
| 2350 | } | 2495 | } |
| ... | @@ -2367,6 +2512,13 @@ pub const Type = extern union { | ... | @@ -2367,6 +2512,13 @@ pub const Type = extern union { |
| 2367 | const error_set = ty.castTag(.error_set).?.data; | 2512 | const error_set = ty.castTag(.error_set).?.data; |
| 2368 | return error_set.srcLoc(); | 2513 | return error_set.srcLoc(); |
| 2369 | }, | 2514 | }, |
| 2515 | .atomic_ordering, | ||
| 2516 | .atomic_rmw_op, | ||
| 2517 | .calling_convention, | ||
| 2518 | .float_mode, | ||
| 2519 | .reduce_op, | ||
| 2520 | .call_options, | ||
| 2521 | => @panic("TODO resolve std.builtin types"), | ||
| 2370 | else => unreachable, | 2522 | else => unreachable, |
| 2371 | } | 2523 | } |
| 2372 | } | 2524 | } |
| ... | @@ -2390,6 +2542,13 @@ pub const Type = extern union { | ... | @@ -2390,6 +2542,13 @@ pub const Type = extern union { |
| 2390 | return error_set.owner_decl; | 2542 | return error_set.owner_decl; |
| 2391 | }, | 2543 | }, |
| 2392 | .@"opaque" => @panic("TODO"), | 2544 | .@"opaque" => @panic("TODO"), |
| 2545 | .atomic_ordering, | ||
| 2546 | .atomic_rmw_op, | ||
| 2547 | .calling_convention, | ||
| 2548 | .float_mode, | ||
| 2549 | .reduce_op, | ||
| 2550 | .call_options, | ||
| 2551 | => @panic("TODO resolve std.builtin types"), | ||
| 2393 | else => unreachable, | 2552 | else => unreachable, |
| 2394 | } | 2553 | } |
| 2395 | } | 2554 | } |
| ... | @@ -2422,6 +2581,13 @@ pub const Type = extern union { | ... | @@ -2422,6 +2581,13 @@ pub const Type = extern union { |
| 2422 | const enum_simple = ty.castTag(.enum_simple).?.data; | 2581 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 2423 | return S.intInRange(int, enum_simple.fields.count()); | 2582 | return S.intInRange(int, enum_simple.fields.count()); |
| 2424 | }, | 2583 | }, |
| 2584 | .atomic_ordering, | ||
| 2585 | .atomic_rmw_op, | ||
| 2586 | .calling_convention, | ||
| 2587 | .float_mode, | ||
| 2588 | .reduce_op, | ||
| 2589 | .call_options, | ||
| 2590 | => @panic("TODO resolve std.builtin types"), | ||
| 2425 | 2591 | ||
| 2426 | else => unreachable, | 2592 | else => unreachable, |
| 2427 | } | 2593 | } |
| ... | @@ -2469,6 +2635,14 @@ pub const Type = extern union { | ... | @@ -2469,6 +2635,14 @@ pub const Type = extern union { |
| 2469 | comptime_float, | 2635 | comptime_float, |
| 2470 | noreturn, | 2636 | noreturn, |
| 2471 | enum_literal, | 2637 | enum_literal, |
| 2638 | manyptr_u8, | ||
| 2639 | manyptr_const_u8, | ||
| 2640 | atomic_ordering, | ||
| 2641 | atomic_rmw_op, | ||
| 2642 | calling_convention, | ||
| 2643 | float_mode, | ||
| 2644 | reduce_op, | ||
| 2645 | call_options, | ||
| 2472 | @"null", | 2646 | @"null", |
| 2473 | @"undefined", | 2647 | @"undefined", |
| 2474 | fn_noreturn_no_args, | 2648 | fn_noreturn_no_args, |
| ... | @@ -2572,6 +2746,14 @@ pub const Type = extern union { | ... | @@ -2572,6 +2746,14 @@ pub const Type = extern union { |
| 2572 | .inferred_alloc_mut, | 2746 | .inferred_alloc_mut, |
| 2573 | .var_args_param, | 2747 | .var_args_param, |
| 2574 | .empty_struct_literal, | 2748 | .empty_struct_literal, |
| 2749 | .manyptr_u8, | ||
| 2750 | .manyptr_const_u8, | ||
| 2751 | .atomic_ordering, | ||
| 2752 | .atomic_rmw_op, | ||
| 2753 | .calling_convention, | ||
| 2754 | .float_mode, | ||
| 2755 | .reduce_op, | ||
| 2756 | .call_options, | ||
| 2575 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), | 2757 | => @compileError("Type Tag " ++ @tagName(t) ++ " has no payload"), |
| 2576 | 2758 | ||
| 2577 | .array_u8, | 2759 | .array_u8, |
src/value.zig+58| ... | @@ -64,6 +64,14 @@ pub const Value = extern union { | ... | @@ -64,6 +64,14 @@ pub const Value = extern union { |
| 64 | single_const_pointer_to_comptime_int_type, | 64 | single_const_pointer_to_comptime_int_type, |
| 65 | const_slice_u8_type, | 65 | const_slice_u8_type, |
| 66 | enum_literal_type, | 66 | enum_literal_type, |
| 67 | manyptr_u8_type, | ||
| 68 | manyptr_const_u8_type, | ||
| 69 | atomic_ordering_type, | ||
| 70 | atomic_rmw_op_type, | ||
| 71 | calling_convention_type, | ||
| 72 | float_mode_type, | ||
| 73 | reduce_op_type, | ||
| 74 | call_options_type, | ||
| 67 | 75 | ||
| 68 | undef, | 76 | undef, |
| 69 | zero, | 77 | zero, |
| ... | @@ -169,6 +177,14 @@ pub const Value = extern union { | ... | @@ -169,6 +177,14 @@ pub const Value = extern union { |
| 169 | .bool_true, | 177 | .bool_true, |
| 170 | .bool_false, | 178 | .bool_false, |
| 171 | .abi_align_default, | 179 | .abi_align_default, |
| 180 | .manyptr_u8_type, | ||
| 181 | .manyptr_const_u8_type, | ||
| 182 | .atomic_ordering_type, | ||
| 183 | .atomic_rmw_op_type, | ||
| 184 | .calling_convention_type, | ||
| 185 | .float_mode_type, | ||
| 186 | .reduce_op_type, | ||
| 187 | .call_options_type, | ||
| 172 | => @compileError("Value Tag " ++ @tagName(t) ++ " has no payload"), | 188 | => @compileError("Value Tag " ++ @tagName(t) ++ " has no payload"), |
| 173 | 189 | ||
| 174 | .int_big_positive, | 190 | .int_big_positive, |
| ... | @@ -327,6 +343,14 @@ pub const Value = extern union { | ... | @@ -327,6 +343,14 @@ pub const Value = extern union { |
| 327 | .bool_false, | 343 | .bool_false, |
| 328 | .empty_struct_value, | 344 | .empty_struct_value, |
| 329 | .abi_align_default, | 345 | .abi_align_default, |
| 346 | .manyptr_u8_type, | ||
| 347 | .manyptr_const_u8_type, | ||
| 348 | .atomic_ordering_type, | ||
| 349 | .atomic_rmw_op_type, | ||
| 350 | .calling_convention_type, | ||
| 351 | .float_mode_type, | ||
| 352 | .reduce_op_type, | ||
| 353 | .call_options_type, | ||
| 330 | => unreachable, | 354 | => unreachable, |
| 331 | 355 | ||
| 332 | .ty => { | 356 | .ty => { |
| ... | @@ -474,6 +498,14 @@ pub const Value = extern union { | ... | @@ -474,6 +498,14 @@ pub const Value = extern union { |
| 474 | .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), | 498 | .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), |
| 475 | .const_slice_u8_type => return out_stream.writeAll("[]const u8"), | 499 | .const_slice_u8_type => return out_stream.writeAll("[]const u8"), |
| 476 | .enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"), | 500 | .enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"), |
| 501 | .manyptr_u8_type => return out_stream.writeAll("[*]u8"), | ||
| 502 | .manyptr_const_u8_type => return out_stream.writeAll("[*]const u8"), | ||
| 503 | .atomic_ordering_type => return out_stream.writeAll("std.builtin.AtomicOrdering"), | ||
| 504 | .atomic_rmw_op_type => return out_stream.writeAll("std.builtin.AtomicRmwOp"), | ||
| 505 | .calling_convention_type => return out_stream.writeAll("std.builtin.CallingConvention"), | ||
| 506 | .float_mode_type => return out_stream.writeAll("std.builtin.FloatMode"), | ||
| 507 | .reduce_op_type => return out_stream.writeAll("std.builtin.ReduceOp"), | ||
| 508 | .call_options_type => return out_stream.writeAll("std.builtin.CallOptions"), | ||
| 477 | .abi_align_default => return out_stream.writeAll("(default ABI alignment)"), | 509 | .abi_align_default => return out_stream.writeAll("(default ABI alignment)"), |
| 478 | 510 | ||
| 479 | .empty_struct_value => return out_stream.writeAll("struct {}{}"), | 511 | .empty_struct_value => return out_stream.writeAll("struct {}{}"), |
| ... | @@ -595,6 +627,14 @@ pub const Value = extern union { | ... | @@ -595,6 +627,14 @@ pub const Value = extern union { |
| 595 | .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), | 627 | .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), |
| 596 | .const_slice_u8_type => Type.initTag(.const_slice_u8), | 628 | .const_slice_u8_type => Type.initTag(.const_slice_u8), |
| 597 | .enum_literal_type => Type.initTag(.enum_literal), | 629 | .enum_literal_type => Type.initTag(.enum_literal), |
| 630 | .manyptr_u8_type => Type.initTag(.manyptr_u8), | ||
| 631 | .manyptr_const_u8_type => Type.initTag(.manyptr_const_u8), | ||
| 632 | .atomic_ordering_type => Type.initTag(.atomic_ordering), | ||
| 633 | .atomic_rmw_op_type => Type.initTag(.atomic_rmw_op), | ||
| 634 | .calling_convention_type => Type.initTag(.calling_convention), | ||
| 635 | .float_mode_type => Type.initTag(.float_mode), | ||
| 636 | .reduce_op_type => Type.initTag(.reduce_op), | ||
| 637 | .call_options_type => Type.initTag(.call_options), | ||
| 598 | 638 | ||
| 599 | .int_type => { | 639 | .int_type => { |
| 600 | const payload = self.castTag(.int_type).?.data; | 640 | const payload = self.castTag(.int_type).?.data; |
| ... | @@ -1132,6 +1172,16 @@ pub const Value = extern union { | ... | @@ -1132,6 +1172,16 @@ pub const Value = extern union { |
| 1132 | std.hash.autoHash(&hasher, payload.hash()); | 1172 | std.hash.autoHash(&hasher, payload.hash()); |
| 1133 | }, | 1173 | }, |
| 1134 | .inferred_alloc => unreachable, | 1174 | .inferred_alloc => unreachable, |
| 1175 | |||
| 1176 | .manyptr_u8_type, | ||
| 1177 | .manyptr_const_u8_type, | ||
| 1178 | .atomic_ordering_type, | ||
| 1179 | .atomic_rmw_op_type, | ||
| 1180 | .calling_convention_type, | ||
| 1181 | .float_mode_type, | ||
| 1182 | .reduce_op_type, | ||
| 1183 | .call_options_type, | ||
| 1184 | => @panic("TODO this hash function looks pretty broken. audit it"), | ||
| 1135 | } | 1185 | } |
| 1136 | return hasher.final(); | 1186 | return hasher.final(); |
| 1137 | } | 1187 | } |
| ... | @@ -1278,6 +1328,14 @@ pub const Value = extern union { | ... | @@ -1278,6 +1328,14 @@ pub const Value = extern union { |
| 1278 | .single_const_pointer_to_comptime_int_type, | 1328 | .single_const_pointer_to_comptime_int_type, |
| 1279 | .const_slice_u8_type, | 1329 | .const_slice_u8_type, |
| 1280 | .enum_literal_type, | 1330 | .enum_literal_type, |
| 1331 | .manyptr_u8_type, | ||
| 1332 | .manyptr_const_u8_type, | ||
| 1333 | .atomic_ordering_type, | ||
| 1334 | .atomic_rmw_op_type, | ||
| 1335 | .calling_convention_type, | ||
| 1336 | .float_mode_type, | ||
| 1337 | .reduce_op_type, | ||
| 1338 | .call_options_type, | ||
| 1281 | => true, | 1339 | => true, |
| 1282 | 1340 | ||
| 1283 | .zero, | 1341 | .zero, |