[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:54:38 PDT 2026
================
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library %s -verify
+
+void no_arg() {
+ __builtin_hlsl_interlocked_or();
+ // expected-error at -1 {{too few arguments to function call, expected 3, have 0}}
+}
+
+void too_many_args() {
+ __builtin_hlsl_interlocked_or(0, 0, 0, 0, 0);
+ // expected-error at -1 {{too many arguments to function call, expected at most 4, have 5}}
+}
+
+void non_resource_arg() {
+ __builtin_hlsl_interlocked_or(0, 0, 0);
+ // expected-error at -1 {{used type 'int' where __hlsl_resource_t is required}}
+}
+
+void ret_no_arg() {
+ __builtin_hlsl_interlocked_or_ret_uint();
+ // expected-error at -1 {{too few arguments to function call, expected 4, have 0}}
+}
+
+void ret_too_many_args() {
+ __builtin_hlsl_interlocked_or_ret_uint(0, 0, 0, 0, 0, 0);
+ // expected-error at -1 {{too many arguments to function call, expected at most 5, have 6}}
+}
+
+void ret_non_resource_arg() {
+ __builtin_hlsl_interlocked_or_ret_uint(0, 0, 0, 0);
+ // expected-error at -1 {{used type 'int' where __hlsl_resource_t is required}}
+}
+
+// ByteAddressBuffer
+using handle_char_t = __hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::raw_buffer]] [[hlsl::contained_type(char)]];
+// Buffer<int>
+using handle_int_t = __hlsl_resource_t [[hlsl::resource_class(SRV)]] [[hlsl::contained_type(float)]];
+// RWBuffer<float>
+using handle_float_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]];
----------------
Alexander-Johnston wrote:
We have these custom resources because the builtin expects a __hlsl_resource_t type. Passing in a buffer type like Buffer<int> will give a typing error (`error: used type 'Buffer<int>' where __hlsl_resource_t is required`)
The tests are giving coverage of the various types of buffer to ensure the different sema and codegen branches are taken and the coordinates are correctly matched.
https://github.com/llvm/llvm-project/pull/180804
More information about the cfe-commits
mailing list