code wiki / (root) / nx_ribosome.nx

nx_ribosome.nx

buildroot/runtime/nx_ribosome.nx

8168 B202 linesdepth 3pulls 3 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_ribosome.nx -- target-ISA decision metadata. Biological analogue: a ribosome translates messenger RNA into the specific protein its codons encode. Nishi ribosome is the NishiLang-side decision primitive that names WHICH of the existing nxc2 codegen backends should emit a call site's binary. The actual codegen lives in C (aarch64.c, armv7a.c, cortex_m.c, gcn.c, loongarch64.c, metal.c, mips64.c, ppc64le.c, ptx.c, riscv.c, riscv32.c, s390x.c, wasm.c, x86_64.c). This primitive's job is to say "this site -> emit AARCH64 NEON" or "this site -> ESP32 Xtensa" based on observed heat from nx_metabolism + the cell's tropism. THIS IS WHAT MAKES DOOM-ON-PREGNANCY-TEST PHYSICALLY POSSIBLE: the same .nx source compiles down to CORTEX_M Thumb on $5 silicon (T1) and to PTX on a 5090 (T5). One IR, fourteen targets, decided per call site by ribosome. Composes: nx_tier -- NX_TIER_MCU..NX_TIER_HPC informs target choice nx_metabolism -- hot sites get SIMD/GPU/SILICON targets nx_pathway -- cell-spec declares preferred ribosome target nx_tropism -- LOCAL_GPU tropism selects GPU-family targets V1 ships a sealed enum + a picker. The handoff to nxc2 is via the target tag on each call site; the nxc2 main loop already reads per-site target hints (see nxc2/main.c). What was missing in NishiLang was the decision primitive; here it is. Gap list (V1 honest perf verdict): - SILICON_HDL emit target is a stub (HDL backend queued) - no online learning -- picker is fully deterministic - no per-cell override (uses pathway-level declaration) - no cross-target ABI shim (caller must keep i64/i32 alignment constant; nx_tier's nx_int alias is the single tuning knob) genealogy_id: nishi_cardinal_2026-05-17_pathway_tropism + biology_protein_synthesis lineage_id: substrate_ribosome_v1 nx_safety_envelope: intended_use: "Per-call-site target ISA decision metadata

dependencies 3 imports · 10 importers

nx_syscalls.nx nx_tier.nx nx_metabolism.nx nx_ribosome.nx nx_cell_anatomy_compose_test.nx nx_codon.nx nx_codon_test.nx nx_ecosystem_compose_test.nx nx_organism_test.nx nx_pathway.nx nx_pathway_test.nx nx_ribosome_test.nx nx_sovereign_compose_test.nx nx_substrate_compose_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_metabolism.nx

imported by: nx_cell_anatomy_compose_test.nxnx_codon.nxnx_codon_test.nxnx_ecosystem_compose_test.nxnx_organism_test.nxnx_pathway.nxnx_pathway_test.nxnx_ribosome_test.nxnx_sovereign_compose_test.nxnx_substrate_compose_test.nx

structs

none

consts

51const NX_MAGIC_1024: i64 = 1024
52const NX_MAGIC_1536: i64 = 1536
53const NX_MAGIC_8192: i64 = 8192
54const NX_MAGIC_1126: i64 = 1126
55const NX_MAGIC_1228: i64 = 1228
62const NX_RBT_X86_64: nx_int = 0
63const NX_RBT_AARCH64: nx_int = 1
64const NX_RBT_ARMV7A: nx_int = 2
65const NX_RBT_CORTEX_M: nx_int = 3
66const NX_RBT_RISCV64: nx_int = 4
67const NX_RBT_RISCV32: nx_int = 5
68const NX_RBT_MIPS64: nx_int = 6
69const NX_RBT_PPC64LE: nx_int = 7
70const NX_RBT_LOONGARCH64: nx_int = 8
71const NX_RBT_S390X: nx_int = 9
72const NX_RBT_WASM: nx_int = 10
73const NX_RBT_PTX: nx_int = 11 // NVIDIA GPU
74const NX_RBT_GCN: nx_int = 12 // AMD GPU
75const NX_RBT_METAL: nx_int = 13 // Apple GPU
76const NX_RBT_SILICON_HDL: nx_int = 14 // Nishi sovereign silicon
77const NX_RBT_N_TARGETS: nx_int = 15
84const NX_RBF_CPU: nx_int = 0
85const NX_RBF_GPU: nx_int = 1
86const NX_RBF_MCU: nx_int = 2
87const NX_RBF_WASM: nx_int = 3
88const NX_RBF_SILICON: nx_int = 4
89const NX_RBF_N_FAMILIES: nx_int = 5

functions

93func nx_rbt_is_valid(t: nx_int) -> nx_int
105func nx_rbt_family(t: nx_int) -> nx_int
117func nx_rbt_is_cpu(t: nx_int) -> nx_int
called by 1: main calls 1: nx_rbt_family
124func nx_rbt_is_gpu(t: nx_int) -> nx_int
called by 2: mainmain calls 1: nx_rbt_family
136func nx_ribosome_default_for_tier(tier: nx_int) -> nx_int
163func nx_ribosome_pick(tier: nx_int,
185func nx_ribosome_cost_q10(t: nx_int) -> nx_int
called by 1: main