[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)
Greg Roth via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 14:34:23 PST 2024
================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify
+
+using handle_t = __hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(int)]];
+
+void test_args(int x, bool b) {
+ handle_t res;
+
+ // expected-error at +1 {{too few arguments to function call, expected 2, have 1}}
+ __builtin_hlsl_buffer_update_counter(x);
+
+ // expected-error at +1 {{too many arguments to function call, expected 2, have 3}}
+ __builtin_hlsl_buffer_update_counter(x, x, x);
+
+ // expected-error at +1 {{used type 'int' where __hlsl_resource_t is required}}
+ __builtin_hlsl_buffer_update_counter(x, x);
+
+ // expected-error at +1 {{argument 1 must be constant integer 1 or -1}}
+ __builtin_hlsl_buffer_update_counter(res, x);
+
+ // expected-error at +1 {{argument 1 must be constant integer 1 or -1}}
+ __builtin_hlsl_buffer_update_counter(res, 10);
----------------
pow2clk wrote:
Might want a test that integer values are required since there is a unique message and check function for it. Might also want a test that proper usage of `__builtin_hlsl_buffer_update_counter` produces no diagnostics.
https://github.com/llvm/llvm-project/pull/114148
More information about the cfe-commits
mailing list