80 changes: 80 additions & 0 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

#include <arm_sve.h>

svint8_t test_svundef_s8()
{
// CHECK-LABEL: test_svundef_s8
// CHECK: ret <vscale x 16 x i8> undef
return svundef_s8();
}

svint16_t test_svundef_s16()
{
// CHECK-LABEL: test_svundef_s16
// CHECK: ret <vscale x 8 x i16> undef
return svundef_s16();
}

svint32_t test_svundef_s32()
{
// CHECK-LABEL: test_svundef_s32
// CHECK: ret <vscale x 4 x i32> undef
return svundef_s32();
}

svint64_t test_svundef_s64()
{
// CHECK-LABEL: test_svundef_s64
// CHECK: ret <vscale x 2 x i64> undef
return svundef_s64();
}

svuint8_t test_svundef_u8()
{
// CHECK-LABEL: test_svundef_u8
// CHECK: ret <vscale x 16 x i8> undef
return svundef_u8();
}

svuint16_t test_svundef_u16()
{
// CHECK-LABEL: test_svundef_u16
// CHECK: ret <vscale x 8 x i16> undef
return svundef_u16();
}

svuint32_t test_svundef_u32()
{
// CHECK-LABEL: test_svundef_u32
// CHECK: ret <vscale x 4 x i32> undef
return svundef_u32();
}

svuint64_t test_svundef_u64()
{
// CHECK-LABEL: test_svundef_u64
// CHECK: ret <vscale x 2 x i64> undef
return svundef_u64();
}

svfloat16_t test_svundef_f16()
{
// CHECK-LABEL: test_svundef_f16
// CHECK: ret <vscale x 8 x half> undef
return svundef_f16();
}

svfloat32_t test_svundef_f32()
{
// CHECK-LABEL: test_svundef_f32
// CHECK: ret <vscale x 4 x float> undef
return svundef_f32();
}

svfloat64_t test_svundef_f64()
{
// CHECK-LABEL: test_svundef_f64
// CHECK: ret <vscale x 2 x double> undef
return svundef_f64();
}
80 changes: 80 additions & 0 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

#include <arm_sve.h>

svint8x2_t test_svundef2_s8()
{
// CHECK-LABEL: test_svundef2_s8
// CHECK: ret <vscale x 32 x i8> undef
return svundef2_s8();
}

svint16x2_t test_svundef2_s16()
{
// CHECK-LABEL: test_svundef2_s16
// CHECK: ret <vscale x 16 x i16> undef
return svundef2_s16();
}

svint32x2_t test_svundef2_s32()
{
// CHECK-LABEL: test_svundef2_s32
// CHECK: ret <vscale x 8 x i32> undef
return svundef2_s32();
}

svint64x2_t test_svundef2_s64()
{
// CHECK-LABEL: test_svundef2_s64
// CHECK: ret <vscale x 4 x i64> undef
return svundef2_s64();
}

svuint8x2_t test_svundef2_u8()
{
// CHECK-LABEL: test_svundef2_u8
// CHECK: ret <vscale x 32 x i8> undef
return svundef2_u8();
}

svuint16x2_t test_svundef2_u16()
{
// CHECK-LABEL: test_svundef2_u16
// CHECK: ret <vscale x 16 x i16> undef
return svundef2_u16();
}

svuint32x2_t test_svundef2_u32()
{
// CHECK-LABEL: test_svundef2_u32
// CHECK: ret <vscale x 8 x i32> undef
return svundef2_u32();
}

svuint64x2_t test_svundef2_u64()
{
// CHECK-LABEL: test_svundef2_u64
// CHECK: ret <vscale x 4 x i64> undef
return svundef2_u64();
}

svfloat16x2_t test_svundef2_f16()
{
// CHECK-LABEL: test_svundef2_f16
// CHECK: ret <vscale x 16 x half> undef
return svundef2_f16();
}

svfloat32x2_t test_svundef2_f32()
{
// CHECK-LABEL: test_svundef2_f32
// CHECK: ret <vscale x 8 x float> undef
return svundef2_f32();
}

svfloat64x2_t test_svundef2_f64()
{
// CHECK-LABEL: test_svundef2_f64
// CHECK: ret <vscale x 4 x double> undef
return svundef2_f64();
}
80 changes: 80 additions & 0 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

