Commit Graph
85 Commits
Author SHA1 Message Date
waozi 12c78dda4b Remove every TinyCC path from generated C
TinyCC left with the native engine's ziran run tier; no build, test or
consumer compiles generated C with it. The SIMD generator drops its
TinyCC macro bodies and SSE2 assembly macros, ziran_simd.h, the bounds,
Vec and slice headers and the emitted checked-arithmetic helpers drop
their __TINYC__ branches, and #asm no longer writes TinyCC variants,
cpuid probes or volatile selection caches. Other compilers keep the
plain lane-array and portable-body fallbacks. The SIMD tests stop
compiling with -D__TINYC__ and check helper segments by their real
spelling.
2026-11-15 21:39:22 -03:00
waozi 8e812f5da1 Add the measured native column to the site target matrix 2026-11-15 14:39:20 -03:00
waoziandClaude Opus 5.5 931fed4c86 Run ZX natively by default and integrate the finished assembly lanes
One commit, because the parts below only build together.

Allocator: an interval needed at the current instruction is never
evicted, and the allocated-program verifier checks that every operand sits
where the allocation says.

AArch64 encoder: compiler_aarch64.zi encodes allocated machine IR with the
shared ARM byte helpers, maps the function-address relocation,
sign-extends signed 8- and 16-bit loads and rejects what it cannot encode
with a named diagnostic. It has no AOT ELF writer yet.

