aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
AgeCommit message (Collapse)Author
2024-04-06spirv: implement `@divFloor`, `@floor` and `@mod`Ali Chraghi
2024-04-05spirv: make behavior tests passingAli Chraghi
2024-03-30spirv: clz, ctz for openclRobin Voetter
This instruction seems common in compiler_rt.
2024-03-26compiler: eliminate TypedValuemlugg
The only logic which remained in this file was the Value printing logic. This has been moved into a new `print_value.zig`.
2024-03-26Zcu: eliminate `Decl.alive` fieldmlugg
Legacy anon decls now have three uses: * Type owner decls * Function owner decls * `@export` and `@extern` Therefore, there are no longer any cases where we wish to explicitly omit legacy anon decls from the binary. This means we can remove the concept of an "alive" vs "dead" `Decl`, which also allows us to remove the separate `anon_work_queue` in `Compilation`.
2024-03-26Zcu.Decl: remove `ty` fieldmlugg
`Decl` can no longer store un-interned values, so this field is now unnecessary. The type can instead be fetched with the new `typeOf` helper method, which just gets the type of the Decl's `Value`.
2024-03-25compiler: implement analysis-local comptime-mutable memorymlugg
This commit changes how we represent comptime-mutable memory (`comptime var`) in the compiler in order to implement the intended behavior that references to such memory can only exist at comptime. It does *not* clean up the representation of mutable values, improve the representation of comptime-known pointers, or fix the many bugs in the comptime pointer access code. These will be future enhancements. Comptime memory lives for the duration of a single Sema, and is not permitted to escape that one analysis, either by becoming runtime-known or by becoming comptime-known to other analyses. These restrictions mean that we can represent comptime allocations not via Decl, but with state local to Sema - specifically, the new `Sema.comptime_allocs` field. All comptime-mutable allocations, as well as any comptime-known const allocs containing references to such memory, live in here. This allows for relatively fast checking of whether a value references any comptime-mtuable memory, since we need only traverse values up to pointers: pointers to Decls can never reference comptime-mutable memory, and pointers into `Sema.comptime_allocs` always do. This change exposed some faulty pointer access logic in `Value.zig`. I've fixed the important cases, but there are some TODOs I've put in which are definitely possible to hit with sufficiently esoteric code. I plan to resolve these by auditing all direct accesses to pointers (most of them ought to use Sema to perform the pointer access!), but for now this is sufficient for all realistic code and to get tests passing. This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema arena for comptime memory mutations, which is possible since comptime memory is now local to the current Sema. This change should allow `Decl` to store only an `InternPool.Index` rather than a full-blown `ty: Type, val: Value`. This commit does not perform this refactor.
2024-03-18spirv: fix optional comparisonRobin Voetter
2024-03-18spirv: make generic globals invocation-localRobin Voetter
2024-03-18spirv: make IdResult an enumRobin Voetter
2024-03-17Revert "spirv: merge `construct(Struct/Vector/Array)` into `constructComposite`"Robin Voetter
This reverts commit eb2d61d02e503f01070c05e2e1fc87e827124d94.
2024-03-11std.builtin: make container layout fields lowercaseTristan Ross
2024-03-06InternPool: create specialized functions for loading namespace typesmlugg
Namespace types (`struct`, `enum`, `union`, `opaque`) do not use structural equality - equivalence is based on their Decl index (and soon will change to AST node + captures). However, we previously stored all other information in the corresponding `InternPool.Key` anyway. For logical consistency, it makes sense to have the key only be the true key (that is, the Decl index) and to load all other data through another function. This introduces those functions, by the name of `loadStructType` etc. It's a big diff, but most of it is no-brainer changes. In future, it might be nice to eliminate a bunch of the loaded state in favour of accessor functions on the `LoadedXyzType` types (like how we have `LoadedUnionType.size()`), but that can be explored at a later date.
2024-03-02Air: replace `.dbg_inline_*` with `.dbg_inline_block`Jacob Young
This prevents the possibility of not emitting a `.dbg_inline_end` instruction and reduces the allocation requirements of the backends. Closes #19093
2024-02-26move Zir to std.zig.ZirAndrew Kelley
Part of an effort to ship more of the compiler in source form.
2024-02-26move Zcu.LazySrcLoc to std.zig.LazySrcLocAndrew Kelley
Part of an effort to ship more of the compiler in source form.
2024-02-26compiler: decide dbg_var scoping based on AIR blocksmlugg
This commit eliminates the `dbg_block_{begin,end}` instructions from both ZIR and AIR. Instead, lexical scoping of `dbg_var_{ptr,val}` instructions is decided based on the AIR block they exist within. This is a much more robust system, and also results in a huge drop in ZIR bytes - around 7% for Sema.zig. This required some enhancements to Sema to prevent elision of blocks when they are required for debug variable scoping. This can be observed by looking at the AIR for the following simple test program with and without `-fstrip`: ```zig export fn f() void { { var a: u32 = 0; _ = &a; } { var a: u32 = 0; _ = &a; } } ``` When `-fstrip` is passed, no AIR blocks are generated. When `-fno-strip` is passed, the ZIR blocks are lowered to true AIR blocks to give correct lexical scoping to the debug vars. The changes here incidentally reolve #19060. A corresponding behavior test has been added. Resolves: #19060
2024-02-25test: rework how filtering worksJacob Young
* make test names contain the fully qualified name * make test filters match the fully qualified name * allow multiple test filters, where a test is skipped if it does not match any of the specified filters
2024-02-15spirv: use extended instructions whenever possibleAli Chraghi
2024-02-10spirv: remove now-redundant isUnused calls from AIR handler functionsAli Chraghi
2024-02-09spirv: emit vectorized operationsAli Chraghi
2024-02-09spirv: merge `construct(Struct/Vector/Array)` into `constructComposite`Ali Chraghi
2024-02-05compiler: rename value.zig to Value.zigAndrew Kelley
This commit only does the file rename to be friendlier to version control conflicts.
2024-02-05spirv: emit vectors whenever we canAli Chraghi
2024-02-05spirv: basic shader supportAli Chraghi
2024-02-04spirv: air vector_store_elementRobin Voetter
2024-02-04spirv: air splatRobin Voetter
2024-02-04spirv: air absRobin Voetter
2024-02-04spirv: fix shuffle properlyRobin Voetter
2024-02-04spirv: vectorize max, minRobin Voetter
2024-02-04spirv: vectorize int_cast, truncRobin Voetter
2024-02-04spirv: air is_(non_)null_ptr, optional_payload_ptrRobin Voetter
2024-02-04spirv: air mul_addRobin Voetter
2024-02-04spirv: air int_from_boolRobin Voetter
2024-02-04spirv: clean up arithmeticTypeInfo a bitRobin Voetter
- No longer returns an error - Returns more useful vector info
2024-02-04spirv: wrap strange its before instead of after operationRobin Voetter
Wrapping strange integers before an operation was initially done as an attempt to minimize the amount of normalizations required: This way, there would not be a normalization necessary between two modular operations. This was a premature optimization, since the resulting logic is more complicated than naive way of wrapping the result after the operation. This commit updates handling of strange integers to do wrapping after each operation. It also seems slightly more efficient in terms of size of generated code, as it reduces the size of the behavior tests binary by about 1%.
2024-02-04spirv: vectorize add/sub overflowRobin Voetter
2024-02-04spirv: reduce, reduce_optimizedRobin Voetter
2024-02-04spirv: shlWithOverflowRobin Voetter
2024-02-04spirv: vectors for air notRobin Voetter
2024-02-04spirv: use new vector stuff for arithOp and shiftRobin Voetter
2024-02-04spirv: element-wise operation helperRobin Voetter
2024-02-04spirv: sh[rl](_exact)?Robin Voetter
2024-02-02InternPool: use separate key for slicesmlugg
This change eliminates some problematic recursive logic in InternPool, and provides a safer API.
2024-01-29llvm: ensure returned undef is 0xaa bytes when runtime safety is enabledVeikka Tuominen
Closes #13178
2024-01-01compiler: update many references to bin_file.optionsAndrew Kelley
2023-12-03Air: use typesafe `Air.Inst.Index`Jacob Young
I need some indices for a thing...
2023-11-26move Module.Decl.Index and Module.Namespace.Index to InternPoolMeghan Denny
2023-11-25convert `toType` and `toValue` to `Type.fromInterned` and `Value.fromInterned`Techatrix
2023-11-24spirv: structured control flowRobin Voetter