[ARM] Fix llvm-objdump disassembly of armv7m object files.

Apparently, the features were getting mixed up, so we'd try to
disassemble in ARM mode. Fix sub-architecture detection to compute the
correct triple if we're detecting it automatically, so the user doesn't
need to pass --triple=thumb etc.

It's possible we should be somehow tying the "+thumb-mode" target
feature more directly to Tag_CPU_arch_profile? But this seems to work
reasonably well, anyway.

While I'm here, fix up the other llvm-objdump tests that were explicitly
specifying an ARM triple; that shouldn't be necessary.

Differential Revision: https://reviews.llvm.org/D106912
This commit is contained in:
Eli Friedman 2021-07-27 12:55:37 -07:00
parent 660a56956c
commit 4adcff0b70
17 changed files with 29 additions and 20 deletions

View File

@ -538,9 +538,16 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
case ARMBuildAttrs::v6K: case ARMBuildAttrs::v6K:
Triple += "v6k"; Triple += "v6k";
break; break;
case ARMBuildAttrs::v7: case ARMBuildAttrs::v7: {
Optional<unsigned> ArchProfileAttr =
Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile);
if (ArchProfileAttr.hasValue() &&
ArchProfileAttr.getValue() == ARMBuildAttrs::MicroControllerProfile)
Triple += "v7m";
else
Triple += "v7"; Triple += "v7";
break; break;
}
case ARMBuildAttrs::v6_M: case ARMBuildAttrs::v6_M:
Triple += "v6m"; Triple += "v6m";
break; break;

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv5t-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv5t-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv5t .arch armv5t

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv5te-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv5te-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv5te .arch armv5te

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv5tej-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv5tej-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
bxj: bxj:
bxj r0 bxj r0

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6 -mattr=+vfp2 -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6 -mattr=+vfp2 -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_FP_arch, 1 // VFP2 .eabi_attribute Tag_FP_arch, 1 // VFP2

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv6 .arch armv6

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6 -mattr=+vfp2 -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6 -mattr=+vfp2 -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_FP_arch, 2 // VFP2 .eabi_attribute Tag_FP_arch, 2 // VFP2

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6k-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6k-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv6k .arch armv6k

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6m-elf -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6m-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv6m .arch armv6m

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv6t2-elf -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv6t2-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv6t2 .arch armv6t2

View File

@ -1,5 +1,4 @@
@ RUN: llvm-mc < %s -triple armv7a -mattr=+vfp3,+neon,+fp16,+hwdiv-arm,+hwdiv -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv7a -mattr=+vfp3,+neon,+fp16,+hwdiv-arm,+hwdiv -filetype=obj | llvm-objdump -d - | FileCheck %s
@ RUN: llvm-mc < %s -triple armv7a -mattr=+vfp3,+neon,+fp16,+hwdiv-arm,+hwdiv -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s --check-prefix=CHECK-THUMB
.eabi_attribute Tag_FP_arch, 0 // disallow vfp .eabi_attribute Tag_FP_arch, 0 // disallow vfp
@ -15,6 +14,7 @@ vfp3:
@CHECK-LABEL: vfp3 @CHECK-LABEL: vfp3
@CHECK-NOT: 00 0a b6 ee vmov.f32 s0, #5.000000e-01 @CHECK-NOT: 00 0a b6 ee vmov.f32 s0, #5.000000e-01
@CHECK: unknown
neon: neon:
vmla.f32 d0, d1, d2 vmla.f32 d0, d1, d2
@ -28,6 +28,7 @@ fp16:
@CHECK-LABEL: fp16 @CHECK-LABEL: fp16
@CHECK-NOT: 02 07 b6 f3 vcvt.f32.f16 q0, d2 @CHECK-NOT: 02 07 b6 f3 vcvt.f32.f16 q0, d2
@CHECK: unknown
div_arm: div_arm:
udiv r0, r1, r2 udiv r0, r1, r2
@ -41,4 +42,5 @@ div_thumb:
udiv r0, r1, r2 udiv r0, r1, r2
@CHECK-LABEL: div_thumb @CHECK-LABEL: div_thumb
@CHECK-THUMB-NOT: b1 fb f2 f0 udiv r0, r1, r2 @CHECK-NOT: b1 fb f2 f0 udiv r0, r1, r2
@CHECK: unknown

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv7a -mattr=+vfp3,+neon,+fp16,+hwdiv-arm -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv7a -mattr=+vfp3,+neon,+fp16,+hwdiv-arm -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_FP_arch, 3 // VFP3 .eabi_attribute Tag_FP_arch, 3 // VFP3
.eabi_attribute Tag_Advanced_SIMD_arch, 2 // SIMDv1 with fp16 .eabi_attribute Tag_Advanced_SIMD_arch, 2 // SIMDv1 with fp16

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv7m -mattr=+vfp4 -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv7m -mattr=+vfp4 -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_CPU_arch, 10 // v7 .eabi_attribute Tag_CPU_arch, 10 // v7
.eabi_attribute Tag_FP_arch, 0 // VFP4 .eabi_attribute Tag_FP_arch, 0 // VFP4

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv7m-elf -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv7m-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv7m .arch armv7m

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv7m -mattr=+vfp4 -filetype=obj | llvm-objdump --triple=thumb -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv7m -mattr=+vfp4 -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_CPU_arch, 10 // v7 .eabi_attribute Tag_CPU_arch, 10 // v7
.eabi_attribute Tag_CPU_arch_profile, 0x4D // 'M' profile .eabi_attribute Tag_CPU_arch_profile, 0x4D // 'M' profile

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv8a-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv8a-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.arch armv8a .arch armv8a

View File

@ -1,4 +1,4 @@
@ RUN: llvm-mc < %s -triple armv8r-elf -filetype=obj | llvm-objdump --triple=arm -d - | FileCheck %s @ RUN: llvm-mc < %s -triple armv8r-elf -filetype=obj | llvm-objdump -d - | FileCheck %s
.eabi_attribute Tag_CPU_arch, 15 // v8_R .eabi_attribute Tag_CPU_arch, 15 // v8_R
.eabi_attribute Tag_CPU_arch_profile, 0x52 // 'R' profile .eabi_attribute Tag_CPU_arch_profile, 0x52 // 'R' profile