Commit Graph

18346 Commits

Author SHA1 Message Date
gingerBill
16ac69517c Merge pull request #6914 from Kelimion/fix-xml
Fix whitespace normalize
2026-06-30 12:32:41 +01:00
Jeroen van Rijn
4b9f396cb3 Fix whitespace normalize 2026-06-30 13:23:44 +02:00
gingerBill
62511914de When inserting a constant union into a struct literal, rebuild the struct to be non-named with llvm_const_insert_value_with_rebuild 2026-06-30 12:16:21 +01:00
gingerBill
28a43fd4f7 Short-circuit further for constant unions in the LLVM constant literal syntax 2026-06-30 11:49:35 +01:00
gingerBill
d0847b7ce8 Merge pull request #6913 from tf2spi/6831-add-constant-type-checks
Add more constant type cases
2026-06-30 11:29:26 +01:00
misomosi
c8aa151a66 Add more constant type cases 2026-06-29 22:46:17 -04:00
gingerBill
47fa8df598 Fix comment 2026-06-29 17:01:44 +01:00
gingerBill
ac6a0f9a40 Move around the ordering of find_visual_studio_and_windows_sdk 2026-06-29 16:36:21 +01:00
gingerBill
1cdf314015 Remove debug print string 2026-06-29 16:04:24 +01:00
misomosi
12e8ba8d66 Use lb_add_values_to_array for cvarargs 2026-06-29 10:01:50 -04:00
gingerBill
cec2127068 Merge pull request #6906 from tf2spi/6902-off-by-one
Report range type correctly on out-of-bounds
2026-06-29 13:51:09 +01:00
gingerBill
37c349e604 Fix #6907 2026-06-29 13:47:46 +01: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
misomosi
fc62110392 Report range type correctly on out-of-bounds 2026-06-29 08:29:14 -04:00
gingerBill
b00f39acaf Merge branch 'master' into bill/rexcode 2026-06-29 13:10:21 +01:00
gingerBill
70607eeb0b Merge pull request #6905 from odin-lang/bill/constant-union-fixes
Fix constant union stuff against tests
2026-06-29 13:10:02 +01:00
gingerBill
e24bbb813c Merge branch 'master' into bill/constant-union-fixes 2026-06-29 13:02:12 +01:00
gingerBill
b9a9846b7c Fix constant union stuff against tests 2026-06-29 13:00:44 +01:00
gingerBill
42f681baff Revert some of the union changes 2026-06-29 12:18:40 +01:00
gingerBill
2f3174fe10 Fix llvm_const_cast with constant union literals 2026-06-29 11:41:27 +01:00
gingerBill
feb9b6159e Fix pkg.Constant.field union access 2026-06-29 11:06:34 +01:00
gingerBill
138748c24a Merge branch 'master' of https://github.com/odin-lang/Odin 2026-06-29 10:49:47 +01:00
gingerBill
e227c736e6 Fix #6786 2026-06-29 10:49:29 +01:00
gingerBill
6fae6827cc Merge pull request #6904 from tf2spi/6889-count-bits
Resolve panic on 64-bit overflow
2026-06-29 10:30:00 +01:00
gingerBill
a4dcf8f5d6 Merge branch 'master' of https://github.com/odin-lang/Odin 2026-06-29 00:55:16 +01:00
gingerBill
6e65b5e4bc Allow for more "constantable" union values 2026-06-29 00:55:07 +01:00
misomosi
5be99bf1c2 Add missing check_is_expressible 2026-06-28 19:25:22 -04:00
misomosi
85c2aaf0a4 Use libtommath API for counting bits 2026-06-28 19:25:02 -04:00
Maurice Elliott
501cf908bb Merge branch 'odin-lang:master' into master 2026-06-28 21:58:24 +01:00
RobinsAviary
d28c610c7e moved to v6.0 folder at suggestion, fixed a few small things i missed 2026-06-28 14:42:21 -04:00
gingerBill
62c59825f8 Merge pull request #6903 from heavyrain266/gameinput
Stripped `GameInput` prefix from interface type names of `vendor:windows/GameInput`
2026-06-28 17:35:21 +01:00
gingerBill
ca3ef41dcf Fix typo 2026-06-28 13:34:29 +01:00
gingerBill
7da5608121 Add _append_elem_ptr to optimize for append when the element is internally pointer-like 2026-06-28 13:31:49 +01:00
Ignacy Koper
979f4fdd0c stripped GameInput prefix from interface type names of vendor:windows/GameInput
Signed-off-by: Ignacy Koper <ignacy423@gmail.com>
2026-06-28 13:38:29 +02:00
Maurice Elliott
3c52217338 Merge branch 'odin-lang:master' into master 2026-06-27 23:13:23 +01:00
Jeroen van Rijn
4ad085b30b Merge pull request #6893 from blob1807/sdl-remove-joystick_lock
Remove non-exported `joystick_lock` symbol
2026-06-26 22:28:50 +02: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
Brendan Punsky
7a8dc34d5f rexcode/ir/spirv: confirm big-endian decode (round-trip test)
The decoder already detects endianness from the magic word and byte-swaps each
word; strings are read from word values, so both endiannesses decode. Lock it in:
the round-trip helper now also byte-swaps every word to big-endian, decodes, and
asserts the re-encoding reproduces the original little-endian bytes -- across all
5 cases.
2026-06-26 11:23:38 -04:00
Brendan Punsky
0f5fa3d1d9 rexcode: wire the ir/ packages into build.lua
build.lua was ISA-centric; add an IRS catalog (ir/<name>) and route it through
the gen / check / test tasks. IR packages have a single-stage generator (gen.odin
emits Odin directly), a plain odin check, and a tests/ suite -- no mnemonic
builders or external-assembler verify, so only those three tasks apply. Purely
additive: the ISA catalog, task functions, and verify-tool probing are untouched.

