Skip to content

Commit 6b486f4

Browse files
authored
[Clang][Arch] Disable mve.fp when explicit -mfpu option (#123028)
1 parent 93d35ad commit 6b486f4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,15 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
756756
Features.push_back("-crc");
757757
}
758758

759+
// Invalid value of the __ARM_FEATURE_MVE macro when an explicit -mfpu= option
760+
// disables MVE-FP -mfpu=fpv5-d16 or -mfpu=fpv5-sp-d16 disables the scalar
761+
// half-precision floating-point operations feature. Therefore, because the
762+
// M-profile Vector Extension (MVE) floating-point feature requires the scalar
763+
// half-precision floating-point operations, this option also disables the MVE
764+
// floating-point feature: -mve.fp
765+
if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == llvm::ARM::FK_FPV5_SP_D16)
766+
Features.push_back("-mve.fp");
767+
759768
// For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes
760769
// Rather than replace within the feature vector, determine whether each
761770
// algorithm is enabled and append this to the end of the vector.

clang/test/Preprocessor/arm-target-features.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,3 +1005,11 @@
10051005
// CHECK-V83-OR-LATER: __ARM_FEATURE_COMPLEX 1
10061006
// CHECK-V81-OR-LATER: __ARM_FEATURE_QRDMX 1
10071007
// CHECK-BEFORE-V83-NOT: __ARM_FEATURE_COMPLEX 1
1008+
1009+
// Check if MVE floating-point feature is disabled (-mve.fp) during explicit fpv5-d16 or fpv5-sp-d16
1010+
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -mfpu=fpv5-d16 -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE1 %s
1011+
// CHECK-MVE1: #define __ARM_FEATURE_MVE 1
1012+
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -mfpu=fpv5-sp-d16 -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE1_2 %s
1013+
// CHECK-MVE1_2: #define __ARM_FEATURE_MVE 1
1014+
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE3 %s
1015+
// CHECK-MVE3: #define __ARM_FEATURE_MVE 3

0 commit comments

Comments
 (0)