Skip to content

[llvm][ARM] Emit MVE .arch_extension after .fpu directive if it does not include MVE features #71545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12648,6 +12648,9 @@ bool ARMAsmParser::enableArchExtFeature(StringRef Name, SMLoc &ExtLoc) {
{ARM::AEK_CRYPTO,
{Feature_HasV8Bit},
{ARM::FeatureCrypto, ARM::FeatureNEON, ARM::FeatureFPARMv8}},
{(ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP),
{Feature_HasV8_1MMainlineBit},
{ARM::HasMVEFloatOps}},
{ARM::AEK_FP,
{Feature_HasV8Bit},
{ARM::FeatureVFP2_SP, ARM::FeatureFPARMv8}},
Expand Down
16 changes: 10 additions & 6 deletions llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,18 @@ void ARMTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI) {
? ARMBuildAttrs::AllowNeonARMv8_1a
: ARMBuildAttrs::AllowNeonARMv8);
} else {
if (STI.hasFeature(ARM::FeatureFPARMv8_D16_SP))
if (STI.hasFeature(ARM::FeatureFPARMv8_D16_SP)) {
// FPv5 and FP-ARMv8 have the same instructions, so are modeled as one
// FPU, but there are two different names for it depending on the CPU.
emitFPU(STI.hasFeature(ARM::FeatureD32)
? ARM::FK_FP_ARMV8
: (STI.hasFeature(ARM::FeatureFP64) ? ARM::FK_FPV5_D16
: ARM::FK_FPV5_SP_D16));
else if (STI.hasFeature(ARM::FeatureVFP4_D16_SP))
if (STI.hasFeature(ARM::FeatureD32))
emitFPU(ARM::FK_FP_ARMV8);
else {
emitFPU(STI.hasFeature(ARM::FeatureFP64) ? ARM::FK_FPV5_D16
: ARM::FK_FPV5_SP_D16);
if (STI.hasFeature(ARM::HasMVEFloatOps))
emitArchExtension(ARM::AEK_SIMD | ARM::AEK_DSP | ARM::AEK_FP);
}
} else if (STI.hasFeature(ARM::FeatureVFP4_D16_SP))
emitFPU(STI.hasFeature(ARM::FeatureD32)
? ARM::FK_VFPV4
: (STI.hasFeature(ARM::FeatureFP64) ? ARM::FK_VFPV4_D16
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/CodeGen/ARM/arm-v8.1m-check-mve-extension.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m85 --float-abi=hard %s -o - | FileCheck %s
; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m55 --float-abi=hard %s -o - | FileCheck %s

; CHECK: .fpu fpv5-d16
; CHECK-NEXT: .arch_extension mve.fp

define <4 x float> @vsubf32(<4 x float> %A, <4 x float> %B) {
; CHECK-LABEL: vsubf32:
; CHECK: @ %bb.0:
; CHECK-NEXT: vsub.f32 q0, q0, q1
; CHECK-NEXT: bx lr
%tmp3 = fsub <4 x float> %A, %B
ret <4 x float> %tmp3
}
6 changes: 6 additions & 0 deletions llvm/test/MC/ARM/arm-v8.1m-check-mve-extension.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: llvm-mc -triple thumbv8.1m.main-none-eabi -filetype asm -o - %s 2>&1 | FileCheck %s

.arch_extension mve.fp
vsub.f32 q0, q0, q1
// CHECK: vsub.f32 q0, q0, q1