nx_ribosome.nx
buildroot/runtime/nx_ribosome.nx
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
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
| 51 | const NX_MAGIC_1024: i64 = 1024 |
| 52 | const NX_MAGIC_1536: i64 = 1536 |
| 53 | const NX_MAGIC_8192: i64 = 8192 |
| 54 | const NX_MAGIC_1126: i64 = 1126 |
| 55 | const NX_MAGIC_1228: i64 = 1228 |
| 62 | const NX_RBT_X86_64: nx_int = 0 |
| 63 | const NX_RBT_AARCH64: nx_int = 1 |
| 64 | const NX_RBT_ARMV7A: nx_int = 2 |
| 65 | const NX_RBT_CORTEX_M: nx_int = 3 |
| 66 | const NX_RBT_RISCV64: nx_int = 4 |
| 67 | const NX_RBT_RISCV32: nx_int = 5 |
| 68 | const NX_RBT_MIPS64: nx_int = 6 |
| 69 | const NX_RBT_PPC64LE: nx_int = 7 |
| 70 | const NX_RBT_LOONGARCH64: nx_int = 8 |
| 71 | const NX_RBT_S390X: nx_int = 9 |
| 72 | const NX_RBT_WASM: nx_int = 10 |
| 73 | const NX_RBT_PTX: nx_int = 11 // NVIDIA GPU |
| 74 | const NX_RBT_GCN: nx_int = 12 // AMD GPU |
| 75 | const NX_RBT_METAL: nx_int = 13 // Apple GPU |
| 76 | const NX_RBT_SILICON_HDL: nx_int = 14 // Nishi sovereign silicon |
| 77 | const NX_RBT_N_TARGETS: nx_int = 15 |
| 84 | const NX_RBF_CPU: nx_int = 0 |
| 85 | const NX_RBF_GPU: nx_int = 1 |
| 86 | const NX_RBF_MCU: nx_int = 2 |
| 87 | const NX_RBF_WASM: nx_int = 3 |
| 88 | const NX_RBF_SILICON: nx_int = 4 |
| 89 | const NX_RBF_N_FAMILIES: nx_int = 5 |
functions
| 93 | func nx_rbt_is_valid(t: nx_int) -> nx_int |
| 105 | func nx_rbt_family(t: nx_int) -> nx_int |
| 117 | func nx_rbt_is_cpu(t: nx_int) -> nx_int |
| 124 | func nx_rbt_is_gpu(t: nx_int) -> nx_int |
| 136 | func nx_ribosome_default_for_tier(tier: nx_int) -> nx_int |
| 163 | func nx_ribosome_pick(tier: nx_int, |
| 185 | func nx_ribosome_cost_q10(t: nx_int) -> nx_int called by 1: main |