<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99207>99207</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `WaveMatch` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
backend:SPIR-V,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `WaveMatch` clang builtin,
- [ ] Link `WaveMatch` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `WaveMatch` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `WaveMatch` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/WaveMatch.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/WaveMatch-errors.hlsl`
- [ ] Create the `int_dx_WaveMatch` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_WaveMatch` to `165` in `DXIL.td`
- [ ] Create the `WaveMatch.ll` and `WaveMatch_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Create the `int_spv_WaveMatch` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `WaveMatch` lowering and map it to `int_spv_WaveMatch` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveMatch.ll`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 165 | WaveMatch | 6.5 | ('library', 'compute', 'amplification', 'mesh', 'pixel', 'vertex', 'hull', 'domain', 'geometry', 'raygeneration', 'intersection', 'anyhit', 'closesthit', 'miss', 'callable', 'node') |
## SPIR-V
# [OpGroupNonUniformPartitionNV](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpGroupNonUniformPartitionNV):
## Description:
Reserved.
[Capability](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Capability):
**GroupNonUniformPartitionedNV**
[Reserved](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Unified).
<table>
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr>
<th>Word Count</th>
<th>Opcode</th>
<th>Results</th>
<th>Operands</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p>4</p></td>
<td class="tableblock halign-left valign-top"><p>5296</p></td>
<td
class="tableblock halign-left valign-top"><p><em><id></em><br />
<em>Result Type</em></p></td>
<td class="tableblock halign-left valign-top"><p><a
href="#ResultId"><em>Result <id></em></a></p></td>
<td
class="tableblock halign-left valign-top"><p><em><id></em><br />
<em>Value</em></p></td>
</tr>
</tbody>
</table>
## Test Case(s)
### Example 1
```hlsl
//dxc WaveMatch_test.hlsl -T lib_6_8 -enable-16bit-types -O1
export uint4 fn(float4 p1) {
return WaveMatch(p1);
}
```
### Example 2
```hlsl
//dxc WaveMatch_1_test.hlsl -T lib_6_8 -enable-16bit-types -O1
export uint4 fn(uint4 p1) {
return WaveMatch(p1);
}
```
### Example 3
```hlsl
//dxc WaveMatch_2_test.hlsl -T lib_6_8 -enable-16bit-types -O1
export uint4 fn(int4 p1) {
return WaveMatch(p1);
}
```
## HLSL:
## Syntax
```syntax
uint<4> WaveMatch(numeric<> value);
```
## Type Description
| Name | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md)| [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md) | Size |
|-------|--------------------------------------------------------------------|----------------------------------------------------------------------|------|
| *ret* | [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md) | [**uint**](../WinProg/windows-data-types) | 4 |
| *value* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | [**float**](../WinProg/windows-data-types) or [**int**](../WinProg/windows-data-types) | any |
## Minimum Shader Model
This function is supported in the following shader models.
|Shader Model | Supported|
|-------------|----------|
|[Shader Model 6.5](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_ShaderModel6_5) and higher shader models | yes |
## Shader Stages
* **Library Shader**
* [**Compute Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d11/direct3d-11-advanced-stages-compute-shader.md)
* [**Amplification Shader**](https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#amplification-shader-and-mesh-shader)
* [**Mesh Shader**](https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html)
* [**Pixel Shader**](../direct3dhlsl/dx-graphics-hlsl-writing-shaders-9.md#pixel-shader-basics)
* [**Vertex Shader**](../direct3dhlsl/dx-graphics-hlsl-writing-shaders-9.md#vertex-shader-basics)
* [**Hull Shader**](https://learn.microsoft.com/en-us/windows/uwp/graphics-concepts/hull-shader-stage--hs-)
* [**Domain Shader**](https://learn.microsoft.com/en-us/windows/uwp/graphics-concepts/domain-shader-stage--ds-)
* [**Geometry Shader**](https://learn.microsoft.com/en-us/windows/uwp/graphics-concepts/geometry-shader-stage--gs-)
* [**Raygeneration Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/ray-generation-shader.md)
* [**Intersection Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/intersection-shader.md)
* [**Anyhit Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/any-hit-shader.md)
* [**Closesthit Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/closest-hit-shader.md)
* [**Miss Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/miss-shader.md)
* [**Callable Shader**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3d12/callable-shader.md)
* **Node Shader**
## See also
- [**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
- **See [WaveMatch() function](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_ShaderModel6_5#wavematch-function)**
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWl1T27rT_zTiRmOPI5O3i1xAID3MlLZTetpzxyjWxtaDLHkkGcj59M9IsmObhNBz_nBKmcwQrda7v32RvFqFGsNzCbBA43M0vjihtS2UXmyo_ltJcbJWbLuIMBqfYzS-wFdlJaAEaTGaJD_oPVxTmxVokuBMUJnjdc2F5RKRJUrOusc-cnl3_An8wG3hWAphxC2XVnNpeGZixzqQdcYYNlBSnBWQ3Rm8UXpPtFWOtHQMf3y8-XgedKxqmVmu5JIK4bi4dFw3UFLPyWUeZ1V1SF-mGOQgj-i6LLntqbp8rHSnYvmhIb8k34KxppHo3YPIytEQWS0Vgw8gnQ5EVo3XDCKrHZjYue5Zbx0R7TzQyPU4r4ZyI9BaaXNQ_FIDtYBtAU4ul_aWPd4O3LMLZeOLq11oL7iGzP4VW3Zc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