Commit Graph

7965 Commits

Author SHA1 Message Date
Flāvius
2e8d3b9e10 rexcode/isa: display-side label naming — address order, offset-keyed names
Internal label ids are allocation-order handles: the encoder's creation
order, or the decoder's branch-DISCOVERY order (a loop's latch names the
header before an earlier forward target). Printing labels by raw id leaked
that accident into listings — label numbers appeared out of order down the
page — and the printers' `label_names: ^map[u32]string` keyed the caller's
names by those synthesized ids, which a decode consumer cannot know without
re-deriving them (the practical result: naming "label 0" could caption a
random interior branch target).

Naming is now derived at the presentation seam, shared by every ISA
(`isa.Label_Display` in isa/print.odin):

  - display numbers are assigned in ASCENDING ADDRESS order, so a listing
    reads L0, L1, L2 … top to bottom regardless of id allocation;
  - caller names are keyed by BYTE OFFSET (`isa.Label_Names`, with a
    `distinct` Label_Offset key so an id-keyed map from the old contract
    fails to compile instead of silently mis-naming);
  - a named offset is guaranteed a label row even when no Label_Definition
    points at it — `names[0] = "factorial"` heads a function's listing.

All ten ISA printers (x86, mips, rsp, arm32, arm64, riscv, ppc, ppc_vle,
mos6502, mos65816) drop their per-printer offset_to_label maps and
write_label helpers for the shared display; each arch re-exports
Label_Offset/Label_Names beside Label_Definition. En route this fixes an
arm32/ppc/ppc_vle bug where passing ANY names map suppressed the default
L<n> label rows for unnamed labels. Decode-side id assignment is untouched:
the reloc round-trip contract (encoder ids surviving decode) and the
sparse-id padding it relies on stay exactly as they were.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Riok9vMpkLmo78wsVKJHhz
2026-08-03 20:52:11 -04:00
Flāvius
da15373ee9 rexcode/mips: add the R6 signed mul/div encodings (MUL_R6/DIV_R6/DIVU_R6)
The table had the R6 unsigned mul, both muh, and mod/modu, but not the R6
SIGNED low multiply (SPECIAL funct 0x18, sa=2 → 0x98) or the R6 signed/unsigned
divide (funct 0x1A, sa=2/3 → 0x9A/0x9B). Add MUL_R6, DIV_R6, DIVU_R6 to the
Mnemonic enum + the encoding table (all SPECIAL, RD/RS/RT, mask 0xFC0007FF,
MIPS32_R6) and regenerate the tables. Verified against llvm-mc -mcpu=mips32r6
(mul/div/divu $rd,$rs,$rt). All existing mips tests pass (166/39/65/14).
2026-08-03 20:52:11 -04:00
Flāvius
69c6135b55 rexcode/mips: feature-gate the decoder so shared opcodes resolve per ISA variant
The MIPS decode tables are universal — every variant (MIPS I..64/R6, the PS1
GTE, PS2 MMI/VU, PSP VFPU) shares one table. Some primary opcodes collide
across variants: most visibly 0x37 is `LD` on 64-bit MIPS but `vfim.s` on the
PSP Allegrex VFPU. The decoder took the first table match, so `LD $ra, 0($sp)`
(0xdfbf0000) mis-decoded as `vfim.s $31, 0`.

Each Decode_Entry already carries a `feature`; the decoder just ignored it.
`decode` now takes a `features: Feature_Set` (a bit_set over `Feature`),
defaulting to `FEATURES_ALL` so existing callers are unchanged, and skips an
entry whose feature isn't enabled — the first ENABLED match wins, preserving
the most-specific-mask-first order. Added `FEATURES_MIPS_III` (MIPS I/II/III +
COP0 + FPU — the VR4300 / classic 64-bit baseline) for N64/MIPS-III consumers.

decode_smoke: opcode 0x37 decodes as LD under FEATURES_MIPS_III and (still)
as the PSP VFPU entry under FEATURES_ALL. 65 decoder checks pass.
2026-08-03 20:52:11 -04:00
gingerBill
c2b4099c01 Fix typo 2026-07-31 00:44:15 +01:00
gingerBill
821a24eb3a Improve formatting in rexcode/isa/x86/encoder.odin 2026-07-31 00:39:41 +01:00
Flāvius
0f472409c4 rexcode/x86: label addressing for RIP-relative disp and movabs imm
Add mem_rip_label(label_id) so a RIP-relative memory operand can
reference a label: the encoder writes a placeholder disp32 and emits a
REL32 relocation (addend 0) at the field's byte offset, mirroring the
existing .RELATIVE jump/call path. This expresses lea reg, [rip + <label>]
(position-independent data addressing).

