brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 2ba266a Raw
57 lines · cpp
1// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -std=c++23 -fsyntax-only -verify %s2 3// This test is testing the diagnostics that Clang emits when compiling without '+sme'.4 5void streaming_compatible_def() __arm_streaming_compatible {} // OK6void streaming_def() __arm_streaming { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}}7void 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'}}10void streaming_shared_za_def() __arm_streaming __arm_inout("za") { } // expected-error {{function executed in streaming-SVE mode requires 'sme'}}11void inout_za_def() __arm_inout("za") { } // expected-error {{function using ZA state requires 'sme'}}12void 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 {} // OK16__attribute__((target("sme"))) void streaming_def_sme_attr() __arm_streaming { } // OK17__attribute__((target("sme"))) void shared_za_def_sme_attr() __arm_inout("za") { } // OK18__arm_new("za") __attribute__((target("sme"))) void new_za_def_sme_attr() {} // OK19__arm_locally_streaming __attribute__((target("sme"))) void locally_streaming_def_sme_attr() {} // OK20 21// Test that it also works with the target("sme2") attribute.22__attribute__((target("sme2"))) void streaming_def_sme2_attr() __arm_streaming { } // OK23 24// No code is generated for declarations, so it should be fine to declare using the attribute.25void streaming_compatible_decl() __arm_streaming_compatible; // OK26void streaming_decl() __arm_streaming; // OK27void shared_za_decl() __arm_inout("za"); // OK28 29void non_streaming_decl();30void non_streaming_def(void (*streaming_fn_ptr)(void) __arm_streaming,31                       void (*streaming_compatible_fn_ptr)(void) __arm_streaming_compatible) {32  streaming_compatible_decl(); // OK33  streaming_compatible_fn_ptr(); // OK34  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 38void 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(); // OK42  streaming_compatible_decl(); // OK43  streaming_compatible_fn_ptr(); // OK44  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.49int streaming_decl_ret_int() __arm_streaming;50int x = streaming_decl_ret_int(); // expected-error {{call to a streaming function requires 'sme'}}51 52void 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}57