Index: clang/lib/Basic/Targets/ARM.h =================================================================== --- clang/lib/Basic/Targets/ARM.h +++ clang/lib/Basic/Targets/ARM.h @@ -33,6 +33,11 @@ FPARMV8 = (1 << 4) }; + enum MVEMode { + MVE_INT = (1 << 0), + MVE_FP = (1 << 1) + }; + // Possible HWDiv features. enum HWDivMode { HWDivThumb = (1 << 0), HWDivARM = (1 << 1) }; @@ -56,6 +61,7 @@ unsigned ArchVersion; unsigned FPU : 5; + unsigned MVE : 2; unsigned IsAAPCS : 1; unsigned HWDiv : 2; @@ -100,6 +106,8 @@ bool isThumb() const; bool supportsThumb() const; bool supportsThumb2() const; + bool hasMVE() const; + bool hasMVEFloat() const; StringRef getCPUAttr() const; StringRef getCPUProfile() const; Index: clang/lib/Basic/Targets/ARM.cpp =================================================================== --- clang/lib/Basic/Targets/ARM.cpp +++ clang/lib/Basic/Targets/ARM.cpp @@ -146,6 +146,14 @@ } } +bool ARMTargetInfo::hasMVE() const { + return ArchKind == llvm::ARM::ArchKind::ARMV8_1MMainline && MVE != 0; +} + +bool ARMTargetInfo::hasMVEFloat() const { + return hasMVE() && (MVE & MVE_FP); +} + bool ARMTargetInfo::isThumb() const { return ArchISA == llvm::ARM::ISAKind::THUMB; } @@ -448,6 +456,14 @@ HasLegalHalfType = true; } else if (Feature == "+dotprod") { DotProd = true; + } else if (Feature == "+mve") { + DSP = 1; + MVE |= MVE_INT; + } else if (Feature == "+mve.fp") { + DSP = 1; + HasLegalHalfType = true; + MVE |= MVE_INT | MVE_FP; + HW_FP |= HW_FP_SP | HW_FP_HP; } } @@ -498,6 +514,7 @@ .Case("vfp", FPU && !SoftFloat) .Case("hwdiv", HWDiv & HWDivThumb) .Case("hwdiv-arm", HWDiv & HWDivARM) + .Case("mve", hasMVE()) .Default(false); } @@ -713,6 +730,10 @@ "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP)); } + if (hasMVE()) { + Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1"); + } + Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Twine(Opts.WCharSize ? Opts.WCharSize : 4)); Index: clang/test/Preprocessor/arm-target-features.c =================================================================== --- clang/test/Preprocessor/arm-target-features.c +++ clang/test/Preprocessor/arm-target-features.c @@ -748,6 +748,26 @@ // KRAIT-ALLOW-FP-INSTR:#define __ARM_FEATURE_DSP 1 // KRAIT-ALLOW-FP-INSTR:#define __ARM_VFPV4__ 1 +// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M %s +// CHECK-V81M: #define __ARM_ARCH 8 +// CHECK-V81M: #define __ARM_ARCH_8_1M_MAIN__ 1 +// CHECK-V81M: #define __ARM_ARCH_ISA_THUMB 2 +// CHECK-V81M: #define __ARM_ARCH_PROFILE 'M' +// CHECK-V81M-NOT: #define __ARM_FEATURE_DSP +// CHECK-V81M-NOT: #define __ARM_FEATURE_MVE +// CHECK-V81M-NOT: #define __ARM_FEATURE_SIMD32 + +// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVE %s +// CHECK-V81M-MVE: #define __ARM_FEATURE_DSP 1 +// CHECK-V81M-MVE: #define __ARM_FEATURE_MVE 1 +// CHECK-V81M-MVE: #define __ARM_FEATURE_SIMD32 1 + +// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVE-FP %s +// CHECK-V81M-MVE-FP: #define __ARM_FEATURE_DSP 1 +// CHECK-V81M-MVE-FP: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 +// CHECK-V81M-MVE-FP: #define __ARM_FEATURE_MVE 3 +// CHECK-V81M-MVE-FP: #define __ARM_FEATURE_SIMD32 1 + // RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81A %s // CHECK-V81A: #define __ARM_ARCH 8 // CHECK-V81A: #define __ARM_ARCH_8_1A__ 1