Add op_imm_label(label_id) for movabs reg, <label>: the imm stays kind
.IMMEDIATE (form matching unchanged) but is flagged so the encoder emits
an ABS64 relocation for the imm64 instead of a literal; imm_matches_inline
forces the full IMM64 form so a small id can't collapse to mov r64, imm32.

Both labeled forms bypass the contextless recipe fast-path (which cannot
append relocations) and fall back to the interpreter. Flags reuse spare
bits in Memory (disp_is_label) and Operand_Flags (imm_is_label) -- no
struct growth. Section 11 tests cover resolved/unresolved disp, the ABS64
movabs, and an end-to-end executed lea+load.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-30 15:05:16 -04:00
gingerBill
8b7d1be601 Keep -vet happy 2026-07-14 13:28:12 +01:00
gingerBill
ee21677ac7 Begin work on the module encoder 2026-07-14 11:29:49 +01:00
gingerBill
1def2e3c66 Improve docs a little 2026-07-13 16:36:45 +01:00
gingerBill
fc17efdd0c Add TODO in encode to make it actually write out the entire module and not just the functions 2026-07-13 16:28:57 +01:00
gingerBill
bfed392a0e Improve printing for call 2026-07-13 16:15:41 +01:00
gingerBill
0696f46bfb Add indentation for block, loop, if, else` constructs 2026-07-13 16:02:38 +01:00
gingerBill
ac5f5fe3ed Add print_wat.odin 2026-07-13 15:56:25 +01:00
gingerBill
8cd5838112 wasm: parse custom sections 2026-07-13 15:30:00 +01:00
gingerBill
23c5c4e668 Add module parsing 2026-07-13 15:24:45 +01:00
gingerBill
fcc6b65ed4 Remove old wasm and wasm/module code 2026-07-13 14:17:27 +01:00
gingerBill
2478af9b1f Minor alignment fix 2026-07-13 14:16:40 +01:00
gingerBill
27e5225730 Refactor core:rexcode/wasm to use the new ir structure and move to core:rexcode/ir/wasm 2026-07-13 14:16:27 +01:00
gingerBill
f7b797cc6f Fix formatting 2026-07-13 13:06:41 +01:00
gingerBill
2bbb04e4f6 Merge branch 'master' into bill/rexcode 2026-07-13 12:10:57 +01:00
Yawning Angel
e1d32cb19f core/cryto/rsa: Initial import 2026-07-12 06:17:08 +09:00
Yawning Angel
483221ef97 core/crypto/_bigint: Initial import 2026-07-12 06:17:08 +09:00
Yawning Angel
f259b416e3 core/crypto/_subtle: Cleanups, dedup from RSA code 2026-07-12 03:28:20 +09:00
Yawning Angel
98e22205af core/crypto/ed25519: Add missing require_results annotations 2026-07-12 03:28:20 +09:00
Jeroen van Rijn
5377cd9c49 Add rbtree.upsert 2026-07-10 21:37:47 +02:00
Isabella Basso
7e6856d486 core/rbtree: match find_or_insert semantics with AVL 2026-07-09 10:17:57 -03:00
gingerBill
46a2960d13 Merge pull request #6968 from ssenthilnathan3/fix/ternary-comment-parsing
Fix parser failing on comments inside ternary expressions
2026-07-08 10:56:05 +01:00
Jeroen van Rijn
1d226a30e4 Fix is_tty doc string 2026-07-07 23:28:26 +02:00
Senthilnathan
a880c1abfa Fix parser failing on comments inside if/when ternary 2026-07-07 14:30:59 +05:30
Senthilnathan
d7fc7c653c Fix parser failing on comments inside ternary expressions 2026-07-07 14:18:42 +05:30
Jeroen van Rijn
0d883bb3e0 Remove raylib v5.5 in favor of v6.0 2026-07-06 20:09:55 +02:00
Laytan Laats
e1dc17a3a3 typo 2026-07-06 19:05:43 +02:00
Laytan Laats
7028a3479f raylib: Add back ShowCursor 2026-07-06 19:02:38 +02:00
Laytan
e8ad21ed2a Merge pull request #6954 from mfbulut/master
Fix data corruption in endcoding/cbor
2026-07-06 14:57:24 +02:00
Jeroen van Rijn
938a6d338f Merge pull request #6958 from denovodavid/pr-fix-xar-caller-location
core:container/xar - forward caller location to make in array_push_back_*
2026-07-06 11:56:23 +02:00
denovodavid
f50625a42d forward caller location to make in xar array_push_back 2026-07-06 17:15:55 +10:00
Jx
1279dd6501 typo(time.odin): "nanonseconds" -> "nanoseconds" 2026-07-06 01:50:23 -03:00
Mustafa Furkan Bulut
2c85085fc6 Fix data corruption in endcoding/cbor 2026-07-05 15:58:45 +03:00
Laytan
d4fb326a4e Merge pull request #6946 from denovodavid/patch-1
core:container/queue - fix typo
2026-07-04 13:00:58 +02:00
David Holland
834b7cf3eb fix queue consume_front doc comment 2026-07-04 14:45:43 +10:00
Qiaoster
4b203f09c6 encoding/cbor: fix segfault decoding map/big.int nested in slice elements 2026-07-04 10:38:12 +08:00
Jeroen van Rijn
dc0f001b35 Merge pull request #6933 from odin-lang/bill/box3d
`vendor:box3d`
2026-07-03 21:35:30 +02:00
Flāvius
263e82a48a rexcode/x86: byte-exact encode/decode round-trip (247 -> 0)
Fix the operand-size/prefix bug class reported by the sigil backend, then close
every failure a whole-ISA encode->decode->re-encode audit surfaced -- 247 -> 0
over the 1165 round-trippable legacy forms.

Encode/decode:
- MOVSX/MOVZX take 66h from the destination, not the source (CRC32, whose r/m
  source drives 66h, is unchanged)
- operand-less 16-bit forms (CBW/CWD, MOVSW/CMPSW/SCASW/LODSW/STOSW,
  IRET/PUSHF/POPF) emit 66h via a new opsize_16 flag
- CRC32/MOVBE and POPCNT/LZCNT/TZCNT: mandatory F2/F3 beats 66h on decode
- mandatory-prefix REP double-encode: F2/F3 no longer re-emitted as REP
- fixed-ModR/M decode: x87 (FNOP/FCHS/FADD ST(i)/...) and the 0F 01/AE/C7/1E
  system-op groups (VMCALL/RDTSCP/LFENCE/ENDBR/...); gen.odin preserves the
  fixed ModR/M byte, the decoder matches and consumes it
- implicit-operand round-trip (accumulator short forms, x87 ST(i), xchg) via a
  positional matcher + emit path; accumulators stay implicit so hand-built
  `add eax, imm` keeps the general form (typed-builder consistency)
- MOV to/from CR/DR/segment (were decoding as GPRs); reg-vs-mem disambiguation
  (RDRAND vs VMPTRLD, MOVLHPS vs MOVHPS); x87 M80 operand size; PINSRW; NOP vs
  XCHG at 0x90
- LOCK standalone; ENTER two immediates; PUSH/POP FS/GS (segment fixed by the
  opcode + non-cacheable); BOUND marked 32-bit-only; RDRAND/RDSEED r16
  (66 is operand-size, resolved against the mandatory-66 VMCLEAR by ModR/M)

Tools/tests:
- revive dump_verify_input + verify_against_llvm (stale Result API; drop the
  aliases that were masking the fixed bugs); align verify_tables with the
  preserved fixed-ModR/M ext
- new tests/test_narrow_widths.odin: byte-exact vs llvm-mc + round-trip guards
- fold the bit-rotted tests32 package into the main suite (i386 Mode._32 paths)

248 tests pass; verify_tables passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01115ktMoX5qGAfp1VemBzCP
2026-07-02 10:32:00 -04:00
gingerBill
9653137a74 Merge pull request #6931 from thetarnav/remove-handle-map-builtin-import
Remove unused `base:builtin` import from `core:container/handle_map`
2026-07-02 14:00:46 +01:00
gingerBill
49120b0fa9 Use q.xyz rather than transmute 2026-07-02 13:33:52 +01:00
thetarnav
76902f5bfb Remove unused "base:builtin" import from "core:container/handle_map" 2026-07-02 13:18:35 +02:00
Jeroen van Rijn
4bc9750373 Fix #6843 2026-07-02 11:05:53 +02:00
Jeroen van Rijn
7b57c3eff2 User 2026-07-01 11:37:44 +02:00
Jeroen van Rijn
92ced49bbd Fix typo 2026-07-01 11:16:28 +02:00
Jeroen van Rijn
4b9f396cb3 Fix whitespace normalize 2026-06-30 13:23:44 +02:00