Commit Graph

7954 Commits

Author SHA1 Message Date
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
gingerBill
7d32c733d3 json.match utility procedure 2026-06-29 13:44:45 +01:00
gingerBill
9e713e2940 Update core:encoding/json to use proc groups and @(require_results) 2026-06-29 13:44:29 +01:00
gingerBill
b00f39acaf Merge branch 'master' into bill/rexcode 2026-06-29 13:10:21 +01:00
Brendan Punsky
7c4ff6a5e1 rexcode/ir/spirv: builders for ALL 873 opcodes (no skips)
Rewrite the builder generator to cover every opcode -- each operand maps to a
typed param by kind + quantifier, emitted with a running operand index so all
shapes compose:
  optional '?'    -> Maybe(T)
  variadic '*'    -> []T
  composite Pair* -> []Pair_Id_Id / []Pair_Lit_Id / []Pair_Id_Lit
  LiteralString   -> string (packed into word operands)
  Id/Lit/enum     -> Id / i64 / the typed enum (ValueEnum) or bit_set (BitEnum)

A verb that would clash with an Odin keyword, builtin, builtin type name, or a
re-exported ir.type_* constructor gets a trailing '_' (return_, switch_, string_,
size_of_, type_void_, ...). builder.odin gains the Pair_* types + a string packer.

873 inst_<OpName> + 873 Builder methods. Package compiles; suite 10 passed.
2026-06-26 15:57:36 -04:00
Brendan Punsky
d39cf98931 rexcode/ir/spirv: encoded_size + measure-mode writer
Add a count-only mode to the Writer (advance pos without storing) and factor the
section walk into emit_module, so encode and the new encoded_size(m) share one
path. encoded_size returns the exact byte count encode will produce -- the SPIR-V
analog of an ISA's encode_max_code_size, here exact rather than an upper bound.
The printer now sizes its scratch buffer with it instead of retry-on-overflow.

Verified: encoded_size == encode byte_count; suite 10 passed.
2026-06-26 13:34:53 -04:00
Brendan Punsky
6665d5b552 rexcode/ir/spirv: generate the typed builders (both layers) from the grammar
Extend tablegen to emit builders_gen.odin -- 723 opcodes get a low-level
inst_<OpName>(buf, ...) constructor and a high-level Builder method, mapping each
grammar operand to a typed param (IdResultType->Type_Ref, IdResult->auto-allocated
Id, IdRef->Id, LiteralInteger->i64, ValueEnum/BitEnum->the typed enum, trailing
IdRef* -> []Id). builder.odin keeps just the hand-written Builder infrastructure.

Skipped (stay hand-writable, like an ISA's can_generate_builder): operands that
aren't simple typed params yet (optional, Pair* composites, LiteralString),
type-declaration opcodes (those are ir.Type), and verbs colliding with Odin
keywords/builtins (return_, switch_, size_of, ...).

Validated: a function body built via i_add / return_ encodes + round-trips
byte-exact (builder_made test) -> 10 passed.
2026-06-26 13:32:07 -04:00
Brendan Punsky
dfbb0abed3 rexcode/ir/spirv: typed instruction builders (foundation)
Two layers, the SPIR-V analog of an ISA's mnemonic builders:
  - low level: inst_<OpName>(buf, ...) -> Operation, stateless + alloc-free, the
    caller owns the operand backing (SPIR-V operands are a slice, so unlike an
    ISA's inline [4]Operand they can't be owned by the return value).
  - high level: a Builder owning operand storage + a result-<id> allocator;
    iadd/load/store/call/variable/ret/ret_value append to the current block and
    return the new <id>.

Hand-written here for a representative slice (Id / no-result / variadic / enum
operands) to fix the pattern; tablegen will generate the full per-opcode set.
Validated: a builder-made function body round-trips byte-exact.
2026-06-26 13:23:55 -04:00
Brendan Punsky
c2a5091336 rexcode/ir/spirv: round-trip opaque types (image/sampler/event/...) verbatim
Type-defining instructions the codec doesn't model structurally -- OpTypeImage,
OpTypeSampler, OpTypeSampledImage, OpTypeMatrix, OpTypeOpaque, OpTypeEvent,
OpTypeDeviceEvent, OpTypeReserveId, OpTypeQueue, OpTypePipe -- decode to
Type{.OPAQUE} plus an Opaque_Info{opcode, words} side entry (the operand words
after the result <id>) and re-emit verbatim. One generic fallback covers every
opaque SPIR-V type byte-exact, with no per-type fields.

Test: image_type (OpTypeImage, 7 operands) round-trips -> 9 passed.
2026-06-26 12:11:25 -04:00
Brendan Punsky
ac1d51a0cd rexcode/ir/spirv: printer -- BitEnum names + trailing enum-param operands
- fmt_bitenum prints the common BitEnum operands as their set bits' names joined
  with '|' (or None when empty): FunctionControl, MemoryAccess, SelectionControl,
  LoopControl, ImageOperands -- so OpFunction ... None, OpLoad ... Aligned.
- fmt_inst now also prints words trailing the fixed operand layout (the params an
  enum value/bit pulls in, e.g. MemoryAccess Aligned's alignment), previously
  dropped: OpLoad %2 %7 Aligned 16.
2026-06-26 12:09:05 -04:00
Brendan Punsky
0cd5ed84b2 rexcode/ir/spirv: dependency-ordered definitions + runtime arrays
- Definition order: Module.defs records the exact type/constant/global
  interleaving (SPIR-V's single 'types, constants, global variables' section must
  be dependency-ordered -- a length constant before the array type that uses it,
  etc.). decode records it; encode replays it for byte-exact, spec-valid output
  (empty defs falls back to all-types, then -constants, then -globals).
  emit_one_type/constant/global factored out for the replay; no encoder alloc.
- OpTypeRuntimeArray: ARRAY with len_ref == ID_NONE (vs OpTypeArray's <id> length).

Tests: bool_and_array sets defs so OpConstant precedes OpTypeArray (verified in
disasm); runtime_array added -> 7 passed.
2026-06-26 12:04:27 -04:00
Brendan Punsky
fe27dcdbd4 rexcode/ir: add Type_Kind.BOOL + array <id> length; SPIR-V bool/array round-trip
Extend the shared type model so SPIR-V's OpTypeBool and OpTypeArray (whose length
is a constant <id>, not a literal) lower cleanly:
  - ir.Type_Kind gains BOOL (a distinct boolean; LLVM i1 will use it too).
  - ir.Type gains len_ref: Id -- an ARRAY length carried as a constant <id>
    (alongside the existing literal count for dialects with literal lengths).
  - type_bool / type_array constructors.

SPIR-V codec: OpTypeBool <-> Type{.BOOL}; OpTypeArray <-> Type{.ARRAY, elem,
len_ref}. Test bool_and_array round-trips byte-exact -> 6 passed.

NOTE: a spec-valid module orders an array's length constant before the array
type; the codec round-trips the shape byte-exact regardless, but emitting the
types/constants section in dependency order is a follow-up.
2026-06-26 11:45:35 -04:00