372 Commits

Author SHA1 Message Date
Simeon David Schaub
4c295216e4
[SPIR-V] fix return type for OpAtomicCompareExchange (#154297)
fixes #152863

Tests were written with some help from Copilot

---------

Co-authored-by: Victor Lomuller <victor@codeplay.com>
2025-08-20 13:19:45 +01:00
Steven Perron
0fb1057e40
[SPIRV] Filter disallowed extensions for env (#150051)
Not all SPIR-V extensions are allows in every environment. When we use
the `-spirv-ext=all` option, the backend currently believes that all
extensions can be used.

This commit filters out the extensions on the command line to remove
those that are not known to be allowed for the current environment.

Alternatives considered: I considered modifying the
SPIRVExtensionsParser::parse to use a different list of extensions for
"all" depending on the target triple. However that does not work because
the target triple is not available, and cannot be made available in a
reasonable way.

Fixes #147717

---------

Co-authored-by: Victor Lomuller <victor@codeplay.com>
2025-08-18 18:33:58 +00:00
Farzon Lotfi
1ca8ad29db
[SPIRV] Create a new OpSelect selector and fix register types. (#152311)
fixes #135572

There are two problems that are causing problems first register types
are copied from older registers instead of evaluating the spirv types.

Second the way OpSelect is defined in SPIRVInstrInfo.td we always
default to integer for TernOpTyped. There seems to be a problem of
multiple matches in the getMatchTable so when executeMatchTable runs we
aren't getting the right opSelect.

Correcting the tablegen wasn't very easy so instead created an emitter
for Select that evaluated the register types. this passes the original
llvm/test/CodeGen/SPIRV/instructions/select.ll tests and the new float
ones I'm adding in issue-135572-emit-float-opselect.ll
2025-08-12 17:43:30 -04:00
Nathan Gauër
6abbfcae6e
[SPIR-V] Fix OpVectorShuffle undef emission (#151993)
When an undef/poison value is lowered as a an immediate, it becomes -1.
When reaching the backend, the -1 was printed as operand to
OpVectorShuffle instead of the proper 0xFFFFFFFF.

From the SPIR-V spec:
  A Component literal may also be FFFFFFFF, which means the
  corresponding result component has no source and is undefined.
  
The reason the existing tests were passing `spirv-val` was because the
binary format was used as output, meaning the `-1` was lowered to
`0xFFFFFFFF`. But when the text format is used, `-1` is emitted as-is
which is wrong.

Fixes #151691
2025-08-12 15:50:48 +00:00
Nikita Popov
c23b4fbdbb
[IR] Remove size argument from lifetime intrinsics (#150248)
Now that #149310 has restricted lifetime intrinsics to only work on
allocas, we can also drop the explicit size argument. Instead, the size
is implied by the alloca.

This removes the ability to only mark a prefix of an alloca alive/dead.
We never used that capability, so we should remove the need to handle
that possibility everywhere (though many key places, including stack
coloring, did not actually respect this).
2025-08-08 11:09:34 +02:00
Steven Perron
25bf86fede
[SPIRV] Add pass to replace gethandlefromimplicitbinding (#146756)
The HLSL frontend generates call to the intrinsic
@llvm.spv.resource.handlefromimplicitbinding to be able to access a
resource where the set and binding were not explicitly given in the
source code. Determining the correct set and binding cannot be done
during Clang's codegen or earlier because in DXIL, they must first
remove resource that are not accessed before assigning binding locations
to the resource without an explicit binding.

We will follow their lead.

This is a change from DXC, where implicit binding for SPIR-V are
assigned before optimizations.

See https://github.com/llvm/wg-hlsl/pull/309
2025-08-06 13:10:55 -04:00
Marcos Maronas
cda4820270
[SPIRV] Do not use OpTypeRuntimeArray in Kernel env. (#149522)
Prior to this patch, when `NumElems` was 0, `OpTypeRuntimeArray` was
directly generated, but it requires `Shader` capability, so it can only
be generated if `Shader` env is being used. We have observed a pattern
of using unbound arrays that translate into `[0 x ...]` types in OpenCL,
which implies `Kernel` capability, so `OpTypeRuntimeArray` should not be
used. To prevent this scenario, this patch simplifies GEP instructions
where type is a 0-length array and the first index is also 0. In such
scenario, we effectively drop the 0-length array and the first index.

Additionally, the newly added test prior to this patch was generating a
module with both `Shader` and `Kernel` capabilities at the same time,
but they're incompatible. This patch also fixes that.

Finally, prior to this patch, the newly added test was adding `Shader`
capability to the module even with the command line flag
`--avoid-spirv-capabilities=Shader`. This patch also has a fix for that.
2025-08-05 15:10:15 +02:00
Nathan Gauër
d64371b819
[tools] Cleanup spirv-sim (#151705)
spirv-sim was supposed to be used to test cross-lane interactions. This
utility was in the end never used for testing, and as we move to proper
end-to-end testing through the llvm/offload-test-suite project, this
becomes obsolete.

Cleaning this up.
2025-08-04 10:42:33 +02:00
VISHAKH PRAKASH
1c75c829dc
[SPIRV] support for the intrinsic @llvm.fptosi.sat.* and @llvm.fptoui.sat.* (#129222)
Add support for the intrinsic @llvm.fptosi.sat.* and @llvm.fptoui.sat.*
- add legalizer for G_FPTOSI_SAT and G_FPTOUI_SAT
- add instructionSelector for G_FPTOSI_SAT and G_FPTOUI_SAT
- add function to add saturatedConversion decoration to the intrinsic

---------

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
Co-authored-by: Ebin-McW <ebin.jose@multicorewareinc.com>
Co-authored-by: Michal Paszkowski <michal@michalpaszkowski.com>
2025-08-03 23:36:54 +02:00
Ebin-McW
3a1cb68fb6
[SPIRV] Porting 4 tests from Translator (#151678)
Tests that checks:
 - Duplicate alignment
 - Duplicate types
 - Non-function storage class for global variable
 - Generating image instructions from opencl builtins

---------

Co-authored-by: Michal Paszkowski <michal@michalpaszkowski.com>
2025-08-03 22:27:36 +02:00
Aadesh Premkumar
29d9c4a6fe
[SPIRV] Addition of test files for @llvm.tan and zero_length_array.ll (#142097)
Co-authored-by: Michal Paszkowski <michal@michalpaszkowski.com>
2025-08-03 21:58:25 +02:00
Aadesh Premkumar
72fbf10755
[SPIRV] Addition of spe-constant-length-array.ll, bit_reverse_small_type.ll test files (#151645)
--Test for support for specialization constant-based variable-length 
--Test for ensuring that encoding of variable with undef initializer has
correct
--Test for bitreverse intrinsic with small types
2025-08-03 21:27:14 +02:00
Aadesh Premkumar
95e96b94d7
[SPIRV] Addition of entry-point-interfaces.ll, get_global_size.ll, layout.ll test files (#151648)
--Test that verifies correct emission of OpEntryPoint and interface
variables for SPIR-V when using multiple global constants in the kernel
entry point.
--Test that verifies code generation for get_global_size() calls.
--Test that verifies SPIR-V layout and initialization of various global
variables.
2025-08-03 21:17:55 +02:00
Ebin-McW
f3e7b355c5
[SPIRV] Test file for memcpy intrinsic (#151657)
Test lowering of llvm.memcpy intrinsics to OpCopyMemorySized with
alignment.
2025-08-03 20:57:15 +02:00
Ebin-McW
09a6a255bd
[SPIRV] Ported tests to transcoding directory from the translator (#151662)
- Checks for printf calls
- Handling of convert_* builtins and fallback
- Generation of nan and shuffle OpExtInst
2025-08-03 20:49:23 +02:00
YixingZhang007
c0fa432315
[SPIR-V] Add support for the SPIR-V extension SPV_INTEL_tensor_float32_conversion (#150090)
This PR introduces the support for the SPIR-V extension
`SPV_INTEL_tensor_float32_conversion` and the corresponding OpenCL
extension `cl_intel_tensor_float32_conversions`.
This extension introduces a rounding instruction that converts standard
32-bit floating-point values to the TensorFloat32 (TF32) format.

Reference Specification: 

https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_tensor_float32_conversion.asciidoc
2025-08-01 22:43:59 +02:00
Nathan Gauër
7c1b948e30
[SPIR-V] Fix some GEP legalization (#150943)
Pointers and GEP are untyped. SPIR-V required structured OpAccessChain.
This means the backend will have to determine a good way to retrieve the
structured access from an untyped GEP. This is not a trivial problem,
and needs to be addressed to have a robust compiler.

The issue is other workstreams relies on the access chain deduction to
work. So we have 2 options:
 - pause all dependent work until we have a good chain deduction.
- submit this limited fix to we can work on both this and other features
in parallel.

Choice we want to make is #2: submitting this **knowing this is not a
good** fix. It only increase the number of patterns we can work with,
thus allowing others to continue working on other parts of the backend.

This patch as-is has many limitations:
- If cannot robustly determine the depth of the structured access from a
GEP. Fixing this would require looking ahead at the full GEP chain.
- It cannot always figure out the correct access indices, especially
with dynamic indices. This will require frontend collaboration.

Because we know this is a temporary hack, this patch only impacts the
logical SPIR-V target. Physical SPIR-V, which can rely on pointer cast
remains on the old method.

Related to #145002
2025-08-01 11:10:35 +02:00
Aadesh Premkumar
0c3092b5b3
[SPIRV] Test for spirv-target-types.ll and unused-sret-opaque-ptr.ll (#142281)
Co-authored-by: Michal Paszkowski <michal@michalpaszkowski.com>
2025-07-31 09:11:16 -07:00
Farzon Lotfi
9de49703b8
[SPIRV] Preserve implicit bitcast (#151041)
fixes #146942 

## Issue
The cause of the bug is in InstCombine which is converting our load of
float vec4 and bitcast to i32 vec4 into one load of i32 vec4. That means
wr have to do a legalization in the spirv backend to convert back
```diff
 -  %3 = load <4 x i32>, ptr addrspace(11) %2, align 16
 +  %3 = load <4 x float>, ptr addrspace(11) %2, align 16
 +  %4 = bitcast <4 x float> %3 to <4 x i32>
```
<img width="2566" height="548" alt="Image"
src="https://github.com/user-attachments/assets/0bf8813c-70f8-47df-8207-ab7da54f5382"
/>

https://godbolt.org/z/K4GeM4fKT

## The Fix
Just removing the assert isn't enough to fix this bug. If we do so we
get an assert later
`Assertion failed: (!storageClassRequiresExplictLayout(SC)), function
getOrCreateSPIRVPointerType, file SPIRVGlobalRegistry.cpp, line 1806.`

If we just remove the assert the `CreateShuffleVector` uses the source
type via the `NewLoad` when the `Output` type needs to be the
`TargetType`.

We also can't use`CreateBitCast` That will feed the right types for the
`ShuffleVector` but it doesn't emit OpBitcast. the llvmIR isn't
translated over to MIR.

The fix then is to emit `spv_bitcast` just like what
`SPIRVEmitIntrinsics::visitBitCastInst` does.

---------

Co-authored-by: Chris B <beanz@abolishcrlf.org>
2025-07-30 14:38:33 -04:00
Fraser Cormack
638383cb71
[SPIRV] Support G_IS_FPCLASS (#148637)
This commit adds custom legalization for G_IS_FPCLASS, corresponding to
the @llvm.is.fpclass intrinsic.

The lowering strategy is essentially copied and adjusted from the
target-agnostic LegalizeHelper::lowerISFPCLASS legalization. The reason
we can't just use that directly is that the series of instruction it
expands to aren't logged in the SPIR-V backend's register/type
book-keeping, leading to issues later on in the compilation process.

As such the code introduced here was copied from the aforementioned
helper method, with some notable changes:

* Each new instruction's destination register must have a SPIR-V type
registered to it.
* Instead of a COPY from the floating-point type to integer, we issue a
SPIR-V OpBitcast directly. The backend doesn't currently appear to
handle bitcast-like COPYs.

Fixes #72862
2025-07-30 12:28:30 +01:00
Nathan Gauër
f45e6a2834
[SPIR-V] Fix emit intrinsic for resource type (#150224)
This is a quick fix to make progress to the backend until we get a
proper type scavenging system.
The previous code was only checking the type if the resource was used
once. Slightly changed the code to look to all usages, and get the first
type.

This will certainly break in other cases, but it allows us to move
forward for now until we rewrite the type scavenging to handle untyped
GEP/ptradd correctly.

Related to #145002
2025-07-24 16:45:33 +02:00
Marcos Maronas
1d02de28dd
[SPIRV] Implement translation for llvm.modf.* intrinsics (#147556)
Based on
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/3100, I'm
adding translation for `llvm.modf.*` intrinsics.
2025-07-21 14:51:34 +02:00
Wenju He
64205adc3b
[SPIR-V] Map SPIR-V friendly work-item function to built-in variables (#148567)
The mapping ensures the function is lowered to SPIR-V built-in variables
in SPIR-V. This can fix pre-commit CI fail in https://github.com/intel/llvm/pull/19359

Also add BuiltIn to SPIR-V Builtin function name in __clang_spirv_builtins.h to align with
https://github.com/llvm/llvm-project/blob/main/llvm/docs/SPIRVUsage.rst#builtin-variables
2025-07-18 08:08:25 +08:00
raoanag
056f0a10b3
[HLSL][DXIL] Implement refract intrinsic (#147342)
- [x] Implement refract using HLSL source in hlsl_intrinsics.h
- [x] Implement the refract SPIR-V target built-in in
clang/include/clang/Basic/BuiltinsSPIRV.td
- [x] Add sema checks for refract to CheckSPIRVBuiltinFunctionCall in
clang/lib/Sema/SemaSPIRV.cpp
- [x] Add codegen for spv refract to EmitSPIRVBuiltinExpr in
CGBuiltin.cpp
- [x] Add codegen tests to clang/test/CodeGenHLSL/builtins/refract.hlsl
- [x] Add spv codegen test to clang/test/CodeGenSPIRV/Builtins/refract.c
- [x] Add sema tests to clang/test/SemaHLSL/BuiltIns/refract-errors.hlsl
- [x] Add spv sema tests to
clang/test/SemaSPIRV/BuiltIns/refract-errors.c
- [x] Create the int_spv_refract intrinsic in IntrinsicsSPIRV.td
- [x] In SPIRVInstructionSelector.cpp create the refract lowering and
map it to int_spv_refract in SPIRVInstructionSelector::selectIntrinsic.
- [x] Create SPIR-V backend test case in
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/refract.ll
- [x] Check for what OpenCL support is needed.

Resolves https://github.com/llvm/llvm-project/issues/99153
2025-07-16 11:28:55 -07:00
Victor Lomuller
27c9b55659
[SPIRV] Add more id and range builtIns (#143909)
The patch adds intrinsics and lowering logic for GlobalSize,
GlobalOffset, SubgroupMaxSize, NumWorkgroups, WorkgroupSize,
WorkgroupId, LocalInvocationId, GlobalInvocationId, SubgroupSize,
NumSubgroups, SubgroupId and SubgroupLocalInvocationId SPIR-V builtins.

The patch also extend spv_thread_id, spv_group_id and
spv_thread_id_in_group to return anyint rather than i32. This allows the
intrinsics to support the opencl environment.

For each of the intrinsics, new clang builtins were added as well as a
binding for the SPIR-V "friendly" format. The original format doesn't
define such binding (uses global variables) but it is not possible to
express the Input SC which is normally required by the environement
specs, and using builtin functions is the most usual approach for other
backend and programming models.
2025-07-09 13:52:06 +01:00
Victor Lomuller
320f6820e3
[NFC][SPIRV] Fix test after spirv-val update (#147523)
ptr-annotation.ll was incorrectly applying a decoration to an unsuitable
target.

The patch changes the decoration to a valid one for the test.
2025-07-08 19:13:08 +02:00
Steven Perron
832cd2df0b
[SPIRV] Add option to add all KHR extensions (#145535)
In DXC, there is an option to enable all KHR extension. I would like to
extend the existing `-spirv-ext` backend commandline option to have the
same capability. It is like the special case for `all` execept it only
adds the `SPV_KHR_*` extensions.

Part of https://github.com/llvm/llvm-project/issues/137650.
2025-07-02 13:50:48 -04:00
Steven Perron
68173c8091
[HLSL][SPRIV] Handle signed RWBuffer correctly (#144774)
In Vulkan, the signedness of the accesses to images has to match the
signedness of the backing image.
    
See

https://docs.vulkan.org/spec/latest/chapters/textures.html#textures-input,
where it says the behaviour is undefined if
    
> the signedness of any read or sample operation does not match the
signedness of the image’s format.
    
Users who define say an `RWBuffer<int>` will create a Vulkan image with
a signed integer format. So the HLSL that is generated must match that
expecation.
    
The solution we use is to generate a `spirv.SignedImage` target type for
signed integer instead of `spirv.Image`. The two types are otherwise the
same.
    
The backend will add the `signExtend` image operand to access to the
image to ensure the image is access as a signed image.
    
Fixes #144580
2025-07-02 12:09:47 -04:00
Steven Perron
4e213159af
[SPIRV] Add FloatControl2 capability (#144371)
Add handling for FPFastMathMode in SPIR-V shaders. This is a first pass
that
simply does a direct translation when the proper extension is available.
This will unblock work for HLSL. However, it is not a full solution.

The default math mode for spir-v is determined by the API. When
targeting Vulkan many of the fast math options are assumed. We should do
something particular when targeting Vulkan.

We will also need to handle the hlsl "precise" keyword correctly when
FPFastMathMode is not available.

Unblockes https://github.com/llvm/llvm-project/issues/140739, but we are
keeing it open to track the remaining issues mentioned above.
2025-07-02 08:48:57 -04:00
Nathan Gauër
3af4d4e810
[HLSL][SPIR-V] Fix LinkageAttribute emission for BuiltIn (#144701)
BuiltIn variables were missing the visibility attribute, which caused
the Linkage capability to be emitted by the backend.
2025-06-18 17:26:40 +02:00
Steven Perron
1410e69b64
[SPIRV] Allow __spirv_SpecConstant in Vulkan shaders (#143543)
There is a builtin __spirv_SpecConstant that the SPIR-V backend expands
into a specialization constant. However, it is currently only enable for
OpenCL shaders, and not the graphic shaders.

We want to use it for specialization constants coming from HLSL, so we
are enabling it for graphic shaders as well.

Implements https://github.com/llvm/wg-hlsl/pull/287

Fixes https://github.com/llvm/llvm-project/issues/142991
2025-06-17 11:26:47 -04:00
Steven Perron
493c1612d6
[SPIRV] Fix ExecutionMode_fragment.ll test (#144116)
Fix test broken by https://github.com/llvm/llvm-project/pull/143412.
2025-06-13 13:26:26 -04:00
Steven Perron
bd33eef7f1
[HLSL][SPIRV] Use resource names (#143412)
The SPIR-V backend does not have access to the original name of a
resource in the source, so it tries to create a name. This leads to some
problems with reflection.
    
That is why start to pass the name of the resource from Clang to the
SPIR-V backend.
    
Fixes #138533
2025-06-13 12:21:38 -04:00
Nathan Gauër
ef1cb8277a
[SPIR-V] Fix ExecutionMode generation (#143888)
PR #141787 added code to emit the Fragment execution model. This
required emitting the OriginUpperLeft ExecutionMode. But this was done
by using the same codepath used for OpEntrypoint.

This has 2 issues:
- the interface variables were added to both OpEntryPoint and
OpExecutionMode.
- the existing OpExecutionMode logic was not used.

This commit fixes this, regrouping OpExecutionMode handling in one
place, and fixing bad codegen issue when interface variiables are added.
2025-06-12 18:13:29 +02:00
VISHAKH PRAKASH
fad1972d74
[SPIRV] FIX print the symbolic operand for opcode for the operation OpSpecConstantOp (#135756)
Current implementation outputs opcode is an immediate but spirv-tools
requires that the name of the operation without "Op" is needed for the
instruction OpSpecConstantOp
that is if the opcode is OpBitcast the instruction must be
`%1 = OpSpecConstantOp %6 Bitcast %17` 
instead of 
`%1 = OpBitcast %6 124 %17`

[refer this commit for more
info](0f166be68d)

---------

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
Co-authored-by: Ebin-McW <ebin.jose@multicorewareinc.com>
2025-06-11 20:13:01 +02:00
Nathan Gauër
65d530193e
[SPIR-V] Add Fragment execution model (#141787)
This commits allows the fragment execution model to be set using the
hlsl.shader attribute.

Fixes #136962
2025-06-10 15:44:11 +02:00
Nathan Gauër
6f23116507
[SPIR-V] Add Vertex execution model (#142369)
Adds backend handling of the vertex shader type compiling from HLSL.

Fixes #136961
2025-06-10 14:48:25 +02:00
Nathan Gauër
20d70196c9
[HLSL][SPIR-V] Implement vk::ext_builtin_input attribute (#138530)
This variable attribute is used in HLSL to add Vulkan specific builtins
in a shader.
The attribute is documented here:

17727e88fd/proposals/0011-inline-spirv.md

Those variable, even if marked as `static` are externally initialized by
the pipeline/driver/GPU. This is handled by moving them to a specific
address space `hlsl_input`, also added by this commit.

The design for input variables in Clang can be found here:
355771361e/proposals/0019-spirv-input-builtin.md


Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-06-04 13:22:37 +02:00
Marcos Maronas
b1703ad38d
[SPIRV] Change how to detect OpenCL/Vulkan Env and update tests accordingly. (#129689)
A new test added for spirv-friendly builtins for
SPV_KHR_bit_instructions unveiled that current mechanism to detect
whether SPIRV Backend is in OpenCL environment or Vulkan environment was
not good enough. This PR updates how to detect the environment and all
the tests accordingly.

*UPDATE*: the new approach is having a new member in `SPIRVSubtarget` to
represent the environment. It can be either OpenCL, Kernel or Unknown.
If the triple is explicit, we can directly set it at the creation of the
`SPIRVSubtarget`, otherwise we just leave it unknown until we find other
information that can help us set the environment. For now, the only
other information we use to set the environment is `hlsl.shader`
attribute at `SPIRV::ExecutionModel::ExecutionModel
getExecutionModel(const SPIRVSubtarget &STI, const Function &F)`. Going
forward we should consider also specific instructions that are
Kernel-exclusive or Shader-exclusive.

---------

Co-authored-by: marcos.maronas <mmaronas@smtp.igk.intel.com>
2025-06-03 09:50:23 -04:00
Cassandra Beckley
e60b6330ac
[SPIR-V] Consistent handling of TargetExtTypes in emit-intrinsics (#135682)
TargetExtType values are replaced with calls to
`llvm.spv.track.constant`, with a `poison` value, but
`llvm.spv.assign.type` was called with their original value. This PR
updates the `assign.type` call to be consistent with the
`track.constant` call.

Fixes #134417.

---------

Co-authored-by: Steven Perron <stevenperron@google.com>
2025-05-29 18:00:16 -04:00
Steven Perron
7c9e0d5b5d
[SPIRV] Lower spirv.Layout type (#140059)
Add this type in accordance with the [design
doc](https://github.com/llvm/wg-hlsl/pull/171).

Fixes https://github.com/llvm/llvm-project/issues/138276

---------

Co-authored-by: Nathan Gauër <github@keenuts.net>
2025-05-27 14:55:45 -04:00
Viktoria Maximova
35ed9a32d5
[SPIR-V] Remove XFAIL from the passing test (#141489)
This is a follow-up to
https://github.com/llvm/llvm-project/pull/141279#issuecomment-2909561544
2025-05-26 15:49:33 +02:00
Viktoria Maximova
435d8b12ef
Reland [SPIR-V] Support SPV_INTEL_int4 extension (#141279)
This relands #141031 

This change ensures generated SPIR-V is valid and passes machine
verification:
```
*** Bad machine code: inconsistent constant size ***
- function:    foo
- basic block: %bb.1 entry (0x9ec9298)
- instruction: %12:iid(s8) = G_CONSTANT i4 1
```
That is done by promoting `G_CONSTANT` instructions with small integer
types (e.g., `i4`) to `i8` if no extensions for "special" integer types
are enabled.
2025-05-26 14:15:27 +02:00
Dmitry Sidorov
69d6c1ff66
Revert "[SPIR-V] Support SPV_INTEL_int4 extension" (#141219)
Reverts llvm/llvm-project#141031
2025-05-23 11:45:55 +02:00
Viktoria Maximova
ced6076dfc
[SPIR-V] Support SPV_INTEL_int4 extension (#141031)
Adds support for native 4-bit type.

Spec:

https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_int4.asciidoc
2025-05-22 11:56:54 -07:00
Aadesh Premkumar
ff46a47496
[SPIRV] Addition of matrix multiply accumulate operands (#138665)
--Added Matrix multiply accumulate operands for the extension
SPV_INTEL_subgroup_matrix_multiply_accumulate
2025-05-21 14:05:56 +02:00
Yury Plyakhin
755acb174a
[SPIR-V] Add SPV_INTEL_2d_block_io extension (#140140)
Adds additional subgroup block prefetch, load,
load transposed, load transformed and store
instructions to read two-dimensional blocks of
data from a two-dimensional region of memory, or
to write two-dimensional blocks of data to a
two-dimensional region of memory.

Spec:

https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_2d_block_io.asciidoc

---------

Co-authored-by: Dmitry Sidorov <dmitry.sidorov@intel.com>
2025-05-19 19:31:15 -07:00
Justin Bogner
f695c8d529
[DirectX][SPIRV] Fix the lowering of dot4add (#140315)
There were some issues with these ops:
- The overload wasn't being specified (`dx.op.dot4AddPacked` vs
`dx.op.dot4AddPacked.i32`)
- The versioning wasn't correct (These ops were added in SM 6.4)
- The argument order was off - while the HLSL function has the
accumulator as the last argument, the DXIL op lists it first.

This fixes the DXIL.td definition and adjusts the LLVM DX and SPIRV
intrinsics to match the argument order in DXIL rather than the argument
order in HLSL.

Fixes #139018
2025-05-17 10:38:24 -07:00
Vyacheslav Levytskyy
8bd35ca412
[SPIR-V] Fix LIT tests, improve ICmpInst's type inference (#139726)
1. There are failed LIT tests at the moment due to type inference
errors.
```
Failed Tests (3):
  LLVM :: CodeGen/SPIRV/pointers/ptr-eq-types.ll
  LLVM :: CodeGen/SPIRV/validate/sycl-hier-par-basic.ll
  LLVM :: CodeGen/SPIRV/validate/sycl-tangle-group-algorithms.ll
```
This PR improves type inference to fix the errors.

2. The following tests start passing:
```
Unexpectedly Passed Tests (2):
  LLVM :: CodeGen/SPIRV/pointers/resource-addrspacecast-2.ll
  LLVM :: CodeGen/SPIRV/pointers/resource-addrspacecast.ll
```
This PR removes XFAILS in those two test cases.
2025-05-15 10:46:54 +02:00
Steven Perron
8732d0f389
[SPIRV] Don't add CPacked and Alignement decorations for Vulkan (#138711)
Packed structs get a different layout than a struct that is not packed.
This is handled by assigning different offset decoration when
appropriate. The `CPacked` decoration is not required, and is in fact
not valid when creating a shader.

Similaraly the alignment decoration is not allows when creating a
shader. We must avoid generating that decoration.

Fixes https://github.com/llvm/llvm-project/issues/138268
2025-05-14 09:18:15 -04:00