aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
AgeCommit message (Collapse)Author
2023-11-24spirv: add -fstructured-cfg optionRobin Voetter
This enables the compiler to generate a structured cfg even in opencl, even if it is not strictly required by the SPIR-V Kernel specification.
2023-11-19compiler: correct unnecessary uses of 'var'mlugg
2023-10-24InternPool: remove runtime_value representationmlugg
The main goal of this commit is to remove the `runtime_value` field from `InternPool.Key` (and its associated representation), but there are a few dominos. Specifically, this mostly eliminates the "maybe runtime" concept from value resolution in Sema: so some resolution functions like `resolveMaybeUndefValAllowVariablesMaybeRuntime` are gone. This required a small change to struct/union/array initializers, to no longer use `runtime_value` if a field was a `variable` - I'm not convinced this case was even reachable, as `variable` should only ever exist as the trivial value of a global runtime `var` decl. Now, the only case in which a `Sema.resolveMaybeUndefVal`-esque function can return the `variable` key is `resolveMaybeUndefValAllowVariables`, which is directly called from `Sema.resolveInstValueAllowVariables` (previously `Sema.resolveInstValue`), which is only used for resolving the value of a Decl from `Module.semaDecl`. While changing these functions, I also slightly reordered and restructured some of them, and updated their doc comments.
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-23Merge pull request #17651 from Vexu/error-limitAndrew Kelley
Make distinct error limit configurable (attempt #2)
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-22Merge pull request #17657 from Snektron/spirv-recursive-ptrsRobin Voetter
spirv: recursive pointers
2023-10-22remove uses of non-configurable `err_int`Veikka Tuominen
2023-10-21InternPool: store alignment of anon declsAndrew Kelley
Commit 5393e56500d499753dbc39704c0161b47d1e4d5c has a flaw pointed out by @mlugg: the `ty` field of pointer values changes when comptime values are pointer-casted. This commit introduces a new encoding which additionally stores the "original pointer type" which is used to store the alignment of the anonymous decl, and potentially other information in the future such as section and pointer address space. However, this new encoding is only used when the original pointer type differs from the casted pointer type in a meaningful way. I was able to make the LLVM backend and the C backend lower anonymous decls with the appropriate alignment, however I will need some help figuring out how to do this for the backends that lower anonymous decls via src/codegen.zig and the wasm backend.
2023-10-21spirv: self-referential pointers via new fwd_ptr_typeRobin Voetter
Its a little ugly but it works.
2023-10-21spirv: make constructStruct also use self.ptrTypeRobin Voetter
This completes the migration from spv.ptrType to self.ptrType. Unfortunately this requires us to pass a list of types to constructStruct, which also requires some extra allocations here and there.
2023-10-21spirv: improve union operationsRobin Voetter
This removes the strategy where union with different active fields would be generated, and instead simply pointer casts the active field type where required. This also allows removing spv.ptrType and using self.ptrType instead, and allows caching all union types (because there is only the canonical one).
2023-10-21spirv: make load() and store() accept MemoryOptionsRobin Voetter
This struct is used to configure the load, such as to make it volatile. Previously this was done using a single bool, but this struct makes it shorter to write non-volatile loads (the usual) and more clear whats going on when a volatile load is required.
2023-10-21spirv: replace most use of spv.ptrType with self.ptrTypeRobin Voetter
To support self-referential pointers, in the future we will need to pass the Zig type to any pointer that is created. This lays some ground work for that by replacing most uses of spv.ptrType with a new ptrType function that also accepts the Zig type. This function's contents will soon be replaced by a version that also supports self-referential pointers. Also fixed some bugs regarding the use of direct/indirect.
2023-10-18Merge pull request #17577 from alichraghi/spirv-1Robin Voetter
spirv: switch on bool
2023-10-18Merge pull request #17561 from alichraghi/spirv-0Robin Voetter
spirv: memcpy
2023-10-18spirv: switch on boolAli Chraghi
2023-10-17spirv: memcpyAli Chraghi
2023-10-16spirv: fieldParentPtrAli Chraghi
2023-10-15spirv: simple binary and comparison vector operationsAli Chraghi
2023-10-15spirv: emit vectors as arraysAli Chraghi
2023-10-15spirv: optional comparisonRobin Voetter
2023-10-15spirv: handle errors in switchRobin Voetter
2023-10-15spirv: intcast, trunc for strange intsRobin Voetter
2023-10-15spirv: sign-extension for strange integersRobin Voetter
2023-10-15spirv: air min/maxRobin Voetter
2023-10-15spirv: air bitcast for non-numeric non-pointer typesRobin Voetter
2023-10-15spirv: fix air is_null optional slice field typeRobin Voetter
2023-10-15spirv: allow generation of *i0Robin Voetter
2023-10-15spirv: handle zero-sized arraysRobin Voetter
2023-10-15spirv: `fpext` and `fptrunc` instructionsAli Chraghi
2023-10-15spirv: override function return type to void if it has no runtime bitsRobin Voetter
2023-10-15spirv: generate *void as pointer to opaqueRobin Voetter
2023-10-15spirv: make air is_null not emit OpPtr(Not)EqualRobin Voetter
2023-10-15spirv: fix incorrect repr of some optional operationsRobin Voetter
2023-10-15spirv: make bitcasts between the same spirv type a no-opRobin Voetter
2023-10-15spirv: fix float unequalityRobin Voetter
2023-10-15spirv: properly skip comptime function parametersRobin Voetter
2023-10-15spirv: aggregate_init for structsRobin Voetter
2023-10-15spirv: put linkery bits in ObjectRobin Voetter
This structure is used to group information that needs to persist between decls in codegen.
2023-10-15spirv: use CacheString for source_file_names instead of []const u8Robin Voetter
2023-10-15spirv: anon decl refsRobin Voetter
2023-10-15spirv: cast result of .elem pointers to right type if neededRobin Voetter
2023-10-15spirv: constant elem ptr fixRobin Voetter
2023-10-15spirv: lower pointers to zero-bit types as undefRobin Voetter
2023-10-15spirv: opaque typesRobin Voetter
2023-10-03compiler: start handling anonymous decls differentlyAndrew Kelley
Instead of explicitly creating a `Module.Decl` object for each anonymous declaration, each `InternPool.Index` value is implicitly understood to be an anonymous declaration when encountered by backend codegen. The memory management strategy for these anonymous decls then becomes to garbage collect them along with standard InternPool garbage. In the interest of a smooth transition, this commit only implements this new scheme for string literals and leaves all the previous mechanisms in place.
2023-09-23spirv: fixesRobin Voetter
2023-09-23spirv: air dbg_var_val and dbg_var_ptrRobin Voetter
2023-09-23spirv: fix blocks that return no valueRobin Voetter