aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
AgeCommit message (Collapse)Author
2024-06-16spirv: add support for workItemId, workGroupId, workGroupSizeRobin Voetter
2024-06-10spirv: new vectorization helperRobin Voetter
The old vectorization helper (WipElementWise) was clunky and a bit annoying to use, and it wasn't really flexible enough. This introduces a new vectorization helper, which uses Temporary and Operation types to deduce a Vectorization to perform the operation in a reasonably efficient manner. It removes the outer loop required by WipElementWise so that implementations of AIR instructions are cleaner. This helps with sanity when we start to introduce support for composite integers. airShift, convertToDirect, convertToIndirect, and normalize are initially implemented using this new method.
2024-04-06spirv: yeet cacheRobin Voetter
2024-04-06spirv: remove cache usage for typesRobin Voetter
2024-04-06spirv: remove cache usage for constantsRobin Voetter
2024-04-06spirv: id range helperRobin Voetter
This allows us to more sanely allocate a continuous range of result-ids, and avoids a bunch of nasty casting code in a few places. Its currently not used very often, but will be useful in the future.
2024-04-06spirv: OpExtInstImport in assemblerAli Chraghi
2024-04-06spirv: implement `@divFloor`, `@floor` and `@mod`Ali Chraghi
2024-03-18spirv: make generic globals invocation-localRobin Voetter
2024-03-18spirv: make IdResult an enumRobin Voetter
2024-02-15spirv: add capability to compile with x86_64 backendAli Chraghi
2024-02-15spirv: use extended instructions whenever possibleAli Chraghi
2024-02-09spirv: make rusticl the primary testing implementationAli Chraghi
2024-02-05spirv: emit vectors whenever we canAli Chraghi
2024-02-05spirv: basic shader supportAli Chraghi
2023-11-24spirv: fix memory leak in SpvModuleRobin Voetter
2023-10-23Revert "Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs""Robin Voetter
This reverts commit 9f0359d78f9facc38418e32b0e8c1bf6f99f0d26 in an attempt to make the tests pass again. The CI failure from that merge should be unrelated to this commit.
2023-10-22Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs"Andrew Kelley
This reverts commit b822e841cda0adabe3fec260ff51c18508f7ee32, reversing changes made to 0c99ba1eab63865592bb084feb271cd4e4b0357e. This caused a CI failure when it landed in master branch.
2023-10-21spirv: self-referential pointers via new fwd_ptr_typeRobin Voetter
Its a little ugly but it works.
2023-10-15spirv: work around OpSource parsing issue in llvm-spirvRobin Voetter
The Khronos SPIRV-LLVM translator does not parse OpSource correctly. This was causing tests to fail and other mysterious issues. These are resolved by only generating a single OpSource instruction for now, which does not have the source file locations also. See https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2188
2023-10-15spirv: use CacheString for source_file_names instead of []const u8Robin Voetter
2023-10-15spirv: get rid of SpvModule arenaRobin Voetter
2023-09-23spirv: air dbg_var_val and dbg_var_ptrRobin Voetter
2023-09-23spirv: generate module initializerRobin Voetter
2023-09-23spirv: put global var initializers in functionsRobin Voetter
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-06-10stage2: move opaque types to InternPoolAndrew Kelley
2023-06-10stage2: move many Type encodings to InternPoolAndrew Kelley
Notably, `vector`. Additionally, all alternate encodings of `pointer`, `optional`, and `array`.
2023-05-30spirv: eliminate remaining uses of emitConstantRobin Voetter
2023-05-30spirv: rename TypeConstantCache -> CacheRobin Voetter
2023-05-30spirv: translate remaining typesRobin Voetter
2023-05-30spirv: translate remaining typesRobin Voetter
2023-05-30spirv: translate structs to cache keyRobin Voetter
2023-05-30spirv: basic setup for using new type constant cacheRobin Voetter
2023-05-30spirv: TypeConstantCacheRobin Voetter
2023-05-20spirv: make constant handle float, errorset, errorunionRobin Voetter
This is in preparation of removing indirect lowering again. Also modifies constant() to accept a repr so that both direct as well as indirect representations can be generated. Indirect is not yet used, but will be used for globals.
2023-05-11spirv: make decl deps a hash map instead of an arraylistRobin Voetter
The same declaration can be added to the dependency set multiple times, and in this case we still need to emit it once. By making this list a hash map instead, we can do that quite easily. This commit also introduces some additional debug logging regarding decls.
2023-05-11spirv: fix use-after-realloc in resolveType()Robin Voetter
The pointer to a slot in a hash map was fetched before a recursive call. If the hash map's size changed during the recursive call, this would write to an invalid pointer. The solution is to use an index instead of a pointer. Note that care must be taken that resolved types (from the type_cahce) must not be accessed, as they might be incomplete during this operation.
2023-04-09spirv: Do not generate the Alignment attribute on pointers for nowRobin Voetter
It seems that some implementations may have problems with these right now, like Intel and Rusticl. In theory, these attributes should be superficial on the pointer type, as alignment guarantees are also added via the alignment option of the OpLoad and OpStore instructions. Therefore, get rid of them for now.
2023-04-09spirv: emit interface variables for entry pointsRobin Voetter
Also actually implement generating the OpEntryPoint instructions.
2023-04-09spirv: add decl dependencies for functions alsoRobin Voetter
Entry points need to be attributed with a complete list of global variables that they use. To that end, the global dependencies mechanism is extended to also allow functions - when flushing the module, the list of dependencies is examined to generate this list of global variable result-ids.
2023-04-09spirv: temporarily emit test kernelsRobin Voetter
SPIR-V cannot represent function pointers without extensions that no vendor implements. For the time being, generate a test kernel for each error, so that we can at least run SOME tests. In the future we may be able to emulate function pointers in some way, but that is not today.
2023-04-09spirv: improve linking globalsRobin Voetter
SPIR-V globals must be emitted in order, so that any declaration precedes usage. Zig, however, generates globals in random order. To this end we keep for each global a list of dependencies and perform a topological sort when flushing the module.
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: generic global pointersRobin Voetter
Similar to function locals, taking the address of a global that does not have an explicit address space assigned to it should result in a generic pointer, not a global pointer. Also similar to function locals, they cannot be generated into the generic storage class, and so are generated into the global storage class and then cast to a generic pointer, using OpSpecConstantOp. Note that using OpSpecConstantOp results is only allowed by a hand full of other OpSpecConstant instructions - which is why we generate constant structs using OpSpecConstantComposite: These may use OpVariable and OpSpecConstantOp results, while OpConstantComposite may not.
2023-04-09spirv: start lowering non-function declsRobin Voetter
Start to lower decls which are not functions. These generate an OpVariable instruction by which they can be used later on.
2023-04-09spirv: introduce type/value representationsRobin Voetter
There are two main ways in which a value can be stored: "Direct", as it will be operated on as an immediate value, and "indirect", as it is stored in memory. Some types need a different representation here: Bools, for example, are opaque in SPIR-V, and so these need to have a different representation in memory. The bool operations are not easily interchangable with integer operations, though, so they need to be OpTypeBool as immediate value.
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.