aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Section.zig
AgeCommit message (Collapse)Author
2025-08-04spirv: define and use extended instruction set opcodesAli Cheraghi
2025-08-03Watch: do not fail when file is removedAli Cheraghi
before this we would get a crash
2025-08-02spirv: refactorAli Cheraghi
2025-07-14spirv: snake-case the specAli Cheraghi
2025-06-12compiler: slightly untangle LLVM from the linkersmlugg
The main goal of this commit is to make it easier to decouple codegen from the linkers by being able to do LLVM codegen without going through the `link.File`; however, this ended up being a nice refactor anyway. Previously, every linker stored an optional `llvm.Object`, which was populated when using LLVM for the ZCU *and* linking an output binary; and `Zcu` also stored an optional `llvm.Object`, which was used only when we needed LLVM for the ZCU (e.g. for `-femit-llvm-bc`) but were not emitting a binary. This situation was incredibly silly. It meant there were N+1 places the LLVM object might be instead of just 1, and it meant that every linker had to start a bunch of methods by checking for an LLVM object, and just dispatching to the corresponding method on *it* instead if it was not `null`. Instead, we now always store the LLVM object on the `Zcu` -- which makes sense, because it corresponds to the object emitted by, well, the Zig Compilation Unit! The linkers now mostly don't make reference to LLVM. `Compilation` makes sure to emit the LLVM object if necessary before calling `flush`, so it is ready for the linker. Also, all of the `link.File` methods which act on the ZCU -- like `updateNav` -- now check for the LLVM object in `link.zig` instead of in every single individual linker implementation. Notably, the change to LLVM emit improves this rather ludicrous call chain in the `-fllvm -flld` case: * Compilation.flush * link.File.flush * link.Elf.flush * link.Elf.linkWithLLD * link.Elf.flushModule * link.emitLlvmObject * Compilation.emitLlvmObject * llvm.Object.emit Replacing it with this one: * Compilation.flush * llvm.Object.emit ...although we do currently still end up in `link.Elf.linkWithLLD` to do the actual linking. The logic for invoking LLD should probably also be unified at least somewhat; I haven't done that in this commit.
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-04-06spirv: OpExtInstImport in assemblerAli Chraghi
2024-03-18spirv: make generic globals invocation-localRobin Voetter
2024-03-18spirv: make IdResult an enumRobin Voetter
2024-03-11std.builtin: make container layout fields lowercaseTristan Ross
2023-11-24spirv: structured control flowRobin Voetter
2023-11-24spirv: always emit mask constants even if no bits are setRobin Voetter
A parameter like this is not always optional, even if that is usually implied. SPIR-V tools fail to parse a module with an OpLoopMerge instruction where the loop control parameter is left out.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-04-09spirv: overhaul constant loweringRobin Voetter
Lowering constants is currently not really compatible with unions. In this commit, constant lowering is drastically overhauled: instead of playing nice and generating SPIR-V constant representations for everything directly, we're just going to treat globals as an untyped bag of bytes ( or rather, SPIR-V 32-bit words), which we cast to the desired type at usage. This is similar to how Rust generates constants in its LLVm backend.
2023-04-09spirv: more fixes and improvementsRobin Voetter
- Formatting. - Improve `decorate` helper function to generate a decoration for a result-id. - Reorder some functions in a more logical way
2023-04-09spirv: make IdResultType and IdRef weak aliases of IdResultRobin Voetter
Previously they were strong aliases, but as these types are used quite intermittendly it resulted in a lot of toRef() calls. Removing them improves readability a bit.
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-11-23spirv: assemblerRobin Voetter
spirv: introduce SpvModule.Fn to generate function code into spirv: assembler error message setup spirv: runtime spec info spirv: inline assembly tokenizer spirv: inline assembly lhs result/opcode parsing spirv: forgot to fmt spirv: tokenize opcodes and assigned result-ids spirv: operand parsing setup spirv: assembler string literals spirv: assembler integer literals spirv: assembler value enums spirv: assembler bit masks spirv: update assembler to new asm air format spirv: target 1.5 for now Current vulkan sdk version (1.3.204) ships spirv tools targetting 1.5, and so these do not work with binaries targetting 1.6 yet. In the future, this version number should be decided by the target. spirv: store operands in flat arraylist. Instead of having dedicated Operand variants for variadic operands, just flatten them and store them in the normal inst.operands list. This is a little simpler, but is not easily decodable in the operand data representation. spirv: parse variadic assembly operands spirv: improve assembler result-id tokenization spirv: begin instruction processing spirv: only remove decl if it was actually allocated spirv: work around weird miscompilation Seems like there are problems with switch in anonymous struct literals. spirv: begin resolving some types in assembler spirv: improve instruction processing spirv: rename some types + process OpTypeInt spirv: process OpTypeVector spirv: process OpTypeMatrix and OpTypeSampler spirv: add opcode class to spec, remove @exclude'd instructions spirv: process more type instructions spirv: OpTypeFunction spirv: OpTypeOpaque spirv: parse LiteralContextDependentNumber operands spirv: emit assembly instruction into right section spirv: parse OpPhi parameters spirv: inline assembly inputs spirv: also copy air types spirv: inline assembly outputs spirv: spir-v address spaces spirv: basic vector constants/types and shuffle spirv: assembler OpTypeImage spirv: some stuff spirv: remove spirv address spaces for now
2022-07-04stage2: disable unit tests when building with stage1Andrew Kelley
They trip LLVM assertions and spirv is not needed to bootstrap. Not important for these tests to pass with stage1.
2022-04-27std: replace usage of std.meta.bitCount() with @bitSizeOf()Isaac Freund
2022-01-28spirv: spir-v dedicated type systemRobin Voetter
2022-01-28spirv: new moduleRobin Voetter
This introduces a dedicated struct that handles module-wide information.
2022-01-28spirv: model spir-v section as separate typeRobin Voetter
The idea is that this type gains the relevant low-level instruction emitting functions, and that higher-level checks and deduplications are performed somewhere else.