From c8fae2bb4afed8073096860d23e5759055c9bf88 Mon Sep 17 00:00:00 2001 From: Cullen Rhodes Date: Fri, 19 Jun 2020 12:13:00 +0000 Subject: [PATCH] [AArch64][SVE] Guard svbfloat16_t with feature macro in ACLE Summary: svbfloat16_t should only be defined if the __ARM_FEATURE_SVE_BF16 feature macro is enabled, similar to the scalar bfloat16_t type. Also, arm_bf16.h should be included in arm_sve.h when __ARM_FEATURE_BF16_SCALAR_ARITHMETIC is defined. Patch also contains a fix for ld1ro intrinsic which should be guarded on __ARM_FEATURE_SVE_BF16 rather than __ARM_FEATURE_BF16_SCALAR_ARITHMETIC, and a fix for bfmmla test which was missing __ARM_FEATURE_BF16_SCALAR_ARITHMETIC and -target-feature +bf16 in the RUN line. Reviewed By: fpetrogalli Differential Revision: https://reviews.llvm.org/D82178 --- clang/include/clang/Basic/arm_sve.td | 4 ++-- .../CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c | 4 ++-- .../aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c | 4 ++-- clang/utils/TableGen/SveEmitter.cpp | 16 +++++++++++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 818d167..ba42943 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -494,8 +494,8 @@ def SVLD4_VNUM : SInst<"svld4_vnum[_{2}]", "4Pcl", "csilUcUsUiUlhfd", MergeNone, let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64)" in { def SVLD1RO : SInst<"svld1ro[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ld1ro">; } -let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)" in { - def SVLD1RO_BF : SInst<"svld1ro[_{2}]", "dPc", "b", MergeNone, "aarch64_sve_ld1ro">; +let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && defined(__ARM_FEATURE_SVE_BF16)" in { + def SVLD1RO_BF16 : SInst<"svld1ro[_{2}]", "dPc", "b", MergeNone, "aarch64_sve_ld1ro">; } let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in { diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c index 654876b..0b9483d 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -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_SVE -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 #include diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c index 56137bd..852cf27 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -D__ARM_FEATURE_SVE_MATMUL_FP64 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -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_SVE_MATMUL_FP64 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -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_SVE_MATMUL_FP64 -D__ARM_FEATURE_SVE_BF16 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -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_SVE_MATMUL_FP64 -D__ARM_FEATURE_SVE_BF16 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -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 #include diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp index b5eed2c..a3cf384 100644 --- a/clang/utils/TableGen/SveEmitter.cpp +++ b/clang/utils/TableGen/SveEmitter.cpp @@ -1088,10 +1088,20 @@ void SVEEmitter::createHeader(raw_ostream &OS) { OS << "typedef __SVUint16_t svuint16_t;\n"; OS << "typedef __SVUint32_t svuint32_t;\n"; OS << "typedef __SVUint64_t svuint64_t;\n"; - OS << "typedef __SVFloat16_t svfloat16_t;\n"; - OS << "typedef __SVBFloat16_t svbfloat16_t;\n\n"; + OS << "typedef __SVFloat16_t svfloat16_t;\n\n"; - OS << "#ifdef __ARM_FEATURE_BF16_SCALAR_ARITHMETIC\n"; + OS << "#if defined(__ARM_FEATURE_SVE_BF16) && " + "!defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n"; + OS << "#error \"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC must be defined when " + "__ARM_FEATURE_SVE_BF16 is defined\"\n"; + OS << "#endif\n\n"; + + OS << "#if defined(__ARM_FEATURE_SVE_BF16)\n"; + OS << "typedef __SVBFloat16_t svbfloat16_t;\n"; + OS << "#endif\n\n"; + + OS << "#if defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n"; + OS << "#include \n"; OS << "typedef __bf16 bfloat16_t;\n"; OS << "#endif\n\n"; -- 2.7.4