Skip to content

Implement the AddUint64 HLSL Function #99205

Closed
@farzonl

Description

@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

DXIL Opcode DXIL OpName Shader Model Shader Stages
44 UAddc 6.0 ()

SPIR-V

There is no support for AddUint64 when targeting SPIR-V.

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:

Syntax

uint<2> AddUint64(uint<2> a, uint<2> b);
uint<4> AddUint64(uint<4> a, uint<4> b);

Type Description

Name Template Type Component Type Size
ret vector uint 2
a vector uint 2
b vector uint 2

Type Description

Name Template Type Component Type Size
ret vector uint 4
a vector uint 4
b vector uint 4

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 6 and higher shader models yes

Shader Stages

See also

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbackend:DirectXbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"metabugIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions