* spirv-val: ValidateWorkgroupSizeAtDefinition as Universial
* spirv-val: Validate ExecutionMode local size
* spirv-val: Tests for zero product workgroup size
When trying to parse SPIR-V version from assembly comments,
ensure a match against an initial comment doesn't cause the
scanner to go back to the beginning of the assembly text.
Fixed: #5909
* spirv-as: Assume target from spvasm text
Assume the desired SPIR-V target version when the command line option is
not provided. This is especially important when the source being
assembled does not match the default (latest version), because it may
create an invalid SPIR-V binary result.
Also, clarify the wording for where a copy of spirv-headers is expected
(to match expected capitalization).
* fix formatting
* Add unit tests, static asserts on supported SPIR-V versions
Rework the algorithm so it accepts earlier termination of the version
string. That made testing easier and more intuitive.
* Fix compilation problems
---------
Co-authored-by: mmoult <30711895+mmoult@users.noreply.github.com>
Ensure valid `OpSizeOf` instructions are not rejected by spirv-val.
Until now, validation of a valid `OpSizeOf` instruction would fail
with the message that the operand "cannot be a type".
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
The storage class restriction for `OpCooperativeMatrixLoadKHR` and
`OpCooperativeMatrixStoreKHR` comes from the Vulkan specification; as
such VUID 08973 should not be reported outside of Vulkan target
environments.
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* Fix switch case construct validation
Fixes https://crbug.com/tint/372311599
* Stop using block depth in switch validation and instead use the more
robust structured exit logic from the switch construct
* This is valid because the function has already handled the
additional valid cases for case constructs
* formatting
#5827 is broken for situations where a loaded value is stored to a pointer resulting from an OpAccessChain. Traverse access chains to find the original OpVariable to add to the worklist.
* Modify static table generation scripts to include alias lists
* Modify spv_opcode_desc_t and spv_operand_desc_t to include aliases
* Modify opcode and operand lookup by name to also search aliases
* update vim syntax generator
Adds support for `InterpolateAtCentroid`, `InterpolateAtSample`, and `InterpolateAtOffset` to the copy propagate arrays pass, as well as propagating pointers with the `Input` storage class. Also handles situations where variables should be propagated in an order different than the order that they are declared in the source.
We cannot apply the negate to an operand of an OpUDiv instead of it
result. This is because the operands of the OpUDiv are interpreted as
unsigned. We stop the optimizer from doing that.
There were no tests for distributing a negate into OpIMul, OpSDiv, and
OpUDiv. Tests are added for all of these.
Fixes#5822
* Add support for SPV_KHR_compute_shader_derivative
* Update tests for SPV_KHR_compute_shader_derivatives
---------
Co-authored-by: MagicPoncho <magicponcho@gmail.com>
Ensure that the validator rejects stores to objects of types
`OpTypeImage`, `OpTypeSampler`, `OpTypeSampledImage`,
`OpTypeAccelerationStructureKHR`, and arrays of these types, according
to `VUID-StandaloneSpirv-OpTypeImage-06924`.
Guard the check behind the before_hlsl_legalization option, as
sometimes we may have temporaries or local variables that are expected
to get optimized away.
Fixes#4796
Change-Id: Ie035c01c5f94e7bdfc16b5c6c85705f302b7bda3
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
* spirv-opt: fix crash in function declarations
Function declarations contain no blocks, so bail before segfaulting
in function optimization passes that operate on blocks.
Fixes#5795
* spirv-opt: add test for optimizing declarations
* Validate Stride operand to OpCooperativeMatrix{Load,Store}KHR
The specification requires the Stride operand for the RowMajorKHR and
ColumnMajorKHR layouts.
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
Change-Id: I51084b9b8dedebf9cab7ae25334ee56b75ef0126
* Update source/val/validate_memory.cpp
Co-authored-by: alan-baker <alanbaker@google.com>
* add test to exercise memory layout from spec constant and fix validation
Change-Id: I06d7308c4a2b62d26d69e88e03bfa009a7f8fff3
* format fixes
Change-Id: I9cbabec0ed2172dcd228cc385551cb7a5b79df1a
---------
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
Co-authored-by: alan-baker <alanbaker@google.com>
We want to be able to recover when fix storage class is not able to fix
everything, and just leave the spir-v in an invalid state. The pass
should not fail because of that.
This removes some uses of the type manager. One use could not be
removed. Instead I had to update GenCopy to not use the type manager,
and be able to copy pointers.
Part of #5691
* linker: run dedup earlier
Otherwise `linkings_to_do` might end up with stale IDs.
* linker: allow linking functions with different pointer arguments
Since llvm-17 there are no typed pointers and hte SPIRV-LLVM-Translator
doesn't know the function signature of imported functions.
I'm investigating different ways of solving this problem and adding an
option to work around it inside `spirv-link` is one of those.
The code is almost complete, just I'm having troubles constructing the
bitcast to cast the pointer parameters to the final type.
Closes: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2153
* test/linker: add tests to test the AllowPtrTypeMismatch feature
When a trying to mark store that use the same address as a load live, we
consider any use of the pointer in the store instruction enough to make
the store live. This is not correct. We should only mark the store as
live if it store to the pointer, and not storing the pointer to another
memory location.
This causes DCE to miss some dead code.
* properly handle the load and store cache control operand types
Without handling these operand types, disassembling a SPIR-V module that uses the cache control extension produces an invalid operand type error.
* add a round trip test for SPV_INTEL_cache_controls