Commit 1218aec
committed
v3: fix ARM64 self-host (test_all.vsh step 4)
Make `v3 -selfhost -b arm64` produce a working arm64 compiler that can
in turn compile programs with the native ARM64 backend. Fixes a series
of ARM64-only SSA codegen bugs (plus one shared transformer fix) that
caused the self-hosted binary to crash:
- ssa: register `array_push_many_ptr` as its own synthetic (the C-macro
name the transformer emits for `arr << ptr` / fixed-array appends).
- ssa: synthesize `<Enum>__autostr` enum-to-string helpers (the C
backend emits these; the SSA path had none). Flag enums get a
flag-specific body that renders `Name{.a | .b}` (and `Name{}` for 0)
via per-bit testing, matching the C backend. Enum field initializer
expressions (`a = 1 << 3`, `a = -1`, ...) are evaluated via a port of
cgen's `enum_field_expr_value`, shared by the autostr helpers and the
`enum_values` table so both agree on the field's real value.
- ssa: resolve a bare enum literal (`x = .member`, `return .member`)
against the assignment/return target type, so a member name that is
duplicated across enums is no longer built as 0.
- ssa: fix the lvalue address of `(&Struct(rawptr)).field` (a pointer
cast base was returning a null address).
- ssa: re-classify `Type.method(args)` selector calls from the resolved
signature's parameter count, so a cross-module static type-method
(e.g. `token.Token.from_string_tinyv`) is not passed a phantom
receiver that shifts its arguments.
- ssa/arm64: give the `string` struct an `is_lit` field (offset 12, also
taught to `block_struct_field_ptr`). `materialize_string` sets it to 1
for literals; `emit_make_string` now takes an explicit is_lit (1 for
the `vstring_literal*` wrappers that borrow static C data, 0 for owned
heap strings), so string.free aborts on neither static data nor a
non-allocation-start pointer. Helpers that would otherwise return a
view/interior pointer instead return an owned copy via
`emit_make_owned_string` (matching V's substr/clone): `tos_clone`,
strings.Builder `str`/`last_n`, `all_before_last`/`all_after_last`,
the `trim_right` and string-slice fallbacks, and `int_str`/`format_int`
(which shifts its backwards-written digits to the buffer start).
- ssa: register a header-less synthetic `array__clone` and materialize
slice rvalues (`a[lo..hi]`, tagged `value == "range"`) when their
address is taken; transform: treat such range-index nodes as
non-addressable so they materialize to a temp.
- ssa: also stub the `v3.bench.*` rss helpers, matching the full
import-path qualification that fn names now carry.
The C-backend self-host chain still converges byte-for-byte and the v3
unit tests show no new failures.1 parent 82e947b commit 1218aec
3 files changed
Lines changed: 517 additions & 59 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1411 | 1411 | | |
1412 | 1412 | | |
1413 | 1413 | | |
1414 | | - | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1415 | 1421 | | |
1416 | 1422 | | |
1417 | 1423 | | |
| |||
0 commit comments