#include <arm_sve.h>

svint8x3_t test_svundef3_s8()
{
// CHECK-LABEL: test_svundef3_s8
// CHECK: ret <vscale x 48 x i8> undef
return svundef3_s8();
}

svint16x3_t test_svundef3_s16()
{
// CHECK-LABEL: test_svundef3_s16
// CHECK: ret <vscale x 24 x i16> undef
return svundef3_s16();
}

svint32x3_t test_svundef3_s32()
{
// CHECK-LABEL: test_svundef3_s32
// CHECK: ret <vscale x 12 x i32> undef
return svundef3_s32();
}

svint64x3_t test_svundef3_s64()
{
// CHECK-LABEL: test_svundef3_s64
// CHECK: ret <vscale x 6 x i64> undef
return svundef3_s64();
}

svuint8x3_t test_svundef3_u8()
{
// CHECK-LABEL: test_svundef3_u8
// CHECK: ret <vscale x 48 x i8> undef
return svundef3_u8();
}

svuint16x3_t test_svundef3_u16()
{
// CHECK-LABEL: test_svundef3_u16
// CHECK: ret <vscale x 24 x i16> undef
return svundef3_u16();
}

svuint32x3_t test_svundef3_u32()
{
// CHECK-LABEL: test_svundef3_u32
// CHECK: ret <vscale x 12 x i32> undef
return svundef3_u32();
}

svuint64x3_t test_svundef3_u64()
{
// CHECK-LABEL: test_svundef3_u64
// CHECK: ret <vscale x 6 x i64> undef
return svundef3_u64();
}

svfloat16x3_t test_svundef3_f16()
{
// CHECK-LABEL: test_svundef3_f16
// CHECK: ret <vscale x 24 x half> undef
return svundef3_f16();
}

svfloat32x3_t test_svundef3_f32()
{
// CHECK-LABEL: test_svundef3_f32
// CHECK: ret <vscale x 12 x float> undef
return svundef3_f32();
}

svfloat64x3_t test_svundef3_f64()
{
// CHECK-LABEL: test_svundef3_f64
// CHECK: ret <vscale x 6 x double> undef
return svundef3_f64();
}
80 changes: 80 additions & 0 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

#include <arm_sve.h>

svint8x4_t test_svundef4_s8()
{
// CHECK-LABEL: test_svundef4_s8
// CHECK: ret <vscale x 64 x i8> undef
return svundef4_s8();
}

svint16x4_t test_svundef4_s16()
{
// CHECK-LABEL: test_svundef4_s16
// CHECK: ret <vscale x 32 x i16> undef
return svundef4_s16();
}

svint32x4_t test_svundef4_s32()
{
// CHECK-LABEL: test_svundef4_s32
// CHECK: ret <vscale x 16 x i32> undef
return svundef4_s32();
}

svint64x4_t test_svundef4_s64()
{
// CHECK-LABEL: test_svundef4_s64
// CHECK: ret <vscale x 8 x i64> undef
return svundef4_s64();
}

svuint8x4_t test_svundef4_u8()
{
// CHECK-LABEL: test_svundef4_u8
// CHECK: ret <vscale x 64 x i8> undef
return svundef4_u8();
}

svuint16x4_t test_svundef4_u16()
{
// CHECK-LABEL: test_svundef4_u16
// CHECK: ret <vscale x 32 x i16> undef
return svundef4_u16();
}

svuint32x4_t test_svundef4_u32()
{
// CHECK-LABEL: test_svundef4_u32
// CHECK: ret <vscale x 16 x i32> undef
return svundef4_u32();
}

svuint64x4_t test_svundef4_u64()
{
// CHECK-LABEL: test_svundef4_u64
// CHECK: ret <vscale x 8 x i64> undef
return svundef4_u64();
}

svfloat16x4_t test_svundef4_f16()
{
// CHECK-LABEL: test_svundef4_f16
// CHECK: ret <vscale x 32 x half> undef
return svundef4_f16();
}

svfloat32x4_t test_svundef4_f32()
{
// CHECK-LABEL: test_svundef4_f32
// CHECK: ret <vscale x 16 x float> undef
return svundef4_f32();
}

