-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement the AddUint64
HLSL Function
#99205
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
Comments
The point of this intrinsic is to implement a This takes (one or two) pairs (low,high) of uint32 values and results in pairs (low,high) of uint32 values. It uses the ; add low words with carry:
%13 = call %dx.types.i32c @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 %5, i32 %1) ; UAddc(a,b)
%14 = extractvalue %dx.types.i32c %13, 0 ; i32 low word result
%15 = extractvalue %dx.types.i32c %13, 1 ; i1 carry bit
%16 = zext i1 %15 to i32 ; extend carry bit to i32
%17 = add i32 %6, %2 ; add high words
%18 = add i32 %17, %16 ; add carry bit for high word result SPIR-V has a LLVM already has an intrinsic |
I will work on this issue. |
@llvm/issue-subscribers-clang-frontend Author: Farzon Lotfi (farzonl)
- [ ] Implement `AddUint64` via use of the `__builtin_addc` clang builtin in `hlsl_intrinsics.h`
- [ ] (optional) If custom sema needed add sema checks for `AddUint64` to `CheckHLSLBuiltinFunctionCall` in `SemaHLSL.cpp`
- [ ] Try to use `llvm::Intrinsic::uadd_with_overflow` codegen for `AddUint64` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/AddUint64.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/AddUint64-errors.hlsl`
- [ ] Create the `DXILOpMapping` of `int_uadd_with_overflow` to `44` in `DXIL.td`
- [ ] Create the `AddUint64.ll` and `AddUint64_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Legalize `int_uadd_with_overflow` for SPIRV.
DirectX
SPIR-VThere is no support for Test Case(s)Example 1//dxc AddUint64_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint4 p1, uint4 p2) {
return AddUint64(p1, p2);
} HLSL:Syntaxuint<2> AddUint64(uint<2> a, uint<2> b); uint<4> AddUint64(uint<4> a, uint<4> b); Type Description
Type Description
Minimum Shader ModelThis function is supported in the following shader models.
Shader StagesSee also |
@llvm/issue-subscribers-clang-codegen Author: Farzon Lotfi (farzonl)
- [ ] Implement `AddUint64` via use of the `__builtin_addc` clang builtin in `hlsl_intrinsics.h`
- [ ] (optional) If custom sema needed add sema checks for `AddUint64` to `CheckHLSLBuiltinFunctionCall` in `SemaHLSL.cpp`
- [ ] Try to use `llvm::Intrinsic::uadd_with_overflow` codegen for `AddUint64` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/AddUint64.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/AddUint64-errors.hlsl`
- [ ] Create the `DXILOpMapping` of `int_uadd_with_overflow` to `44` in `DXIL.td`
- [ ] Create the `AddUint64.ll` and `AddUint64_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Legalize `int_uadd_with_overflow` for SPIRV.
DirectX
SPIR-VThere is no support for Test Case(s)Example 1//dxc AddUint64_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export uint4 fn(uint4 p1, uint4 p2) {
return AddUint64(p1, p2);
} HLSL:Syntaxuint<2> AddUint64(uint<2> a, uint<2> b); uint<4> AddUint64(uint<4> a, uint<4> b); Type Description
Type Description
Minimum Shader ModelThis function is supported in the following shader models.
Shader StagesSee also |
…L op (llvm#127137) Fixes llvm#99205. - Implements the HLSL intrinsic `AddUint64` used to perform unsigned 64-bit integer addition by using pairs of unsigned 32-bit integers instead of native 64-bit types - The LLVM intrinsic `uadd_with_overflow` is used in the implementation of `AddUint64` in `CGBuiltin.cpp` - The DXIL op `UAddc` was defined in `DXIL.td`, and a lowering of the LLVM intrinsic `uadd_with_overflow` to the `UAddc` DXIL op was implemented in `DXILOpLowering.cpp` Notes: - `__builtin_addc` was not able to be used to implement `AddUint64` in `hlsl_intrinsics.h` because its `CarryOut` argument is a pointer, and pointers are not supported in HLSL - A lowering of the LLVM intrinsic `uadd_with_overflow` to SPIR-V [already exists](https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/SPIRV/llvm-intrinsics/uadd.with.overflow.ll) - When lowering the LLVM intrinsic `uadd_with_overflow` to the `UAddc` DXIL op, the anonymous struct type `{ i32, i1 }` is replaced with a named struct type `%dx.types.i32c`. This aspect of the implementation may be changed when issue llvm#113192 gets addressed - Fixes issues mentioned in the comments on the original PR llvm#125319 --------- Co-authored-by: Finn Plummer <[email protected]> Co-authored-by: Farzon Lotfi <[email protected]> Co-authored-by: Chris B <[email protected]> Co-authored-by: Justin Bogner <[email protected]>
AddUint64
via use of the__builtin_addc
clang builtin inhlsl_intrinsics.h
AddUint64
toCheckHLSLBuiltinFunctionCall
inSemaHLSL.cpp
llvm::Intrinsic::uadd_with_overflow
codegen forAddUint64
inCGBuiltin.cpp
clang/test/CodeGenHLSL/builtins/AddUint64.hlsl
clang/test/SemaHLSL/BuiltIns/AddUint64-errors.hlsl
DXILOpMapping
ofint_uadd_with_overflow
to44
inDXIL.td
AddUint64.ll
andAddUint64_errors.ll
tests inllvm/test/CodeGen/DirectX/
int_uadd_with_overflow
for SPIRV.DirectX
SPIR-V
There is no support for
AddUint64
when targeting SPIR-V.Test Case(s)
Example 1
HLSL:
Syntax
uint<2> AddUint64(uint<2> a, uint<2> b);
uint<4> AddUint64(uint<4> a, uint<4> b);
Type Description
Type Description
Minimum Shader Model
This function is supported in the following shader models.
Shader Stages
See also
The text was updated successfully, but these errors were encountered: