Issue |
125605
|
Summary |
Implement the `or` HLSL Function
|
Labels |
metabug,
HLSL,
bot:HLSL
|
Assignees |
|
Reporter |
farzonl
|
- [ ] Implement the `or` api in `hlsl_intrinsics.h`
- [ ] If a clang builtin is needed add sema checks for `or` to `CheckHLSLBuiltinFunctionCall` in `SemaHLSL.cpp`
- [ ] If codegen is needed, add codegen for `or` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/or.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/or-errors.hlsl`
## DirectX
There were no DXIL opcodes found for `or`.
## SPIR-V
There were no SPIR-V opcodes found for `or`.
## Test Case(s)
### Example 1
```hlsl
//dxc or_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export bool4 fn(bool4 p1, bool4 p2) {
return or(p1, p2);
}
```
## HLSL:
Logically `or`s a vector and produces a bool vector output
## Syntax
```syntax
bool<> or(bool<> x, bool<> y);
```
## 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* | [**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) | **bool** | any |
| *x* | [**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) | **bool** | any |
| *y* | [**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) | **bool** | any |
## Minimum Shader Model
This function is supported in the following shader models.
|Shader Model | Supported|
|-------------|----------|
|All Shader Models with HLSL 2021 Language Mode | yes |
## Shader Stages
**All Shader Stages**
## Remarks
In HLSL 2021 `or(X, Y);` is a replacement for
```hlsl
int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;
```
## See also
- [**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
- **See [HLSL 2021 Logical operation short-circuiting for scalars](https://github.com/microsoft/DirectXShaderCompiler/wiki/HLSL-2021#logical-operation-short-circuiting-for-scalars)**
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs