| ... | ... | @@ -471,10 +471,181 @@ fn gen(self: *Self) !void { |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 474 | | _ = self; |
| 475 | | _ = body; |
| 474 | const air_tags = self.air.instructions.items(.tag); |
| 475 | |
| 476 | for (body) |inst| { |
| 477 | const old_air_bookkeeping = self.air_bookkeeping; |
| 478 | try self.ensureProcessDeathCapacity(Liveness.bpi); |
| 479 | |
| 480 | switch (air_tags[inst]) { |
| 481 | .arg => @panic("TODO implement arg"), |
| 482 | .add => @panic("TODO implement add"), |
| 483 | .addwrap => @panic("TODO implement addwrap"), |
| 484 | .add_sat => @panic("TODO implement add_sat"), |
| 485 | .sub => @panic("TODO implement sub"), |
| 486 | .subwrap => @panic("TODO implement subwrap"), |
| 487 | .sub_sat => @panic("TODO implement sub_sat"), |
| 488 | .mul => @panic("TODO implement mul"), |
| 489 | .mulwrap => @panic("TODO implement mulwrap"), |
| 490 | .mul_sat => @panic("TODO implement mul_sat"), |
| 491 | .div_float => @panic("TODO implement div_float"), |
| 492 | .div_trunc => @panic("TODO implement div_trunc"), |
| 493 | .div_floor => @panic("TODO implement div_floor"), |
| 494 | .div_exact => @panic("TODO implement div_exact"), |
| 495 | .rem => @panic("TODO implement rem"), |
| 496 | .mod => @panic("TODO implement mod"), |
| 497 | .ptr_add => @panic("TODO implement ptr_add"), |
| 498 | .ptr_sub => @panic("TODO implement ptr_sub"), |
| 499 | .max => @panic("TODO implement max"), |
| 500 | .min => @panic("TODO implement min"), |
| 501 | .add_with_overflow => @panic("TODO implement add_with_overflow"), |
| 502 | .sub_with_overflow => @panic("TODO implement sub_with_overflow"), |
| 503 | .mul_with_overflow => @panic("TODO implement mul_with_overflow"), |
| 504 | .shl_with_overflow => @panic("TODO implement shl_with_overflow"), |
| 505 | .alloc => @panic("TODO implement alloc"), |
| 506 | .ret_ptr => @panic("TODO implement ret_ptr"), |
| 507 | .assembly => @panic("TODO implement assembly"), |
| 508 | .bit_and => @panic("TODO implement bit_and"), |
| 509 | .bit_or => @panic("TODO implement bit_or"), |
| 510 | .shr => @panic("TODO implement shr"), |
| 511 | .shr_exact => @panic("TODO implement shr_exact"), |
| 512 | .shl => @panic("TODO implement shl"), |
| 513 | .shl_exact => @panic("TODO implement shl_exact"), |
| 514 | .shl_sat => @panic("TODO implement shl_sat"), |
| 515 | .xor => @panic("TODO implement xor"), |
| 516 | .not => @panic("TODO implement not"), |
| 517 | .bitcast => @panic("TODO implement bitcast"), |
| 518 | .block => @panic("TODO implement block"), |
| 519 | .loop => @panic("TODO implement loop"), |
| 520 | .br => @panic("TODO implement br"), |
| 521 | .breakpoint => @panic("TODO implement breakpoint"), |
| 522 | .ret_addr => @panic("TODO implement ret_addr"), |
| 523 | .frame_addr => @panic("TODO implement frame_addr"), |
| 524 | .call => @panic("TODO implement call"), |
| 525 | .call_always_tail => @panic("TODO implement call_always_tail"), |
| 526 | .call_never_tail => @panic("TODO implement call_never_tail"), |
| 527 | .call_never_inline => @panic("TODO implement call_never_inline"), |
| 528 | .clz => @panic("TODO implement clz"), |
| 529 | .ctz => @panic("TODO implement ctz"), |
| 530 | .popcount => @panic("TODO implement popcount"), |
| 531 | .byte_swap => @panic("TODO implement byte_swap"), |
| 532 | .bit_reverse => @panic("TODO implement bit_reverse"), |
| 533 | .sqrt => @panic("TODO implement sqrt"), |
| 534 | .sin => @panic("TODO implement sin"), |
| 535 | .cos => @panic("TODO implement cos"), |
| 536 | .exp => @panic("TODO implement exp"), |
| 537 | .exp2 => @panic("TODO implement exp2"), |
| 538 | .log => @panic("TODO implement log"), |
| 539 | .log2 => @panic("TODO implement log2"), |
| 540 | .log10 => @panic("TODO implement log10"), |
| 541 | .fabs => @panic("TODO implement fabs"), |
| 542 | .floor => @panic("TODO implement floor"), |
| 543 | .ceil => @panic("TODO implement ceil"), |
| 544 | .round => @panic("TODO implement round"), |
| 545 | .trunc_float => @panic("TODO implement trunc_float"), |
| 546 | .cmp_lt => @panic("TODO implement cmp_lt"), |
| 547 | .cmp_lte => @panic("TODO implement cmp_lte"), |
| 548 | .cmp_eq => @panic("TODO implement cmp_eq"), |
| 549 | .cmp_gte => @panic("TODO implement cmp_gte"), |
| 550 | .cmp_gt => @panic("TODO implement cmp_gt"), |
| 551 | .cmp_neq => @panic("TODO implement cmp_neq"), |
| 552 | .cmp_vector => @panic("TODO implement cmp_vector"), |
| 553 | .cond_br => @panic("TODO implement cond_br"), |
| 554 | .switch_br => @panic("TODO implement switch_br"), |
| 555 | .constant => @panic("TODO implement constant"), |
| 556 | .const_ty => @panic("TODO implement const_ty"), |
| 557 | .dbg_stmt => @panic("TODO implement dbg_stmt"), |
| 558 | .dbg_block_begin => @panic("TODO implement dbg_block_begin"), |
| 559 | .dbg_block_end => @panic("TODO implement dbg_block_end"), |
| 560 | .dbg_inline_begin => @panic("TODO implement dbg_inline_begin"), |
| 561 | .dbg_inline_end => @panic("TODO implement dbg_inline_end"), |
| 562 | .dbg_var_ptr => @panic("TODO implement dbg_var_ptr"), |
| 563 | .dbg_var_val => @panic("TODO implement dbg_var_val"), |
| 564 | .is_null => @panic("TODO implement is_null"), |
| 565 | .is_non_null => @panic("TODO implement is_non_null"), |
| 566 | .is_null_ptr => @panic("TODO implement is_null_ptr"), |
| 567 | .is_non_null_ptr => @panic("TODO implement is_non_null_ptr"), |
| 568 | .is_err => @panic("TODO implement is_err"), |
| 569 | .is_non_err => @panic("TODO implement is_non_err"), |
| 570 | .is_err_ptr => @panic("TODO implement is_err_ptr"), |
| 571 | .is_non_err_ptr => @panic("TODO implement is_non_err_ptr"), |
| 572 | .bool_and => @panic("TODO implement bool_and"), |
| 573 | .bool_or => @panic("TODO implement bool_or"), |
| 574 | .load => @panic("TODO implement load"), |
| 575 | .ptrtoint => @panic("TODO implement ptrtoint"), |
| 576 | .bool_to_int => @panic("TODO implement bool_to_int"), |
| 577 | .ret => @panic("TODO implement ret"), |
| 578 | .ret_load => @panic("TODO implement ret_load"), |
| 579 | .store => @panic("TODO implement store"), |
| 580 | .unreach => @panic("TODO implement unreach"), |
| 581 | .fptrunc => @panic("TODO implement fptrunc"), |
| 582 | .fpext => @panic("TODO implement fpext"), |
| 583 | .intcast => @panic("TODO implement intcast"), |
| 584 | .trunc => @panic("TODO implement trunc"), |
| 585 | .optional_payload => @panic("TODO implement optional_payload"), |
| 586 | .optional_payload_ptr => @panic("TODO implement optional_payload_ptr"), |
| 587 | .optional_payload_ptr_set => @panic("TODO implement optional_payload_ptr_set"), |
| 588 | .wrap_optional => @panic("TODO implement wrap_optional"), |
| 589 | .unwrap_errunion_payload => @panic("TODO implement unwrap_errunion_payload"), |
| 590 | .unwrap_errunion_err => @panic("TODO implement unwrap_errunion_err"), |
| 591 | .unwrap_errunion_payload_ptr => @panic("TODO implement unwrap_errunion_payload_ptr"), |
| 592 | .unwrap_errunion_err_ptr => @panic("TODO implement unwrap_errunion_err_ptr"), |
| 593 | .errunion_payload_ptr_set => @panic("TODO implement errunion_payload_ptr_set"), |
| 594 | .wrap_errunion_payload => @panic("TODO implement wrap_errunion_payload"), |
| 595 | .wrap_errunion_err => @panic("TODO implement wrap_errunion_err"), |
| 596 | .struct_field_ptr => @panic("TODO implement struct_field_ptr"), |
| 597 | .struct_field_ptr_index_0 => @panic("TODO implement struct_field_ptr_index_0"), |
| 598 | .struct_field_ptr_index_1 => @panic("TODO implement struct_field_ptr_index_1"), |
| 599 | .struct_field_ptr_index_2 => @panic("TODO implement struct_field_ptr_index_2"), |
| 600 | .struct_field_ptr_index_3 => @panic("TODO implement struct_field_ptr_index_3"), |
| 601 | .struct_field_val => @panic("TODO implement struct_field_val"), |
| 602 | .set_union_tag => @panic("TODO implement set_union_tag"), |
| 603 | .get_union_tag => @panic("TODO implement get_union_tag"), |
| 604 | .slice => @panic("TODO implement slice"), |
| 605 | .slice_len => @panic("TODO implement slice_len"), |
| 606 | .slice_ptr => @panic("TODO implement slice_ptr"), |
| 607 | .ptr_slice_len_ptr => @panic("TODO implement ptr_slice_len_ptr"), |
| 608 | .ptr_slice_ptr_ptr => @panic("TODO implement ptr_slice_ptr_ptr"), |
| 609 | .array_elem_val => @panic("TODO implement array_elem_val"), |
| 610 | .slice_elem_val => @panic("TODO implement slice_elem_val"), |
| 611 | .slice_elem_ptr => @panic("TODO implement slice_elem_ptr"), |
| 612 | .ptr_elem_val => @panic("TODO implement ptr_elem_val"), |
| 613 | .ptr_elem_ptr => @panic("TODO implement ptr_elem_ptr"), |
| 614 | .array_to_slice => @panic("TODO implement array_to_slice"), |
| 615 | .float_to_int => @panic("TODO implement float_to_int"), |
| 616 | .int_to_float => @panic("TODO implement int_to_float"), |
| 617 | .reduce => @panic("TODO implement reduce"), |
| 618 | .splat => @panic("TODO implement splat"), |
| 619 | .shuffle => @panic("TODO implement shuffle"), |
| 620 | .select => @panic("TODO implement select"), |
| 621 | .memset => @panic("TODO implement memset"), |
| 622 | .memcpy => @panic("TODO implement memcpy"), |
| 623 | .cmpxchg_weak => @panic("TODO implement cmpxchg_weak"), |
| 624 | .cmpxchg_strong => @panic("TODO implement cmpxchg_strong"), |
| 625 | .fence => @panic("TODO implement fence"), |
| 626 | .atomic_load => @panic("TODO implement atomic_load"), |
| 627 | .atomic_store_unordered => @panic("TODO implement atomic_store_unordered"), |
| 628 | .atomic_store_monotonic => @panic("TODO implement atomic_store_monotonic"), |
| 629 | .atomic_store_release => @panic("TODO implement atomic_store_release"), |
| 630 | .atomic_store_seq_cst => @panic("TODO implement atomic_store_seq_cst"), |
| 631 | .atomic_rmw => @panic("TODO implement atomic_rmw"), |
| 632 | .tag_name => @panic("TODO implement tag_name"), |
| 633 | .error_name => @panic("TODO implement error_name"), |
| 634 | .aggregate_init => @panic("TODO implement aggregate_init"), |
| 635 | .union_init => @panic("TODO implement union_init"), |
| 636 | .prefetch => @panic("TODO implement prefetch"), |
| 637 | .mul_add => @panic("TODO implement mul_add"), |
| 638 | .field_parent_ptr => @panic("TODO implement field_parent_ptr"), |
| 639 | |
| 640 | .wasm_memory_size, .wasm_memory_grow => unreachable, |
| 641 | } |
| 476 | 642 | |
| 477 | | @panic("TODO implement genBody"); |
| 643 | if (std.debug.runtime_safety) { |
| 644 | if (self.air_bookkeeping < old_air_bookkeeping + 1) { |
| 645 | std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[inst] }); |
| 646 | } |
| 647 | } |
| 648 | } |
| 478 | 649 | } |
| 479 | 650 | |
| 480 | 651 | fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
| ... | ... | @@ -487,6 +658,11 @@ fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
| 487 | 658 | return result_index; |
| 488 | 659 | } |
| 489 | 660 | |
| 661 | fn ensureProcessDeathCapacity(self: *Self, additional_count: usize) !void { |
| 662 | const table = &self.branch_stack.items[self.branch_stack.items.len - 1].inst_table; |
| 663 | try table.ensureUnusedCapacity(self.gpa, additional_count); |
| 664 | } |
| 665 | |
| 490 | 666 | fn fail(self: *Self, comptime format: []const u8, args: anytype) InnerError { |
| 491 | 667 | @setCold(true); |
| 492 | 668 | assert(self.err_msg == null); |