summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-08-09 08:52:54 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2019-08-09 08:52:54 +0000
commiteb485fbc712861e37813ff93d2711c631d162f68 (patch)
treea4d98d5f98b6ca91562dba8b5c2a3819546eb688 /clang/test/Sema
parent9693d28da8758de36adcf95614447f8ee3943ab1 (diff)
downloadbcm5719-llvm-eb485fbc712861e37813ff93d2711c631d162f68.tar.gz
bcm5719-llvm-eb485fbc712861e37813ff93d2711c631d162f68.zip
Add SVE opaque built-in types
This patch adds the SVE built-in types defined by the Procedure Call Standard for the Arm Architecture: https://developer.arm.com/docs/100986/0000 It handles the types in all relevant places that deal with built-in types. At the moment, some of these places bail out with an error, including: (1) trying to generate LLVM IR for the types (2) trying to generate debug info for the types (3) trying to mangle the types using the Microsoft C++ ABI (4) trying to @encode the types in Objective C (1) and (2) are fixed by follow-on patches but (unlike this patch) they deal mostly with target-specific LLVM details, so seemed like a logically separate change. There is currently no spec for (3) and (4), so reporting an error seems like the correct behaviour for now. The intention is that the types will become sizeless types: http://lists.llvm.org/pipermail/cfe-dev/2019-June/062523.html The main purpose of the sizeless type extension is to diagnose impossible or dangerous uses of the types, such as any that would require sizeof to have a meaningful defined value. Until then, the patch sets the alignments of the types to the values specified in the link above. It also sets the sizes of the types to zero, which is chosen to be consistently wrong and shouldn't affect correctly-written code (i.e. code that would compile even with the sizeless type extension). The patch adds the common subset of functionality needed to test the sizeless type extension on the one hand and to provide SVE intrinsic functions on the other. After this patch, the two pieces of work are essentially independent. The patch is based on one by Graham Hunter: https://reviews.llvm.org/D59245 Differential Revision: https://reviews.llvm.org/D62960 llvm-svn: 368413
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/aarch64-sve-types.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/clang/test/Sema/aarch64-sve-types.c b/clang/test/Sema/aarch64-sve-types.c
new file mode 100644
index 00000000000..f85e0f8b61f
--- /dev/null
+++ b/clang/test/Sema/aarch64-sve-types.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fsyntax-only -verify
+
+// This test is invalid under the sizeless type extension and is a stop-gap
+// until that extension is added. The test makes sure that sizeof and
+// alignof queries are handled without assertion failures, since at
+// present there is nothing to prevent such queries being made.
+//
+// Under this scheme, sizeof returns 0 for all built-in sizeless types.
+// This is compatible with correct usage but it relies on the user being
+// careful to avoid constructs that depend directly or indirectly on the
+// value of sizeof. (The sizeless type extension avoids this by treating
+// such constructs as an error.)
+
+// expected-no-diagnostics
+
+void f() {
+ int size_s8[sizeof(__SVInt8_t) == 0 ? 1 : -1];
+ int align_s8[__alignof__(__SVInt8_t) == 16 ? 1 : -1];
+
+ int size_s16[sizeof(__SVInt16_t) == 0 ? 1 : -1];
+ int align_s16[__alignof__(__SVInt16_t) == 16 ? 1 : -1];
+
+ int size_s32[sizeof(__SVInt32_t) == 0 ? 1 : -1];
+ int align_s32[__alignof__(__SVInt32_t) == 16 ? 1 : -1];
+
+ int size_s64[sizeof(__SVInt64_t) == 0 ? 1 : -1];
+ int align_s64[__alignof__(__SVInt64_t) == 16 ? 1 : -1];
+
+ int size_u8[sizeof(__SVUint8_t) == 0 ? 1 : -1];
+ int align_u8[__alignof__(__SVUint8_t) == 16 ? 1 : -1];
+
+ int size_u16[sizeof(__SVUint16_t) == 0 ? 1 : -1];
+ int align_u16[__alignof__(__SVUint16_t) == 16 ? 1 : -1];
+
+ int size_u32[sizeof(__SVUint32_t) == 0 ? 1 : -1];
+ int align_u32[__alignof__(__SVUint32_t) == 16 ? 1 : -1];
+
+ int size_u64[sizeof(__SVUint64_t) == 0 ? 1 : -1];
+ int align_u64[__alignof__(__SVUint64_t) == 16 ? 1 : -1];
+
+ int size_f16[sizeof(__SVFloat16_t) == 0 ? 1 : -1];
+ int align_f16[__alignof__(__SVFloat16_t) == 16 ? 1 : -1];
+
+ int size_f32[sizeof(__SVFloat32_t) == 0 ? 1 : -1];
+ int align_f32[__alignof__(__SVFloat32_t) == 16 ? 1 : -1];
+
+ int size_f64[sizeof(__SVFloat64_t) == 0 ? 1 : -1];
+ int align_f64[__alignof__(__SVFloat64_t) == 16 ? 1 : -1];
+
+ int size_b8[sizeof(__SVBool_t) == 0 ? 1 : -1];
+ int align_b8[__alignof__(__SVBool_t) == 2 ? 1 : -1];
+}
OpenPOWER on IntegriCloud