| 1 |
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -std=c++23 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// This test is testing the diagnostics that Clang emits when compiling without '+sme'. |
| 4 |
|
| 5 |
void streaming_compatible_def() __arm_streaming_compatible {} // OK |
| 6 |
void streaming_def() __arm_streaming { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}} |
| 7 |
void shared_za_def() __arm_inout("za") { } // expected-error {{function using ZA state requires 'sme'}} |
| 8 |
__arm_new("za") void new_za_def() { } // expected-error {{function using ZA state requires 'sme'}} |
| 9 |
__arm_locally_streaming void locally_streaming_def() { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}} |
| 10 |
void streaming_shared_za_def() __arm_streaming __arm_inout("za") { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}} |
| 11 |
void inout_za_def() __arm_inout("za") { } // expected-error {{function using ZA state requires 'sme'}} |
| 12 |
void inout_zt0_def() __arm_inout("zt0") { } // expected-error {{function using ZT0 state requires 'sme2'}} |
| 13 |
|
| 14 |
// It should work fine when we explicitly add the target("sme") attribute. |
| 15 |
__attribute__((target("sme"))) void streaming_compatible_def_sme_attr() __arm_streaming_compatible {} // OK |
| 16 |
__attribute__((target("sme"))) void streaming_def_sme_attr() __arm_streaming { } // OK |
| 17 |
__attribute__((target("sme"))) void shared_za_def_sme_attr() __arm_inout("za") { } // OK |
| 18 |
__arm_new("za") __attribute__((target("sme"))) void new_za_def_sme_attr() {} // OK |
| 19 |
__arm_locally_streaming __attribute__((target("sme"))) void locally_streaming_def_sme_attr() {} // OK |
| 20 |
|
| 21 |
// Test that it also works with the target("sme2") attribute. |
| 22 |
__attribute__((target("sme2"))) void streaming_def_sme2_attr() __arm_streaming { } // OK |
| 23 |
|
| 24 |
// No code is generated for declarations, so it should be fine to declare using the attribute. |
| 25 |
void streaming_compatible_decl() __arm_streaming_compatible; // OK |
| 26 |
void streaming_decl() __arm_streaming; // OK |
| 27 |
void shared_za_decl() __arm_inout("za"); // OK |
| 28 |
|
| 29 |
void non_streaming_decl(); |
| 30 |
void non_streaming_def(void (*streaming_fn_ptr)(void) __arm_streaming, |
| 31 |
void (*streaming_compatible_fn_ptr)(void) __arm_streaming_compatible) { |
| 32 |
streaming_compatible_decl(); // OK |
| 33 |
streaming_compatible_fn_ptr(); // OK |
| 34 |
streaming_decl(); // expected-error {{call to a streaming function requires 'sme'}} |
| 35 |
streaming_fn_ptr(); // expected-error {{call to a streaming function requires 'sme'}} |
| 36 |
} |
| 37 |
|
| 38 |
void streaming_compatible_def2(void (*streaming_fn_ptr)(void) __arm_streaming, |
| 39 |
void (*streaming_compatible_fn_ptr)(void) __arm_streaming_compatible) |
| 40 |
__arm_streaming_compatible { |
| 41 |
non_streaming_decl(); // OK |
| 42 |
streaming_compatible_decl(); // OK |
| 43 |
streaming_compatible_fn_ptr(); // OK |
| 44 |
streaming_decl(); // expected-error {{call to a streaming function requires 'sme'}} |
| 45 |
streaming_fn_ptr(); // expected-error {{call to a streaming function requires 'sme'}} |
| 46 |
} |
| 47 |
|
| 48 |
// Also test when call-site is not a function. |
| 49 |
int streaming_decl_ret_int() __arm_streaming; |
| 50 |
int x = streaming_decl_ret_int(); // expected-error {{call to a streaming function requires 'sme'}} |
| 51 |
|
| 52 |
void sme_attrs_lambdas() { |
| 53 |
[] __arm_locally_streaming () { return; }(); // expected-error {{function executed in streaming-SVE mode requires 'sme'}} |
| 54 |
[] __arm_new("za") () { return; }(); // expected-error {{function using ZA state requires 'sme'}} |
| 55 |
[] __arm_new("zt0") () { return; }(); // expected-error {{function using ZT0 state requires 'sme2'}} |
| 56 |
} |