diff options
author | Javed Absar <javed.absar@arm.com> | 2019-04-26 21:08:11 +0000 |
---|---|---|
committer | Javed Absar <javed.absar@arm.com> | 2019-04-26 21:08:11 +0000 |
commit | bf0e87411c9175f911b7319f03c9cde84075152b (patch) | |
tree | 8ee9e39c6fd2d888b6a737502d9b37bb45315872 /test/Sema/builtins-arm64-mte.c | |
parent | cde9c9e3de199301f9b3e23b8eacebcd86ffe502 (diff) | |
download | clang-bf0e87411c9175f911b7319f03c9cde84075152b.tar.gz |
[AArch64] Add support for MTE intrinsics
This provides intrinsics support for Memory Tagging Extension (MTE),
which was introduced with the Armv8.5-a architecture.
These intrinsics are available when __ARM_FEATURE_MEMORY_TAGGING is defined.
Each intrinsic is described in detail in the ACLE Q1 2019 documentation:
https://developer.arm.com/docs/101028/latest
Reviewed By: Tim Nortover, David Spickett
Differential Revision: https://reviews.llvm.org/D60485
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/builtins-arm64-mte.c')
-rw-r--r-- | test/Sema/builtins-arm64-mte.c | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/test/Sema/builtins-arm64-mte.c b/test/Sema/builtins-arm64-mte.c new file mode 100644 index 0000000000..4f87eb000b --- /dev/null +++ b/test/Sema/builtins-arm64-mte.c @@ -0,0 +1,136 @@ +// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -fsyntax-only -verify +// RUN: %clang_cc1 -triple arm64-arm-eabi %s -target-feature +mte -x c++ -fsyntax-only -verify +#include <stddef.h> +#include <arm_acle.h> + +int *create_tag1(int a, unsigned b) { + // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}} + return __arm_mte_create_random_tag(a,b); +} + +int *create_tag2(int *a, unsigned *b) { + // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('unsigned int *' invalid)}} + return __arm_mte_create_random_tag(a,b); +} + +int *create_tag3(const int *a, unsigned b) { +#ifdef __cplusplus + // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}} + return __arm_mte_create_random_tag(a,b); +#else + // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}} + return __arm_mte_create_random_tag(a,b); +#endif +} + +int *create_tag4(volatile int *a, unsigned b) { +#ifdef __cplusplus + // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'volatile int *'}} + return __arm_mte_create_random_tag(a,b); +#else + // expected-warning@+1 {{returning 'volatile int *' from a function with result type 'int *' discards qualifiers}} + return __arm_mte_create_random_tag(a,b); +#endif +} + +int *increment_tag1(int *a, unsigned b) { + // expected-error@+1 {{argument to '__builtin_arm_addg' must be a constant integer}} + return __arm_mte_increment_tag(a,b); +} + +int *increment_tag2(int *a) { + // expected-error@+1 {{argument value 16 is outside the valid range [0, 15]}} + return __arm_mte_increment_tag(a,16); +} + +int *increment_tag3(int *a) { + // expected-error@+1 {{argument value -1 is outside the valid range [0, 15]}} + return __arm_mte_increment_tag(a,-1); +} + +int *increment_tag4(const int *a) { +#ifdef __cplusplus + // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const int *'}} + return __arm_mte_increment_tag(a,5); +#else + // expected-warning@+1 {{returning 'const int *' from a function with result type 'int *' discards qualifiers}} + return __arm_mte_increment_tag(a,5); +#endif +} + +int *increment_tag5(const volatile int *a) { +#ifdef __cplusplus + // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}} + return __arm_mte_increment_tag(a,5); +#else + // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}} + return __arm_mte_increment_tag(a,5); +#endif +} + +unsigned exclude_tag1(int *ptr, unsigned m) { + // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}} + return __arm_mte_exclude_tag(*ptr, m); +} + +unsigned exclude_tag2(int *ptr, int *m) { + // expected-error@+1 {{second argument of MTE builtin function must be an integer type ('int *' invalid)}} + return __arm_mte_exclude_tag(ptr, m); +} + +void get_tag1() { + // expected-error@+1 {{too few arguments to function call, expected 1, have 0}} + __arm_mte_get_tag(); +} + +int *get_tag2(int ptr) { + // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}} + return __arm_mte_get_tag(ptr); +} + +int *get_tag3(const volatile int *ptr) { +#ifdef __cplusplus + // expected-error@+1 {{cannot initialize return object of type 'int *' with an rvalue of type 'const volatile int *'}} + return __arm_mte_get_tag(ptr); +#else + // expected-warning@+1 {{returning 'const volatile int *' from a function with result type 'int *' discards qualifiers}} + return __arm_mte_get_tag(ptr); +#endif +} + +void set_tag1() { + // expected-error@+1 {{too few arguments to function call, expected 1, have 0}} + __arm_mte_set_tag(); +} + +void set_tag2(int ptr) { + // expected-error@+1 {{first argument of MTE builtin function must be a pointer ('int' invalid)}} + __arm_mte_set_tag(ptr); +} + +ptrdiff_t subtract_pointers1(int a, int *b) { + // expected-error@+1 {{first argument of MTE builtin function must be a null or a pointer ('int' invalid)}} + return __arm_mte_ptrdiff(a, b); +} + +ptrdiff_t subtract_pointers2(int *a, int b) { + // expected-error@+1 {{second argument of MTE builtin function must be a null or a pointer ('int' invalid)}} + return __arm_mte_ptrdiff(a, b); +} + +ptrdiff_t subtract_pointers3(char *a, int *b) { + // expected-error@+1 {{'char *' and 'int *' are not pointers to compatible types}} + return __arm_mte_ptrdiff(a, b); +} + +ptrdiff_t subtract_pointers4(int *a, char *b) { + // expected-error@+1 {{'int *' and 'char *' are not pointers to compatible types}} + return __arm_mte_ptrdiff(a, b); +} + +#ifdef __cplusplus +ptrdiff_t subtract_pointers5() { + // expected-error@+1 {{at least one argument of MTE builtin function must be a pointer ('nullptr_t', 'nullptr_t' invalid)}} + return __arm_mte_ptrdiff(nullptr, nullptr); +} +#endif |