Skip to content

Implement the or HLSL Function #125605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks
Tracked by #99235
farzonl opened this issue Feb 4, 2025 · 4 comments · Fixed by #128979
Closed
5 tasks
Tracked by #99235

Implement the or HLSL Function #125605

farzonl opened this issue Feb 4, 2025 · 4 comments · Fixed by #128979
Assignees
Labels
bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Feb 4, 2025

  • Implement the or api in hlsl_intrinsics.h
    - [ ] Investigate to see if we can use __builtin_reduce_or.
  • 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

//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 ors a vector and produces a bool vector output

Syntax

bool<> or(bool<> x, bool<> y);

Type Description

Name Template Type Component Type Size
ret scalar, vector, or matrix bool any
x scalar, vector, or matrix bool any
y scalar, vector, or matrix 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

int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;

See also

@farzonl farzonl added bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Feb 4, 2025
@farzonl farzonl moved this to Planning in HLSL Support Feb 4, 2025
@damyanp damyanp assigned raoanag and unassigned raoanag Feb 6, 2025
@metkarpoonam
Copy link
Contributor

I will begin working on this.

@damyanp damyanp moved this from Planning to Active in HLSL Support Feb 11, 2025
@farzonl farzonl linked a pull request Mar 9, 2025 that will close this issue
@farzonl
Copy link
Member Author

farzonl commented Mar 9, 2025

completed by #128979

@farzonl farzonl closed this as completed Mar 9, 2025
@github-project-automation github-project-automation bot moved this from Active to Closed in HLSL Support Mar 9, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. labels Mar 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2025

@llvm/issue-subscribers-clang-frontend

Author: Farzon Lotfi (farzonl)

- [ ] Implement the `or` api in `hlsl_intrinsics.h` ~~- [ ] Investigate to see if we can use `__builtin_reduce_or`.~~ - [ ] 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

//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 ors a vector and produces a bool vector output

Syntax

bool&lt;&gt; or(bool&lt;&gt; x, bool&lt;&gt; y);

Type Description

Name Template Type Component Type Size
ret scalar, vector, or matrix bool any
x scalar, vector, or matrix bool any
y scalar, vector, or matrix 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

int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;

See also

@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2025

@llvm/issue-subscribers-clang-codegen

Author: Farzon Lotfi (farzonl)

- [ ] Implement the `or` api in `hlsl_intrinsics.h` ~~- [ ] Investigate to see if we can use `__builtin_reduce_or`.~~ - [ ] 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

//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 ors a vector and produces a bool vector output

Syntax

bool&lt;&gt; or(bool&lt;&gt; x, bool&lt;&gt; y);

Type Description

Name Template Type Component Type Size
ret scalar, vector, or matrix bool any
x scalar, vector, or matrix bool any
y scalar, vector, or matrix 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

int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:HLSL clang:codegen IR generation bugs: mangling, exceptions, etc. clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

5 participants