Native default with checked pointers and no fallback: on linux-x86_64,
`ziran run app.zx`, `zi2zx run`, the embedding API's Auto and the Kryon
players run a bundle's verified program as native code in W^X memory.
Stray and freed pointers, double free, bounds and read-only stores trap. A
native gap is a named preflight error, nothing falls back to the engine,
and `--backend engine` picks it explicitly. zx2native uses the same
preflight. Native code exchanges module state for hot reload, checks the
stack, zeroes fresh locals, spends fuel at the engine's checkpoints and
returns records, arrays and strings from host calls. `zi2zx --debug` source
origins name lines in native traps and `zx2native --emit map`. The host
value API drops its VM prefix (HostValue, HOST_*). A call with a record
result loads the hidden result address into rax only after its stack
arguments are stored, and an indirect target stays in r10: rax could hold
a stack argument (Kryon's text-field clip guard arrived as an address) or
the target (indirect calls returning records crashed).

Self-hosting ports: compiler_backend_process, compiler_backend_cache,
compiler_native_names and compiler_runtime_emit replace the zir_c_build,
zir_c_cache and zir_c_process C, with checked bootstrap C and Makefile
rules. zir_c.toolchain again reports "compiling OUT failed:" with the head
of the compiler output and a truncation marker. The parallel scheduler no
longer stalls on a held compiler after reaping a finished job, and poll or
read errors now fail the build. A fresh BUILD_DIR (Kryon's runtime build)
builds: generated files have pattern rules, objects wait for the headers
they include, and engine flags are per object instead of leaking into zi2c.

Legacy removals F1-F10 and N1-N4: the duplicate LirX64 encoder and its
spec test, zir_c_*, zir_runtime and zir_native, nine zero-reference spec
tests, vec_capacity, the zx_metadata and native_cache_names benchmarks,
build-android-host.sh and two shell wrappers are deleted; zx2native is
machine-only; `zi2zx` rejects `--opt` on ZX input; the bootstrap is
regenerated. ASSEMBLY docs, the legacy-removal plan, the milestones and the
remaining-work plan record the current position.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 14:04:48 -03:00
waozi c7b107d26f Keep every platform in the target matrix
The last three commits published a matrix with only the desktop
snapshot, so the site_targets check and the website deploy failed.
Restore the web and USB Android snapshots and the web artifacts they
ran, and render the library table in nanoseconds like the target table.

The previous matrix recorded outputs from an uncommitted compiler and
timed those, so it is rebuilt from the earlier snapshot whose outputs
and desktop timings match the committed artifacts. Rebuilding outputs
with site_targets.py now carries the platform snapshots forward; only
site_target_platforms.py replaces one.
2026-11-15 09:46:53 -03:00
waozi e41b61abee Speed up ZX platform writes and report timings in ns 2026-11-15 00:27:25 -03:00
waoziandClaude Opus 5.5 9ad5f481ef Name the tools by what they turn into what, and run verified ZX natively
The tools are renamed after their input and output: zi2zx lowers source
or ZIR to executable ZX, zx2native turns ZX into a native ELF, zx2wasm
into a wasm32 module, and zi2c, zi2go and zi2zir keep their roles under
cmd/ folders of the same names. zi2asm and the cmd/zir-* folders are
gone, and tests/tool_names.sh keeps the old names out. zx2native keeps
the direct encoder as its default; the machine pipeline replaces it once
it reaches parity.

The embedding API can run a verified bundle as x86-64 machine code in
memory. Code is written to RW pages, relocated, then switched to RX,
never RWX, and each instance gets its own data
(cmd/zir/zir_native_memory.c, zir_host_native.c). Backend selection is
BundleBackendPolicy: Engine and Native are strict, and Auto chooses by
platform only, never by whether one program fits. A native gap is a
named error, never a switch to the engine. Desktop x86-64 Auto stays on
the engine until the native backend is complete.

cmd/compiler_machine_image.zi adds the target-neutral machine image
contract. The machine verifiers reject unknown relocation kinds,
out-of-range symbols and addends, non-host external calls, native-width
mismatches and missing stack or fuel facts. The machine pipeline lowers
and encodes more of LIR. Docs, site pages, Kryon's build references and
the benchmarks use the new names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 22:07:42 -03:00
waozi efe3fabf71 Run the Wasm tier under Asyncify, fix float32 literals, docs for one format
- The bundle WebAssembly tier runs inside Emscripten runtimes built with
  Asyncify, such as Kryon's web player: a host that suspends inside a
  call (image decode, storage flush) suspends the tier's frames and
  resumes at that call; JSPI runtimes keep the engine. The suspending-host
  test agrees with the engine, including suspension inside a module
  initializer and in a loop.
- Revision-28 lowering compares an untyped float literal with a float32
  operand as float32, as C does (`x: float32 = 0.55; x != 0.55` was true).
- A prebuilt build tree compiles only zir_load.c again (Toolchains CI).
- Site target matrix collected on desktop, web and the moto e6 (mobile);
  Kryon widget library data regenerated.
- Docs describe the instruction engine and one ZX format instead of the
  removed portable VM, TinyCC and zi2wasm routes.
- Plans: native ZX players and phones, self-hosting, tool names by
  format; engine before/after samples from Omega.
2026-11-14 17:54:25 -03:00
waozi 16b60d090f Free host-returned storage, speed up the engine, finish the Wasm tier
Engine (cmd/compiler_exec.zi, compiler_opt.zi, compiler_lowered_verify.zi):
- Storage that host calls return is given back once nothing the program
  can reach names it; 100,100 calls returning 64-byte strings peak at
  65,752 live bytes instead of growing by 6.4 MB.
- An address only loaded from or stored to later in its own block takes a
  scratch table entry instead of a permanent one, so programs that read
  millions of bytes of a global or of host text no longer hit the address
  limit. The optimizer drops block parameters every edge passes one value
  (float-text: 32,168 -> 1,031), and frame and plan records are read in
  place. float-text runs 63.9 -> 45.0 s locally.

Host interface and embedding:
- Types that hold themselves through a slice and procedure values are
  written in the interface section; when it cannot be written the build
  fails with a diagnostic naming the type instead of writing a bundle
  without it. Every entry-module global is lowered and named, so state
  export includes globals the entry never reads.

Wasm tier (cmd/zir-wasm/zx_wasm_lower.c, zir_zx_wasm_web.c):
- Recursive host types work; the tier stays out of Emscripten runtimes
  built with Asyncify or JSPI, where hosts suspend (Kryon's image and
  storage hosts trapped with "unreachable"), and the engine runs those.
  Kernels use real loops without dispatch tables. Benchmarks on Alpha in
  bench/wasm_tier.*, raw samples under bench/results/.

Also: generated C indexes []*T slices with pointer elements; the site
target matrix is regenerated for desktop and web (mobile waits for the
phone's USB authorization); ASSEMBLY docs describe one ZX format; the
package artifact test restores CC instead of unsetting it, since the
artifact key names the compiler.
2026-11-14 15:51:28 -03:00
waozi 1a750826b7 Give the engine's names a private prefix on every target
The instruction engine in libziran carries its own copies of the standard
modules (Sin, Copy, Count, ...). On ELF a merged object with objcopy
--localize-hidden kept them private, but wasm objcopy cannot localize and
COFF keeps no hidden visibility, so Kryon's browser player failed to link
against libziran built with the engine. scripts/engine-names.sh now writes
a header that renames every name the engine's modules declare to
ziran_engine_*, force-included in the engine and in the embedding API;
names a header also offers inline are renamed only in their own module.
The merge step goes.
2026-11-14 14:23:26 -03:00
waozi cb0a762fd4 Migrate to one ZX format and delete the old route
zi2zx bundle and ziran run always write and run revision-28 executable
ZX. The semantic bundle reader and writer, the portable VM, the
TinyCC-compiled and linked native bundles with the vendored TinyCC,
bundle libraries, the VM profile, --vm, BundleInstantiatePortable,
libziran-vm.a and the ZIR-based Wasm lowering with zi2wasm are removed;
the Wasm tier, the embedding API and every tool run revision 28. Tests
of the removed VM internals and libraries are removed, and the rest run
on revision 28. Engine problems read as the diagnostics users rely on.
2026-11-14 14:03:01 -03:00
waozi bd85c5288f Show ZIR listings by meaning and call it just ZIR
ziran inspect printed every expression's text, so a statement's source
appeared once per node. Statements now carry their source once as a
trailing comment; literals show their value and calls their callee and
arguments, and expression text is printed only when no statement holds it.

ZIR is always written after type checking, so docs, the website and the
zi2asm pipeline help call it ZIR instead of checked ZIR or checked IR.
The site's inspection listings are regenerated in the new form.
2026-11-13 19:42:51 -03:00
waozi b390572374 Unify the native pipeline around verified ZX and shrink native hello
Source builds now check and lower to LIR, verify and optimize it, encode
portable ZX, and read that same verified image for the interpreter or for
native ELF generation. Standalone .lirb, --emit exec and --input exec are
removed. Linux x86-64 hello lowers to a static ELF with target-owned
write_all/exit_group veneers and no libc, CRT or dynamic linker.

Add machine IR register allocation, allocated-code verification, the
x86-64 encoder and ELF writer, LIR optimizer folds and type/origin
pruning, and the matching ASSEMBLY, docs and site updates.

Native tests now remove their temporary build/tests folders after failing
runs too, and the private Chromium profile under build/t is removed on close.
2026-11-13 18:13:30 -03:00
waozi 10e854af6b Add native std facades, fix ASCII lowercase and move site examples
Portable standard facades for byte text, environment, timers, randomness,
mapped files, streams, worker pools, directory trees and threads; full ASCII
lowercase in std/unicode; examples move to examples/ with generated site
pages; Go output handles mixed-width slice bounds.
2026-11-12 19:15:45 -03:00
waozi bb89cbe24b Add the revision-28 executable ZX container and machine IR boundary
The experimental direct backend now writes and reads an opt-in
revision-28 ZX container that holds verified lowered instructions.
Stripped files run through the portable engine without source or
semantic IR. Bounded validation covers framing, identities, symbols
and reachability, and versions 26/27 are rejected with a rebuild
diagnostic. Default ziran/zi2zx output is unchanged.

Address-taken local scalars lower to fresh checked frame storage in
the portable engine and native x86-64, including aliases across calls
and recursion and stale-token traps. A verified target-neutral machine
IR keeps Allocate as an explicit effectful operation ahead of register
allocation.

ASSEMBLY/milestones.md reviews the ten-step plan and reorders delivery
around a Linux x86-64 vertical slice. It starts with an Alpha
physical-host baseline and adds staged interim comparisons. Plan
statuses now match the implementation.
2026-11-12 19:11:59 -03:00
waozi 4838ce9b2f Improve runtimes, add an experimental direct backend, and prune Ziran tests
Prepare short portable helpers and scalar record reads, improve JSON SIMD scanning, expose one-line execution, and publish qualified Alpha benchmark artifacts. Add the experimental verified lowered execution, serialization and Linux x86-64 backend with source maps.

Physically remove 263 redundant test entry points and unused helpers, migrate retained helpers to Ziran, and execute the full retained suite without sharding. Allow ignored backup state for the managed physical Alpha workflow.

Local validation: all 268 retained tests passed across the full run and corrected targeted reruns; bootstrap matches. Current assembly verifier, x86-64, executor and serializer tests passed. Website examples and all 4661 local links passed. Six Alpha JSON/text workloads retain verified artifacts, raw samples and explicit unsupported Wasm diagnostics. The mobile sub-500 ns target remains pending.
2026-11-11 18:46:34 -03:00
waozi 126266c4a6 Release 0.4.1 with faster portable execution and verified benchmarks 2026-11-11 02:25:51 -03:00
waozi 4dc2da6b09 Publish measured desktop, Android and web target matrix
Compare five real examples across four targets on three measured platforms, preserving raw samples, independent output verification and artifact provenance.

Complete the WebAssembly support needed by the examples, inspect ZX bundles, prune generated C dependencies while preserving C++ linkage, and validate native script execution. Optimize only the temporary bootstrap seed and retain fresh-build measurements and historical benchmark records under bench/results.

Local tests: all 522 cases passed across the full run and corrected header-test rerun; all 16 bootstrap modules match. Playground runtime, bundle runtime, private browser layouts and matrix controls, published artifacts and local site links passed.
2026-11-10 23:50:12 -03:00
waozi 61b1e5402a Adopt capybara branding and require CI website deployments 2026-11-10 22:00:44 -03:00
waozi 3fd3fd5255 Show four Ziran targets in an inspectable benchmark matrix 2026-11-10 19:50:00 -03:00
waozi 0e73fed52a Fix local dependency package identity 2026-11-10 14:27:04 -03:00
waozi 97d08f3213 Define the IR records once in Ziran
cmd/compiler_ir.zi holds the records zir.h declared by hand: modules,
functions, statements, expressions, types, laws and proofs, their kinds
and the buffer sizes, spelled for C with #c. zir.h includes the generated
compiler_ir.h, built like the other compiler modules from a checked seed
in bootstrap/compiler_ir. Every field keeps its size and offset, and saved
IR, C and Go output are unchanged. C compiled outside the Makefile adds
-Ibootstrap/compiler_ir.
2026-11-07 14:53:56 -03:00
waozi d16e8da489 Read site API doc comments from the file that declares each item 2026-11-07 11:30:22 -03:00
waozi 677ee203ab Add native-width SIMD vectors (s16xN and friends)
u8xN .. f64xN hold two 128-bit blocks in a #target procedure's AVX2 clone
and in AVX2 builds, and one in base C, other clones, Go, TinyCC and the
VM. Simd.Lanes(T) and Simd.Blocks(T) give the count: a constant for fixed
vectors, the tier's width for native ones. Per-block operations work on
each block; WidenLow/High, MulWideLow/High and Narrow number lanes across
the vector; Make and Splat repeat one block.

Native vectors stay plain values: the checker rejects them in globals,
fields, arrays, pointers, slices, size_of, #foreign signatures and across
#target boundaries. tests/simd_native.sh checks that every compiler,
width, forced tier, Go, bundle and VM run gives the same hash, and that
Blocks reports the width each build picks.
2026-11-07 09:17:19 -03:00
waozi 9524616df1 Give each program only the SIMD helpers it calls
TinyCC read the whole 2.25 MB ziran_simd_ops.h for every module of a
SIMD program, so an uncached `ziran run` of the AV1 decoder spent about a
third of its TinyCC time on the header.

- scripts/simd_header.py marks each helper's lines in the header with a
  /*@name*/ comment line; /*@*/ marks lines every build keeps.
- zi2c notes the helpers each generated file names and, once the program
  is lowered, writes its ziran_simd_ops.h with those helpers and the ones
  they call, in full-header order and without the marks (EmitSimdOps).
- Under TinyCC zi_ref is static inline, so it is compiled only where an
  ARMv7 NEON helper calls it.

GCC and Clang build byte-identical objects from the copy and the full
header: the simd.sh program at -O0, -O2, SSE4.1, AVX2, scalar and TinyCC
flags, and all 52 AV1 decoder modules at -O0, -O2 and AVX2.

TinyCC on the AV1 decoder's modules: 702 -> 470 ms on the Moto (ARMv7,
same generated C), 38.5 -> 28 ms on x86-64.
2026-11-07 08:25:58 -03:00
waozi 684b89bbc8 Lower ZX bundles without repeated scans or per-access emulated TLS
Uncached `ziran run` of a ZX bundle spent its time rescanning text and
reading thread-local state through emutls on 32-bit Android.

- Embedded runtime and native headers carry a bitmask of the headers they
  include, so header closure needs no strstr over 2 MB texts.
- Native helper discovery walks each text's words once, marking includes
  and helper calls in the same pass.
- ScalarType dispatches on length; builder_text_module formats its scoped
  name only after the cheap rejections.
- The IR writer remembers written string addresses; the reader keeps each
  string-table entry once and records its context once per read.
- Each thread's compiler state is one record (zir_thread.h): memory scope,
  selected context, storage hints and the KeepText cache. Field walks,
  symbol lookups and KeepText find it once and pass it down.

Bundles, native C and Breeze's generated C are byte-identical.
2026-11-07 07:35:58 -03:00
waozi cef1a98d95 std/resample: NEON and SIMD128 kernels in std/simd
The ARMv7, AArch64 and WebAssembly row kernels move from #asm to std/simd,
making the same bytes. Each tap's bytes widen to 32 bits and take its whole
weight; the horizontal kernel takes four taps a step and walks pointers with
32-bit counts, which ARMv7 and wasm32 keep in one register.

On a Cortex-A53 (ARMv7) resizes run 3 to 10% faster than the assembly, and
under wasmtime about twice as fast.

ziran_simd.h: Clang's ARMv7 backend copied an unaligned 8-byte load that it
merged into a widening through the stack; Simd.LoadLow now keeps it one
vld1.

tests/lanczos_isa_bitexact.sh runs the WebAssembly modules standalone with
WASI_RUN (such as wasmtime run), without JavaScript.
2026-11-07 07:20:21 -03:00
waozi 410fa10ce7 Run std/simd inline under TinyCC everywhere and copy ARM records in place
Under TinyCC every std/simd helper is now a statement-expression macro
on any target, not only x86-64, where the common integer ones stay SSE2
assembly. Loads, stores and gathers copy through structures of bytes,
which TinyCC copies at any address, instead of calling memcpy.

TinyCC's 32-bit ARM code generator copies a structure of up to 32 bytes
through lr a word at a time on ARMv6 and later, rather than calling
__aeabi_memmove, and the ZX engine's TinyCC targets the CPU's own
architecture version, so ARMv7 builds constants with movw and movt
instead of loading them from beside the code.

A 352p AV1 decode under `ziran run` on a Cortex-A53 phone (armeabi-v7a),
best of five on one core: 1.81 s cached, from 3.57 s; 7.27 s uncached,
from 9.42 s. The decoded planes hash the same, and every helper agrees
with zi_ref under TinyCC on the phone and, with the assembly left out,
on x86-64. x86-64 builds keep the same macros.
2026-11-07 06:15:56 -03:00
waozi 4244f07689 Compute std/simd in typed Go instead of through the reference
zi2go wrote every std/simd value helper as a wrapper that copied its
operands into 64-bit lane arrays and ran one port of zi_ref, so each
operation dispatched on its op and lane kind at run time. The helpers
now have typed bodies, generated by scripts/simd_header.py --go into
cmd/zir/zir_simd_go_bodies.h: straight-line code over each lane, or a
loop past eight lanes of one per-lane expression, which Go inlines. The
lane functions they call (saturation, masks, float to integer) and the
math, strconv and unsafe imports come only where a helper uses them;
the reference port is written only for a helper without a typed body,
which no helper the checker accepts lacks.

tests/simd_go.sh writes every helper the checker accepts beside its
reference form (GoSimdWriteCheck), checks the file is gofmt-clean, runs
each pair on the same edge-heavy operands, and checks the three
generated headers match scripts/simd_header.py. All 1060 agree.

AV1 352p decode built as Go, best of 3 on one core: 346 -> 44 ms, with
the same decoded planes.
2026-11-07 05:36:41 -03:00
waozi 31e97f3585 Run std/simd multiplies, narrowing and gathers inline under TinyCC
Under TinyCC on x86-64 the 32-bit multiplies, rounding shifts, half
widening and the signed narrowings are SSE2 assembly macros, and a gather
reads its lanes straight from the table, two to a 64-bit word, instead
of four memcpy calls. Each result is stored as one 128-bit block: the
next operation's 64-bit half loads still forward from it. TinyCC's
assembler learns pmuludq and pshufd.

Where nothing inlines (TinyCC, unoptimized GCC and Clang), zi_simd_at,
zi_simd_gather_check and SliceRange check in place and call only to
report. A whole slice a[:] is the view itself in C, and a vector load,
store or gather of a whole named array addresses the array directly.
TinyCC zeroes small braced locals with stores instead of memset.

AV1's s32x4 self-guided restoration (tree-s3) against its scalar form
(tree-s2), `ziran run`, best of 3 on one core:
  d352  cached 95 -> 76 ms (scalar 79 -> 71), uncached 356 -> 336 ms (scalar 328 -> 325)
  d1080 cached 488 -> 408 ms (scalar 484 -> 408), uncached 793 -> 703 ms (scalar 802 -> 703)
The bootstrap C is regenerated.
2026-11-07 04:51:58 -03:00
waozi c3f786fe6e Run std/simd operations inline under TinyCC on x86-64
TinyCC inlines nothing, so every std/simd helper under `ziran run` cost a
call with its vectors copied in and out, and a typed kernel ran slower
than the scalar loop it replaced. Under TinyCC on x86-64 every one of
the 1064 helpers is now a statement-expression macro that evaluates each
argument once. The common integer operations are one SSE2 asm statement
that reads each vector argument in place through a memory operand and
writes the result into the local the expression yields; the rest run
their lane-array C on argument locals. Shifts compute their lanes
without branches and Make builds its lanes in one initializer, so they
convert too.

Macro temporaries, here and in the 256-bit split and pack macros, are
spelled __zi_*, which C reserves for the implementation. The C emitter
now renames locals, parameters and globals spelled with two leading
underscores as it renames keywords, so no argument can name a temporary;
fields keep their C spelling. tests/simd.sh checks a program whose own
values are named like the temporaries.

AV1 batch 10, best of 3 on one core: a cached 1080p decode takes 503 ms,
from 697 ms (the assembly build takes 547 ms), and 352p 75 ms, from 90.
Uncached, 352p takes 324 ms, from 387, and 1080p 784 ms.
2026-11-07 03:40:29 -03:00
waozi 5f6f77f385 Include only the SIMD vector types where C just names them
TinyCC spent about 8 ms of every translation unit parsing ziran_simd.h,
600 KB once preprocessed, even in modules that only pass vectors
around. The ZI_VEC detection and the vector typedefs now live in a
generated ziran_simd_types.h. Module headers and C that only names
vector types include it, and C that calls an operation still includes
ziran_simd.h, which includes the types header too. On the AV1 352p
bundle, an uncached ziran run compiles in 38 ms instead of 80 ms, and
the generated code is otherwise unchanged.
2026-11-07 01:44:10 -03:00
waozi 2ebd27804f Build the TinyCC SSE2 helpers' asm operands in one place 2026-11-07 01:00:13 -03:00
waozi 153dd49267 Cast parameters a procedure body never reads to void
Generated C now starts every body, out of line, a #target clone or a
header's inline copy, with (void)name; for each parameter it never reads,
so a C file including another module's header passes -Wall -Wextra
-Werror. USAGE.md documents the ZIRAN_<MODULE>_H_SOURCE opt-out for C
mocks, and tests/c_warnings.sh covers both. The commit also takes the
working tree's other in-progress changes (C cache, SIMD ops, check runner
and tests), which passed make check alongside it.
2026-11-06 22:51:43 -03:00
waozi 43345a103f Run 256-bit SIMD as 128-bit halves below AVX2 and add Sign and AbsDiff
std/simd helpers below AVX2 take 256-bit vectors by pointer and run them
as two 128-bit halves, so no helper passes a 32-byte vector by value
(no -Wpsabi note) and GCC no longer scalarizes generic 256-bit operations.
Halves come from a 16-byte aligned union: memcpy went through the stack,
and an under-aligned union made GCC 14 fold misaligned memory operands
into SSE instructions (an internal compiler error).

Faster lowerings: NEON single-instruction reductions, x86 lane-swap
reduction trees and SSE4.1 phminposuw, pmuludq/pmuldq MulWide,
saturating Narrow from unsigned and 32-bit sources, AddPairs, MulAddPairsSat,
SSE2 Abs, u16 Min and Max, AVX2 16-bit ShiftLanes, and WebAssembly
MulHighRound.

Sign(a, b) and AbsDiff(a, b) have C (SSSE3 psign, NEON vabd, SIMD128),
Go, VM and scalar versions.

zi_ref fixes found on ARMv7: f32 arithmetic uses the exact scalar path
because NEON flushes subnormals, and the byte-shift loop is flat because
NDK Clang 19 miscompiled the nested one. zi_ref is marked unused for
programs that never take a scalar path.
2026-11-06 20:12:39 -03:00
waozi ae2bde9480 Compile SIMD loads, stores and widening to single instructions
std/simd's C helpers now load and store whole vectors with unaligned
vector moves (SSE2, AVX2, NEON and SIMD128) instead of letting GCC copy
the 4-byte-aligned vector types as two 64-bit halves. Widening a half,
taking or joining 256-bit halves and the 64-bit low loads also use one
instruction on each target where one exists. Lane results are
unchanged; scripts/simd_header.py --test checks them against the
scalar definitions.
2026-11-06 16:39:38 -03:00
waozi a0153ce471 Emit std/simd operations in C with GCC/Clang vectors and intrinsics
ziran_simd_ops.h, generated by scripts/simd_header.py, defines every
vector type and operation for SSE2, SSSE3, SSE4.1, AVX2 and NEON, with
portable vector-extension and plain-struct fallbacks that agree lane for
lane with the reference semantics. Slice and array loads, stores and
gathers check their bounds; pointer access stays unchecked.
tests/simd.sh compares lane results across the vector, scalar, TinyCC,
SSE4.1 and AVX2 builds, from source and saved IR, and under ASan.
2026-11-06 12:58:19 -03:00
waozi 854d4ae202 Generate the module index, per-module API pages and guide for the website
scripts/site_pages.py now writes modules.html (every std module and public
ziranlang package with summary and release-derived status), one API page per
std module and package, the guide rendered from docs/USAGE.md,
docs/COMPILER_API.md and the documents they link, and sitemap.xml. It asks
ziran api for one module at full limits and fails on truncation, so
net_ws_curl_linux, png_linux and web are complete again. scripts/site_links.py
checks every local link and fragment offline. /std redirects to /modules.
2026-11-05 16:32:54 -03:00
waozi 1c897d763f Add checked edits, Unicode normalization and owned JSON, file and process APIs
ziran edit previews and applies checked source edits, and ziran compact and
expand give .zi files a lossless compact transport. Diagnostics bound each
message and report truncation. The standard library adds Unicode 17 NFC,
lowercase and properties, owned JSON documents with Into accessors and
erasers, file identity snapshots, 32-argument process channels with optional
stderr discard, socket write shutdown, longer Curl header values and fallible
image resampling. Checks cover the new APIs, and stale tests now match the
bounded diagnostics, the 4 ms kernel timestamp tick and the check runner.
2026-11-05 11:47:14 -03:00
waozi abb165ca84 Add Unicode printability and replacement decoding 2026-11-04 04:34:09 -03:00
waozi 4d3c91df7a Add portable Unicode case and character APIs 2026-11-04 02:03:44 -03:00
waozi dd1c95df7f Remove the Python target 2026-10-31 02:46:00 -03:00
waozi c70b8a8100 Build the playground with a native Ziran script 2026-10-31 02:32:44 -03:00
waozi ee86330414 Share verified artifact consumption with Python build tools 2026-10-30 22:57:24 -03:00
waozi 5d3e5ca4ca Install CI packages from the canonical Ubuntu archive
Hosted runners read Ubuntu packages from an Azure mirror list that
sometimes stalled package setup for many minutes, up to 44 in Kryon.
ci_packages.sh now reads only the canonical archive (ports for arm64)
with time limits, also on Ubuntu 22.04, and can install recommended
packages. The setup action installs packages with its own copy, so
every project gets the fix whichever Ziran it locks.
2026-10-27 18:35:02 -03:00
waozi 2e2fea84d9 Run bundles linked into browser hosts as compiled code
The browser ran every bundle on the portable VM: Shovey walking in a level
reached 33 fps at 6x CPU throttle, against 55 for a separately compiled web
edition. A page cannot compile at run time, so its bundles are now compiled
when the page is built, with the same C lowering the native engine uses.

zi2zx native-c [--embedded] -o DIR file.zx writes each bundle's checked
program as C, with zx_native.json naming its sources and compile flags and
a constructor that registers it under the bundle's identity; --embedded
adds the bundles packed in it that open without libraries.
scripts/linked-zx.py compiles them, prefixing each program's external
symbols so programs and the host's own compiled modules cannot collide.
WebAssembly libziran (LINKED_ZX) opens a bundle whose identity has linked
code without checking it again and runs it as that code; any other bundle
runs on the VM. A program's globals sit in their own data section, copied
back before each instance starts, so one instance at a time runs the
linked code and one opened beside it runs on the VM.

The engine is split into its run time and services (zir_zx_native_run.c),
lowering (zir_zx_native_lower.c) and TinyCC compilation (zir_zx_native.c).
Lowered module globals carry ZIR_GLOBAL and engine builds no longer emit
startup constructors, since the engine runs module initializers itself.
tests/zx_linked_web.sh checks linked code end to end with emcc and node.
2026-10-27 16:05:01 -03:00
waozi da76a21675 Remove the C++, Rust and Plan 9 targets
Ziran now generates C, Go, Python and portable .zx. zi2cpp, zi2rust, the
C++ mode of the shared C emitter, the Plan 9 post-pass and the std Plan 9
modules are gone; --target=cpp|rust|plan9-c and zi2c --plan9 are rejected
as unknown targets. Generated C headers keep avoiding C++ keywords in
exported names, so C++ hosts can still include them.
2026-10-24 00:57:29 -03:00
waozi 3cc5e35234 Rename portable executables and toolchain from ZIB to ZX 2026-10-23 18:55:04 -03:00
waozi 4eba2ac73e Pass Unicode conformance offset arrays through a shared generic check 2026-10-23 16:19:37 -03:00
waozi 8604e7062b Deduplicate Unicode property pages without changing grapheme results 2026-10-23 14:53:43 -03:00
waozi d3e7c90073 Scope compiler lifetimes and separate lowering phases 2026-10-18 11:52:51 -03:00