svfloat64x4_t test_svundef4_f64()
{
// CHECK-LABEL: test_svundef4_f64
// CHECK: ret <vscale x 8 x double> undef
return svundef4_f64();
}
69 changes: 69 additions & 0 deletions clang/test/CodeGenCXX/aarch64-mangle-sve-vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,72 @@ void f10(S<__SVFloat32_t>) {}
void f11(S<__SVFloat64_t>) {}
// CHECK: _Z3f121SIu10__SVBool_tE
void f12(S<__SVBool_t>) {}

// The tuple types don't use the internal name for mangling.

// CHECK: _Z3f131SI10svint8x2_tE
void f13(S<__clang_svint8x2_t>) {}
// CHECK: _Z3f141SI10svint8x3_tE
void f14(S<__clang_svint8x3_t>) {}
// CHECK: _Z3f151SI10svint8x4_tE
void f15(S<__clang_svint8x4_t>) {}
// CHECK: _Z3f161SI11svint16x2_tE
void f16(S<__clang_svint16x2_t>) {}
// CHECK: _Z3f171SI11svint16x3_tE
void f17(S<__clang_svint16x3_t>) {}
// CHECK: _Z3f181SI11svint16x4_tE
void f18(S<__clang_svint16x4_t>) {}
// CHECK: _Z3f191SI11svint32x2_tE
void f19(S<__clang_svint32x2_t>) {}
// CHECK: _Z3f201SI11svint32x3_tE
void f20(S<__clang_svint32x3_t>) {}
// CHECK: _Z3f211SI11svint32x4_tE
void f21(S<__clang_svint32x4_t>) {}
// CHECK: _Z3f221SI11svint64x2_tE
void f22(S<__clang_svint64x2_t>) {}
// CHECK: _Z3f231SI11svint64x3_tE
void f23(S<__clang_svint64x3_t>) {}
// CHECK: _Z3f241SI11svint64x4_tE
void f24(S<__clang_svint64x4_t>) {}
// CHECK: _Z3f251SI11svuint8x2_tE
void f25(S<__clang_svuint8x2_t>) {}
// CHECK: _Z3f261SI11svuint8x3_tE
void f26(S<__clang_svuint8x3_t>) {}
// CHECK: _Z3f271SI11svuint8x4_tE
void f27(S<__clang_svuint8x4_t>) {}
// CHECK: _Z3f281SI12svuint16x2_tE
void f28(S<__clang_svuint16x2_t>) {}
// CHECK: _Z3f291SI12svuint16x3_tE
void f29(S<__clang_svuint16x3_t>) {}
// CHECK: _Z3f301SI12svuint16x4_tE
void f30(S<__clang_svuint16x4_t>) {}
// CHECK: _Z3f311SI12svuint32x2_tE
void f31(S<__clang_svuint32x2_t>) {}
// CHECK: _Z3f321SI12svuint32x3_tE
void f32(S<__clang_svuint32x3_t>) {}
// CHECK: _Z3f331SI12svuint32x4_tE
void f33(S<__clang_svuint32x4_t>) {}
// CHECK: _Z3f341SI12svuint64x2_tE
void f34(S<__clang_svuint64x2_t>) {}
// CHECK: _Z3f351SI12svuint64x3_tE
void f35(S<__clang_svuint64x3_t>) {}
// CHECK: _Z3f361SI12svuint64x4_tE
void f36(S<__clang_svuint64x4_t>) {}
// CHECK: _Z3f371SI13svfloat16x2_tE
void f37(S<__clang_svfloat16x2_t>) {}
// CHECK: _Z3f381SI13svfloat16x3_tE
void f38(S<__clang_svfloat16x3_t>) {}
// CHECK: _Z3f391SI13svfloat16x4_tE
void f39(S<__clang_svfloat16x4_t>) {}
// CHECK: _Z3f401SI13svfloat32x2_tE
void f40(S<__clang_svfloat32x2_t>) {}
// CHECK: _Z3f411SI13svfloat32x3_tE
void f41(S<__clang_svfloat32x3_t>) {}
// CHECK: _Z3f421SI13svfloat32x4_tE
void f42(S<__clang_svfloat32x4_t>) {}
// CHECK: _Z3f431SI13svfloat64x2_tE
void f43(S<__clang_svfloat64x2_t>) {}
// CHECK: _Z3f441SI13svfloat64x3_tE
void f44(S<__clang_svfloat64x3_t>) {}
// CHECK: _Z3f451SI13svfloat64x4_tE
void f45(S<__clang_svfloat64x4_t>) {}
55 changes: 43 additions & 12 deletions clang/utils/TableGen/SveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@ void SVEType::applyTypespec() {

void SVEType::applyModifier(char Mod) {
switch (Mod) {
case '2':
NumVectors = 2;
break;
case '3':
NumVectors = 3;
break;
case '4':
NumVectors = 4;
break;
case 'v':
Void = true;
break;
Expand Down Expand Up @@ -801,18 +810,7 @@ Intrinsic::Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy,
}

std::string Intrinsic::getBuiltinTypeStr() {
std::string S;

SVEType RetT = getReturnType();
// Since the return value must be one type, return a vector type of the
// appropriate width which we will bitcast. An exception is made for
// returning structs of 2, 3, or 4 vectors which are returned in a sret-like
// fashion, storing them to a pointer arg.
if (RetT.getNumVectors() > 1) {
S += "vv*"; // void result with void* first argument
} else
S += RetT.builtin_str();

std::string S = getReturnType().builtin_str();
for (unsigned I = 0; I < getNumParams(); ++I)
S += getParamType(I).builtin_str();

Expand Down Expand Up @@ -1071,6 +1069,39 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
OS << "typedef __SVFloat16_t svfloat16_t;\n";
OS << "typedef __SVFloat32_t svfloat32_t;\n";
OS << "typedef __SVFloat64_t svfloat64_t;\n";
OS << "typedef __clang_svint8x2_t svint8x2_t;\n";
OS << "typedef __clang_svint16x2_t svint16x2_t;\n";
OS << "typedef __clang_svint32x2_t svint32x2_t;\n";
OS << "typedef __clang_svint64x2_t svint64x2_t;\n";
OS << "typedef __clang_svuint8x2_t svuint8x2_t;\n";
OS << "typedef __clang_svuint16x2_t svuint16x2_t;\n";
OS << "typedef __clang_svuint32x2_t svuint32x2_t;\n";
OS << "typedef __clang_svuint64x2_t svuint64x2_t;\n";
OS << "typedef __clang_svfloat16x2_t svfloat16x2_t;\n";
OS << "typedef __clang_svfloat32x2_t svfloat32x2_t;\n";
OS << "typedef __clang_svfloat64x2_t svfloat64x2_t;\n";
OS << "typedef __clang_svint8x3_t svint8x3_t;\n";
OS << "typedef __clang_svint16x3_t svint16x3_t;\n";
OS << "typedef __clang_svint32x3_t svint32x3_t;\n";
OS << "typedef __clang_svint64x3_t svint64x3_t;\n";
OS << "typedef __clang_svuint8x3_t svuint8x3_t;\n";
OS << "typedef __clang_svuint16x3_t svuint16x3_t;\n";
OS << "typedef __clang_svuint32x3_t svuint32x3_t;\n";
OS << "typedef __clang_svuint64x3_t svuint64x3_t;\n";
OS << "typedef __clang_svfloat16x3_t svfloat16x3_t;\n";
OS << "typedef __clang_svfloat32x3_t svfloat32x3_t;\n";
OS << "typedef __clang_svfloat64x3_t svfloat64x3_t;\n";
OS << "typedef __clang_svint8x4_t svint8x4_t;\n";
OS << "typedef __clang_svint16x4_t svint16x4_t;\n";
OS << "typedef __clang_svint32x4_t svint32x4_t;\n";
OS << "typedef __clang_svint64x4_t svint64x4_t;\n";
OS << "typedef __clang_svuint8x4_t svuint8x4_t;\n";
OS << "typedef __clang_svuint16x4_t svuint16x4_t;\n";
OS << "typedef __clang_svuint32x4_t svuint32x4_t;\n";
OS << "typedef __clang_svuint64x4_t svuint64x4_t;\n";
OS << "typedef __clang_svfloat16x4_t svfloat16x4_t;\n";
OS << "typedef __clang_svfloat32x4_t svfloat32x4_t;\n";
OS << "typedef __clang_svfloat64x4_t svfloat64x4_t;\n";
OS << "typedef __SVBool_t svbool_t;\n\n";

OS << "typedef enum\n";
Expand Down