mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 18:26:05 +00:00

This patch adds all the language-level function keywords defined in: https://github.com/ARM-software/acle/pull/188 (merged) https://github.com/ARM-software/acle/pull/261 (update after D148700 landed) The keywords are used to control PSTATE.ZA and PSTATE.SM, which are respectively used for enabling the use of the ZA matrix array and Streaming mode. This information needs to be available on call sites, since the use of ZA or streaming mode may have to be enabled or disabled around the call-site (depending on the IR attributes set on the caller and the callee). For calls to functions from a function pointer, there is no IR declaration available, so the IR attributes must be added explicitly to the call-site. With the exception of '__arm_locally_streaming' and '__arm_new_za' the information is part of the function's interface, not just the function definition, and thus needs to be propagated through the FunctionProtoType::ExtProtoInfo. This patch adds the defintions of these keywords, as well as codegen and semantic analysis to ensure conversions between function pointers are valid and that no conflicting keywords are set. For example, '__arm_streaming' and '__arm_streaming_compatible' are mutually exclusive. Differential Revision: https://reviews.llvm.org/D127762
67 lines
3.8 KiB
C++
67 lines
3.8 KiB
C++
// Test without serialization:
|
|
// RUN: %clang_cc1 -triple aarch64 -target-feature +sme -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s
|
|
|
|
// Test with serialization:
|
|
// RUN: %clang_cc1 -std=c++20 -triple aarch64 -target-feature +sme -emit-pch -o %t %s
|
|
// RUN: %clang_cc1 -x c++ -std=c++20 -triple aarch64 -target-feature +sme -include-pch %t -ast-dump-all -ast-dump-filter Foo /dev/null \
|
|
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
|
|
// RUN: | FileCheck --strict-whitespace %s
|
|
|
|
struct Foo {
|
|
// CHECK: |-CXXRecordDecl {{.*}} implicit struct Foo
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_streaming 'void () __arm_streaming'
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_streaming_compatible 'void () __arm_streaming_compatible'
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_locally_streaming 'void ()'
|
|
// CHECK-NEXT: | `-ArmLocallyStreamingAttr
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_shared_za 'void () __arm_shared_za'
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_new_za 'void ()'
|
|
// CHECK-NEXT: | `-ArmNewZAAttr
|
|
// CHECK-NEXT: |-CXXMethodDecl {{.*}} f_preserves_za 'void () __arm_preserves_za'
|
|
void f_streaming() __arm_streaming;
|
|
void f_streaming_compatible() __arm_streaming_compatible;
|
|
__arm_locally_streaming void f_locally_streaming();
|
|
void f_shared_za() __arm_shared_za;
|
|
__arm_new_za void f_new_za();
|
|
void f_preserves_za() __arm_preserves_za;
|
|
|
|
|
|
// CHECK: |-CXXMethodDecl {{.*}} test_lambda 'int (int)' implicit-inline
|
|
// CHECK: `-CompoundStmt
|
|
// CHECK-NEXT: |-DeclStmt
|
|
// CHECK-NEXT: | `-VarDecl
|
|
// CHECK-NEXT: | `-LambdaExpr
|
|
// CHECK-NEXT: | |-CXXRecordDecl
|
|
// CHECK: | | |-CXXMethodDecl {{.*}} used constexpr operator() 'int (int) __arm_streaming const' inline
|
|
// CHECK: | | |-CXXConversionDecl {{.*}} implicit constexpr operator int (*)(int) __arm_streaming 'int (*() const noexcept)(int) __arm_streaming' inline
|
|
// CHECK: | | |-CXXMethodDecl {{.*}} implicit __invoke 'int (int) __arm_streaming' static inline
|
|
// CHECK: `-ReturnStmt
|
|
// CHECK: `-CXXOperatorCallExpr
|
|
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'int (*)(int) __arm_streaming const' <FunctionToPointerDecay>
|
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int (int) __arm_streaming const' lvalue CXXMethod {{.*}} 'operator()' 'int (int) __arm_streaming const'
|
|
int test_lambda(int x) {
|
|
auto F = [](int x) __arm_streaming { return x; };
|
|
return F(x);
|
|
}
|
|
|
|
// CHECK: |-TypedefDecl {{.*}} referenced s_ptrty 'void (*)(int, int) __arm_streaming'
|
|
// CHECK-NEXT: | `-PointerType {{.*}} 'void (*)(int, int) __arm_streaming'
|
|
// CHECK-NEXT: | `-ParenType {{.*}} 'void (int, int) __arm_streaming' sugar
|
|
// CHECK-NEXT: | `-FunctionProtoType {{.*}} 'void (int, int) __arm_streaming' cdecl
|
|
typedef void (*s_ptrty) (int, int) __arm_streaming;
|
|
|
|
// CHECK: `-CXXMethodDecl {{.*}} test_streaming_ptrty 'void (s_ptrty, int, int)' implicit-inline
|
|
// CHECK-NEXT: |-ParmVarDecl {{.*}} used f 's_ptrty':'void (*)(int, int) __arm_streaming'
|
|
// CHECK-NEXT: |-ParmVarDecl {{.*}} used x 'int'
|
|
// CHECK-NEXT: |-ParmVarDecl {{.*}} used y 'int'
|
|
// CHECK: `-CompoundStmt
|
|
// CHECK-NEXT: `-ReturnStmt
|
|
// CHECK-NEXT: `-CallExpr
|
|
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 's_ptrty':'void (*)(int, int) __arm_streaming' <LValueToRValue>
|
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} 's_ptrty':'void (*)(int, int) __arm_streaming' lvalue ParmVar {{.*}} 'f' 's_ptrty':'void (*)(int, int) __arm_streaming'
|
|
// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
|
|
// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'
|
|
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
|
|
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'y' 'int'
|
|
void test_streaming_ptrty(s_ptrty f, int x, int y) { return f(x, y); };
|
|
};
|