[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:44 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() {
----------------
Alexander-Johnston wrote:
It was just to make it a bit clearer that the 64bit functions wouldn't be added if we weren't in SM6.6 and above.
And yes, intention was to have all the interlocked functions here, but given the number and similarity of them it might be nicest to add a macro in here when we do the subsequent ones to reduce the code size.
https://github.com/llvm/llvm-project/pull/180804
More information about the cfe-commits
mailing list