Index: clang/include/clang/Basic/arm_sve.td =================================================================== --- clang/include/clang/Basic/arm_sve.td +++ clang/include/clang/Basic/arm_sve.td @@ -1415,6 +1415,16 @@ def SVCREATE_3 : SInst<"svcreate3[_{d}]", "3ddd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_create3", [IsTupleCreate]>; def SVCREATE_4 : SInst<"svcreate4[_{d}]", "4dddd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_create4", [IsTupleCreate]>; +let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in { +def SVUNDEF_1_BF16 : SInst<"svundef_{d}", "d", "b", MergeNone, "", [IsUndef]>; +def SVUNDEF_2_BF16 : SInst<"svundef2_{d}", "2", "b", MergeNone, "", [IsUndef]>; +def SVUNDEF_3_BF16 : SInst<"svundef3_{d}", "3", "b", MergeNone, "", [IsUndef]>; +def SVUNDEF_4_BF16 : SInst<"svundef4_{d}", "4", "b", MergeNone, "", [IsUndef]>; + +def SVCREATE_2_BF16 : SInst<"svcreate2[_{d}]", "2dd", "b", MergeNone, "aarch64_sve_tuple_create2", [IsTupleCreate]>; +def SVCREATE_3_BF16 : SInst<"svcreate3[_{d}]", "3ddd", "b", MergeNone, "aarch64_sve_tuple_create3", [IsTupleCreate]>; +def SVCREATE_4_BF16 : SInst<"svcreate4[_{d}]", "4dddd", "b", MergeNone, "aarch64_sve_tuple_create4", [IsTupleCreate]>; +} //////////////////////////////////////////////////////////////////////////////// // Vector insertion and extraction @@ -1426,6 +1436,16 @@ def SVSET_3 : SInst<"svset3[_{d}]", "33id", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_set", [IsTupleSet], [ImmCheck<1, ImmCheck0_2>]>; def SVSET_4 : SInst<"svset4[_{d}]", "44id", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tuple_set", [IsTupleSet], [ImmCheck<1, ImmCheck0_3>]>; +let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in { +def SVGET_2_BF16 : SInst<"svget2[_{d}]", "d2i", "b", MergeNone, "aarch64_sve_tuple_get", [IsTupleGet], [ImmCheck<1, ImmCheck0_1>]>; +def SVGET_3_BF16 : SInst<"svget3[_{d}]", "d3i", "b", MergeNone, "aarch64_sve_tuple_get", [IsTupleGet], [ImmCheck<1, ImmCheck0_2>]>; +def SVGET_4_BF16 : SInst<"svget4[_{d}]", "d4i", "b", MergeNone, "aarch64_sve_tuple_get", [IsTupleGet], [ImmCheck<1, ImmCheck0_3>]>; + +def SVSET_2_BF16 : SInst<"svset2[_{d}]", "22id", "b", MergeNone, "aarch64_sve_tuple_set", [IsTupleSet], [ImmCheck<1, ImmCheck0_1>]>; +def SVSET_3_BF16 : SInst<"svset3[_{d}]", "33id", "b", MergeNone, "aarch64_sve_tuple_set", [IsTupleSet], [ImmCheck<1, ImmCheck0_2>]>; +def SVSET_4_BF16 : SInst<"svset4[_{d}]", "44id", "b", MergeNone, "aarch64_sve_tuple_set", [IsTupleSet], [ImmCheck<1, ImmCheck0_3>]>; +} + //////////////////////////////////////////////////////////////////////////////// // SVE2 WhileGE/GT let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in { Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16x2_t test_svcreate2_bf16(svbfloat16_t x0, svbfloat16_t x1) +{ + // CHECK-LABEL: test_svcreate2_bf16 + // CHECK: %[[CREATE:.*]] = call @llvm.aarch64.sve.tuple.create2.nxv16bf16.nxv8bf16( %x0, %x1) + // CHECK-NEXT: ret %[[CREATE]] + // expected-warning@+1 {{implicit declaration of function 'svcreate2_bf16'}} + return SVE_ACLE_FUNC(svcreate2,_bf16,,)(x0, x1); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create3-bfloat.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16x3_t test_svcreate3_bf16(svbfloat16_t x0, svbfloat16_t x1, svbfloat16_t x2) +{ + // CHECK-LABEL: test_svcreate3_bf16 + // CHECK: %[[CREATE:.*]] = call @llvm.aarch64.sve.tuple.create3.nxv24bf16.nxv8bf16( %x0, %x1, %x2) + // CHECK-NEXT: ret %[[CREATE]] + // expected-warning@+1 {{implicit declaration of function 'svcreate3_bf16'}} + return SVE_ACLE_FUNC(svcreate3,_bf16,,)(x0, x1, x2); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create4-bfloat.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16x4_t test_svcreate4_bf16(svbfloat16_t x0, svbfloat16_t x1, svbfloat16_t x2, svbfloat16_t x4) +{ + // CHECK-LABEL: test_svcreate4_bf16 + // CHECK: %[[CREATE:.*]] = call @llvm.aarch64.sve.tuple.create4.nxv32bf16.nxv8bf16( %x0, %x1, %x2, %x4) + // CHECK-NEXT: ret %[[CREATE]] + // expected-warning@+1 {{implicit declaration of function 'svcreate4_bf16'}} + return SVE_ACLE_FUNC(svcreate4,_bf16,,)(x0, x1, x2, x4); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2-bfloat.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16_t test_svget2_bf16_0(svbfloat16x2_t tuple) +{ + // CHECK-LABEL: test_svget2_bf16_0 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv16bf16( %tuple, i32 0) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget2_bf16'}} + return SVE_ACLE_FUNC(svget2,_bf16,,)(tuple, 0); +} + +svbfloat16_t test_svget2_bf16_1(svbfloat16x2_t tuple) +{ + // CHECK-LABEL: test_svget2_bf16_1 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv16bf16( %tuple, i32 1) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget2_bf16'}} + return SVE_ACLE_FUNC(svget2,_bf16,,)(tuple, 1); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get3-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get3-bfloat.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16_t test_svget3_bf16_0(svbfloat16x3_t tuple) +{ + // CHECK-LABEL: test_svget3_bf16_0 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16( %tuple, i32 0) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget3_bf16'}} + return SVE_ACLE_FUNC(svget3,_bf16,,)(tuple, 0); +} + +svbfloat16_t test_svget3_bf16_1(svbfloat16x3_t tuple) +{ + // CHECK-LABEL: test_svget3_bf16_1 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16( %tuple, i32 1) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget3_bf16'}} + return SVE_ACLE_FUNC(svget3,_bf16,,)(tuple, 1); +} + +svbfloat16_t test_svget3_bf16_2(svbfloat16x3_t tuple) +{ + // CHECK-LABEL: test_svget3_bf16_2 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16( %tuple, i32 2) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget3_bf16'}} + return SVE_ACLE_FUNC(svget3,_bf16,,)(tuple, 2); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get4-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get4-bfloat.c @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16_t test_svget4_bf16_0(svbfloat16x4_t tuple) +{ + // CHECK-LABEL: test_svget4_bf16_0 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 0) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget4_bf16'}} + return SVE_ACLE_FUNC(svget4,_bf16,,)(tuple, 0); +} + +svbfloat16_t test_svget4_bf16_1(svbfloat16x4_t tuple) +{ + // CHECK-LABEL: test_svget4_bf16_1 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 1) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget4_bf16'}} + return SVE_ACLE_FUNC(svget4,_bf16,,)(tuple, 1); +} + +svbfloat16_t test_svget4_bf16_2(svbfloat16x4_t tuple) +{ + // CHECK-LABEL: test_svget4_bf16_2 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 2) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget4_bf16'}} + return SVE_ACLE_FUNC(svget4,_bf16,,)(tuple, 2); +} + +svbfloat16_t test_svget4_bf16_3(svbfloat16x4_t tuple) +{ + // CHECK-LABEL: test_svget4_bf16_3 + // CHECK: %[[EXT:.*]] = call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 3) + // CHECK-NEXT: ret %[[EXT]] + // expected-warning@+1 {{implicit declaration of function 'svget4_bf16'}} + return SVE_ACLE_FUNC(svget4,_bf16,,)(tuple, 3); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set2-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set2-bfloat.c @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + +svbfloat16x2_t test_svset2_bf16_0(svbfloat16x2_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset2_bf16_0 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv16bf16.nxv8bf16( %tuple, i32 0, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset2_bf16'}} + return SVE_ACLE_FUNC(svset2,_bf16,,)(tuple, 0, x); +} + +svbfloat16x2_t test_svset2_bf16_1(svbfloat16x2_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset2_bf16_1 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv16bf16.nxv8bf16( %tuple, i32 1, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset2_bf16'}} + return SVE_ACLE_FUNC(svset2,_bf16,,)(tuple, 1, x); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set3-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set3-bfloat.c @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + + +svbfloat16x3_t test_svset3_bf16_0(svbfloat16x3_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset3_bf16_0 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv24bf16.nxv8bf16( %tuple, i32 0, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset3_bf16'}} + return SVE_ACLE_FUNC(svset3,_bf16,,)(tuple, 0, x); +} + +svbfloat16x3_t test_svset3_bf16_1(svbfloat16x3_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset3_bf16_1 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv24bf16.nxv8bf16( %tuple, i32 1, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset3_bf16'}} + return SVE_ACLE_FUNC(svset3,_bf16,,)(tuple, 1, x); +} + +svbfloat16x3_t test_svset3_bf16_2(svbfloat16x3_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset3_bf16_2 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv24bf16.nxv8bf16( %tuple, i32 2, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset3_bf16'}} + return SVE_ACLE_FUNC(svset3,_bf16,,)(tuple, 2, x); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set4-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_set4-bfloat.c @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +#ifdef SVE_OVERLOADED_FORMS +// A simple used,unused... macro, long enough to represent any SVE builtin. +#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 +#else +#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 +#endif + + +svbfloat16x4_t test_svset4_bf16_0(svbfloat16x4_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset4_bf16_0 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv32bf16.nxv8bf16( %tuple, i32 0, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset4_bf16'}} + return SVE_ACLE_FUNC(svset4,_bf16,,)(tuple, 0, x); +} + +svbfloat16x4_t test_svset4_bf16_1(svbfloat16x4_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset4_bf16_1 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv32bf16.nxv8bf16( %tuple, i32 1, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset4_bf16'}} + return SVE_ACLE_FUNC(svset4,_bf16,,)(tuple, 1, x); +} + +svbfloat16x4_t test_svset4_bf16_2(svbfloat16x4_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset4_bf16_2 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv32bf16.nxv8bf16( %tuple, i32 2, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset4_bf16'}} + return SVE_ACLE_FUNC(svset4,_bf16,,)(tuple, 2, x); +} + +svbfloat16x4_t test_svset4_bf16_3(svbfloat16x4_t tuple, svbfloat16_t x) +{ + // CHECK-LABEL: test_svset4_bf16_3 + // CHECK: %[[INSERT:.*]] = call @llvm.aarch64.sve.tuple.set.nxv32bf16.nxv8bf16( %tuple, i32 3, %x) + // CHECK-NEXT: ret %[[INSERT]] + // expected-warning@+1 {{implicit declaration of function 'svset4_bf16'}} + return SVE_ACLE_FUNC(svset4,_bf16,,)(tuple, 3, x); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef-bfloat.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +svbfloat16_t test_svundef_bf16() +{ + // CHECK-LABEL: test_svundef_bf16 + // CHECK: ret undef + // expected-warning@+1 {{implicit declaration of function 'svundef_bf16'}} + return svundef_bf16(); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef2-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef2-bfloat.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +svbfloat16x2_t test_svundef2_bf16() +{ + // CHECK-LABEL: test_svundef2_bf16 + // CHECK: ret undef + // expected-warning@+1 {{implicit declaration of function 'svundef2_bf16'}} + return svundef2_bf16(); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef3-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef3-bfloat.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +svbfloat16x3_t test_svundef3_bf16() +{ + // CHECK-LABEL: test_svundef3_bf16 + // CHECK: ret undef + // expected-warning@+1 {{implicit declaration of function 'svundef3_bf16'}} + return svundef3_bf16(); +} Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef4-bfloat.c =================================================================== --- /dev/null +++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef4-bfloat.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error -verify-ignore-unexpected=note %s + +#include + +svbfloat16x4_t test_svundef4_bf16() +{ + // CHECK-LABEL: test_svundef4_bf16 + // CHECK: ret undef + // expected-warning@+1 {{implicit declaration of function 'svundef4_bf16'}} + return svundef4_bf16(); +} Index: llvm/test/CodeGen/AArch64/sve-intrinsics-create-tuple.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-intrinsics-create-tuple.ll +++ llvm/test/CodeGen/AArch64/sve-intrinsics-create-tuple.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple aarch64 -mattr=+sve -asm-verbose=1 < %s | FileCheck %s +; RUN: llc -mtriple aarch64 -mattr=+sve,+bf16 -asm-verbose=1 < %s | FileCheck %s ; ; SVCREATE2 (i8) @@ -94,6 +94,37 @@ } ; +; SVCREATE2 (bfloat) +; + +define @test_svcreate2_bf16_vec0(i1 %p, %z0, %z1) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate2_bf16_vec0: +; CHECK: // %L2 +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create2.nxv16bf16.nxv8bf16( %z0, %z1) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv16bf16( %tuple, i32 0) + ret %extract +} + +define @test_svcreate2_bf16_vec1(i1 %p, %z0, %z1) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate2_bf16_vec1: +; CHECK: // %L2 +; CHECK-NEXT: mov z0.d, z1.d +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create2.nxv16bf16.nxv8bf16( %z0, %z1) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv16bf16( %tuple, i32 1) + ret %extract +} + +; ; SVCREATE2 (i32) ; @@ -278,6 +309,7 @@ %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8i16.nxv24i16( %tuple, i32 2) ret %extract } + ; ; SVCREATE3 (half) ; @@ -309,6 +341,36 @@ ret %extract } +; +; SVCREATE3 (bfloat) +; + +define @test_svcreate3_bf16_vec0(i1 %p, %z0, %z1, %z2) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate3_bf16_vec0: +; CHECK: // %L2 +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create3.nxv24bf16.nxv8bf16( %z0, %z1, %z2) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16( %tuple, i32 0) + ret %extract +} + +define @test_svcreate3_bf16_vec2(i1 %p, %z0, %z1, %z2) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate3_bf16_vec2: +; CHECK: // %L2 +; CHECK-NEXT: mov z0.d, z2.d +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create3.nxv24bf16.nxv8bf16( %z0, %z1, %z2) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16( %tuple, i32 2) + ret %extract +} ; ; SVCREATE3 (i32) @@ -528,6 +590,37 @@ } ; +; SVCREATE4 (bfloat) +; + +define @test_svcreate4_bf16_vec0(i1 %p, %z0, %z1, %z2, %z3) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate4_bf16_vec0: +; CHECK: // %L2 +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create4.nxv32bf16.nxv8bf16( %z0, %z1, %z2, %z3) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 0) + ret %extract +} + +define @test_svcreate4_bf16_vec3(i1 %p, %z0, %z1, %z2, %z3) local_unnamed_addr #0 { +; CHECK-LABEL: test_svcreate4_bf16_vec3: +; CHECK: // %L2 +; CHECK-NEXT: mov z0.d, z3.d +; CHECK-NEXT: ret + %tuple = tail call @llvm.aarch64.sve.tuple.create4.nxv32bf16.nxv8bf16( %z0, %z1, %z2, %z3) + br i1 %p, label %L1, label %L2 +L1: + ret undef +L2: + %extract = tail call @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16( %tuple, i32 3) + ret %extract +} + +; ; SVCREATE4 (i32) ; @@ -651,11 +744,12 @@ ret %extract } -attributes #0 = { nounwind "target-features"="+sve" } +attributes #0 = { nounwind "target-features"="+sve,+bf16" } declare @llvm.aarch64.sve.tuple.create2.nxv4f64.nxv2f64(, ) declare @llvm.aarch64.sve.tuple.create2.nxv8f32.nxv4f32(, ) declare @llvm.aarch64.sve.tuple.create2.nxv16f16.nxv8f16(, ) +declare @llvm.aarch64.sve.tuple.create2.nxv16bf16.nxv8bf16(, ) declare @llvm.aarch64.sve.tuple.create2.nxv4i64.nxv2i64(, ) declare @llvm.aarch64.sve.tuple.create2.nxv8i32.nxv4i32(, ) declare @llvm.aarch64.sve.tuple.create2.nxv16i16.nxv8i16(, ) @@ -664,6 +758,7 @@ declare @llvm.aarch64.sve.tuple.create3.nxv6f64.nxv2f64(, , ) declare @llvm.aarch64.sve.tuple.create3.nxv12f32.nxv4f32(, , ) declare @llvm.aarch64.sve.tuple.create3.nxv24f16.nxv8f16(, , ) +declare @llvm.aarch64.sve.tuple.create3.nxv24bf16.nxv8bf16(, , ) declare @llvm.aarch64.sve.tuple.create3.nxv6i64.nxv2i64(, , ) declare @llvm.aarch64.sve.tuple.create3.nxv12i32.nxv4i32(, , ) declare @llvm.aarch64.sve.tuple.create3.nxv24i16.nxv8i16(, , ) @@ -672,6 +767,7 @@ declare @llvm.aarch64.sve.tuple.create4.nxv8f64.nxv2f64 (, , , ) declare @llvm.aarch64.sve.tuple.create4.nxv16f32.nxv4f32(, , , ) declare @llvm.aarch64.sve.tuple.create4.nxv32f16.nxv8f16(, , , ) +declare @llvm.aarch64.sve.tuple.create4.nxv32bf16.nxv8bf16(, , , ) declare @llvm.aarch64.sve.tuple.create4.nxv8i64.nxv2i64(, , , ) declare @llvm.aarch64.sve.tuple.create4.nxv16i32.nxv4i32(, , , ) declare @llvm.aarch64.sve.tuple.create4.nxv32i16.nxv8i16(, , , ) @@ -693,6 +789,10 @@ declare @llvm.aarch64.sve.tuple.get.nxv2i64.nxv6i64(, i32 immarg) declare @llvm.aarch64.sve.tuple.get.nxv2i64.nxv8i64(, i32 immarg) +declare @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv16bf16(, i32 immarg) +declare @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv24bf16(, i32 immarg) +declare @llvm.aarch64.sve.tuple.get.nxv8bf16.nxv32bf16(, i32 immarg) + declare @llvm.aarch64.sve.tuple.get.nxv8f16.nxv16f16(, i32 immarg) declare @llvm.aarch64.sve.tuple.get.nxv8f16.nxv24f16(, i32 immarg) declare @llvm.aarch64.sve.tuple.get.nxv8f16.nxv32f16(, i32 immarg)