[clang] [llvm] [HLSL][DXIL] InterlockedOr and InterlockedOr64 builtins (PR #180804)
Alexander Johnston via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 09:52:02 PDT 2026
================
@@ -2017,5 +1840,87 @@ BuiltinTypeDeclBuilder::addGetDimensionsMethodForBuffer() {
.finalize();
}
+BuiltinTypeDeclBuilder &
+BuiltinTypeDeclBuilder::addInterlockedMethodsForBuffer() {
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+ ASTContext &AST = SemaRef.getASTContext();
+ QualType UIntTy = AST.UnsignedIntTy;
+ QualType IntTy = AST.IntTy;
+
+ BuiltinTypeMethodBuilder(*this, "InterlockedOr", AST.VoidTy)
+ .addParam("dest", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("value", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .callBuiltin("__builtin_hlsl_interlocked_or", QualType(), PH::Handle,
+ PH::_0, PH::_1)
+ .finalize();
+
+ BuiltinTypeMethodBuilder(*this, "InterlockedOr", AST.VoidTy)
+ .addParam("dest", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("value", IntTy, HLSLParamModifierAttr::Keyword_in)
+ .callBuiltin("__builtin_hlsl_interlocked_or", QualType(), PH::Handle,
+ PH::_0, PH::_1)
+ .finalize();
+
+ BuiltinTypeMethodBuilder(*this, "InterlockedOr", AST.VoidTy)
+ .addParam("dest", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("value", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("original_value", UIntTy, HLSLParamModifierAttr::Keyword_out)
+ .callBuiltin("__builtin_hlsl_interlocked_or_ret_uint", UIntTy, PH::Handle,
+ PH::_0, PH::_1, PH::_2)
+ .finalize();
+
+ return BuiltinTypeMethodBuilder(*this, "InterlockedOr", AST.VoidTy)
+ .addParam("dest", UIntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("value", IntTy, HLSLParamModifierAttr::Keyword_in)
+ .addParam("original_value", IntTy, HLSLParamModifierAttr::Keyword_out)
+ .callBuiltin("__builtin_hlsl_interlocked_or_ret_int", IntTy, PH::Handle,
+ PH::_0, PH::_1, PH::_2)
+ .finalize();
+}
+
+BuiltinTypeDeclBuilder &
+BuiltinTypeDeclBuilder::addInterlocked64MethodsForBuffer() {
+ ASTContext &AST = SemaRef.getASTContext();
+ VersionTuple TargetVersion = AST.getTargetInfo().getTriple().getOSVersion();
+ bool IsDXIL = AST.getTargetInfo().getTriple().getArch() == llvm::Triple::dxil;
+ if (TargetVersion < VersionTuple(6, 6) && IsDXIL)
+ return *this;
+
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+ QualType UIntTy = AST.UnsignedIntTy;
+ QualType ULongTy = AST.UnsignedLongTy;
----------------
Alexander-Johnston wrote:
Yes, I noticed a little bit of inconsistency about this throughout the HLSL backend so checked the data model. I think I landed on Long because it was more commonly used but will go back and investigate again. I'd like if it were consistently LLP64 too.
https://github.com/llvm/llvm-project/pull/180804
More information about the cfe-commits
mailing list