luajit build.lua --check --test now reports spirv alongside the ISAs
(check ok, test 5 passed).
2026-06-26 11:21:33 -04:00
Brendan Punsky
4de6a7e6b6 rexcode/ir/spirv: printer -- symbolic ValueEnum names + computed bound in header
fmt_enum prints the common ValueEnum operands by name (Capability Shader,
Addressing/Memory model Logical GLSL450, ExecutionModel GLCompute, StorageClass,
Decoration, ...); BitEnums stay numeric (their bit_set %v form is too verbose to
read inline). The header comment now reads version/generator/bound from the
encoded words, so Bound reflects the computed value, not the pre-encode 0.
2026-06-26 11:17:39 -04:00
Brendan Punsky
35fac68c7c rexcode/ir/spirv: codec completeness -- function params, computed bound, enum-param operands
- OpFunctionParameter: the entry block's Block.params round-trip as
  OpFunctionParameter (emitted between OpFunction and the entry OpLabel, decoded
  back onto the entry block).
- encode computes bound (max <id> + 1) when the caller leaves it 0; a non-zero
  bound (e.g. from decode) is preserved, so re-encode is stable.
- Trailing operands an enum value/bit pulls in (MemoryAccess Aligned's alignment,
  ...) are captured on decode as literals, so enum-parameter instructions
  re-encode byte-exact.

Tests: param_function + load_aligned added -> 5 passed.
2026-06-26 11:14:12 -04:00
Brendan Punsky
47c23d6d35 rexcode/ir/spirv: printer (disassembly) -- the third ir verb
print(m, sb, options): disassemble a Module into a spirv-dis-style listing.
Encodes to a scratch buffer (doubling on overflow) and walks the word stream
generically through the operand-layout table, so every opcode disassembles with
no per-op code -- Id operands as %id, LiteralString quoted, the result-id column
right-aligned before OpName:

  ; SPIR-V
  ; Version: 1.5
  ; Bound: 9
           %2 = OpTypeInt 32 1
           %4 = OpConstant %2 10
           %6 = OpIAdd %2 %4 %5
                OpReturn

Enums print numerically for now (symbolic names a refinement). Completes the
encode / decode / print verb triad.
2026-06-26 11:05:14 -04:00