Index: llvm/trunk/include/llvm/Support/TargetParser.h =================================================================== --- llvm/trunk/include/llvm/Support/TargetParser.h +++ llvm/trunk/include/llvm/Support/TargetParser.h @@ -117,6 +117,7 @@ AK_ARMV7L, AK_ARMV7HL, AK_ARMV7S, + AK_ARMV7K, AK_LAST }; Index: llvm/trunk/lib/Support/TargetParser.cpp =================================================================== --- llvm/trunk/lib/Support/TargetParser.cpp +++ llvm/trunk/lib/Support/TargetParser.cpp @@ -94,6 +94,7 @@ { "armv7-r", ARM::AK_ARMV7R, "7-R", "v7r", ARMBuildAttrs::CPUArch::v7 }, { "armv7-m", ARM::AK_ARMV7M, "7-M", "v7m", ARMBuildAttrs::CPUArch::v7 }, { "armv7e-m", ARM::AK_ARMV7EM, "7E-M", "v7em", ARMBuildAttrs::CPUArch::v7E_M }, + { "armv7k", ARM::AK_ARMV7K, "7-K", "v7k", ARMBuildAttrs::CPUArch::v7 }, { "armv8-a", ARM::AK_ARMV8A, "8-A", "v8", ARMBuildAttrs::CPUArch::v8 }, { "armv8.1-a", ARM::AK_ARMV8_1A, "8.1-A", "v8.1a", ARMBuildAttrs::CPUArch::v8 }, // Non-standard Arch names. @@ -662,6 +663,7 @@ case ARM::AK_ARMV7HL: case ARM::AK_ARMV7S: case ARM::AK_ARMV7EM: + case ARM::AK_ARMV7K: return 7; case ARM::AK_ARMV8A: case ARM::AK_ARMV8_1A: Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MachO.h" +#include "llvm/Support/TargetParser.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -743,6 +744,39 @@ } } +static MachO::CPUSubTypeARM getMachOSubTypeFromArch(StringRef Arch) { + unsigned AK = ARMTargetParser::parseArch(Arch); + switch (AK) { + default: + return MachO::CPU_SUBTYPE_ARM_V7; + case ARM::AK_ARMV4T: + return MachO::CPU_SUBTYPE_ARM_V4T; + case ARM::AK_ARMV6: + case ARM::AK_ARMV6K: + return MachO::CPU_SUBTYPE_ARM_V6; + case ARM::AK_ARMV5: + return MachO::CPU_SUBTYPE_ARM_V5; + case ARM::AK_ARMV5T: + case ARM::AK_ARMV5E: + case ARM::AK_ARMV5TE: + case ARM::AK_ARMV5TEJ: + return MachO::CPU_SUBTYPE_ARM_V5TEJ; + case ARM::AK_ARMV7: + return MachO::CPU_SUBTYPE_ARM_V7; + case ARM::AK_ARMV7S: + return MachO::CPU_SUBTYPE_ARM_V7S; + case ARM::AK_ARMV7K: + return MachO::CPU_SUBTYPE_ARM_V7K; + case ARM::AK_ARMV6M: + case ARM::AK_ARMV6SM: + return MachO::CPU_SUBTYPE_ARM_V6M; + case ARM::AK_ARMV7M: + return MachO::CPU_SUBTYPE_ARM_V7M; + case ARM::AK_ARMV7EM: + return MachO::CPU_SUBTYPE_ARM_V7EM; + } +} + MCAsmBackend *llvm::createARMAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TheTriple, StringRef CPU, @@ -751,18 +785,7 @@ default: llvm_unreachable("unsupported object format"); case Triple::MachO: { - MachO::CPUSubTypeARM CS = - StringSwitch(TheTriple.getArchName()) - .Cases("armv4t", "thumbv4t", MachO::CPU_SUBTYPE_ARM_V4T) - .Cases("armv5e", "thumbv5e", MachO::CPU_SUBTYPE_ARM_V5TEJ) - .Cases("armv6", "thumbv6", MachO::CPU_SUBTYPE_ARM_V6) - .Cases("armv6m", "thumbv6m", MachO::CPU_SUBTYPE_ARM_V6M) - .Cases("armv7em", "thumbv7em", MachO::CPU_SUBTYPE_ARM_V7EM) - .Cases("armv7k", "thumbv7k", MachO::CPU_SUBTYPE_ARM_V7K) - .Cases("armv7m", "thumbv7m", MachO::CPU_SUBTYPE_ARM_V7M) - .Cases("armv7s", "thumbv7s", MachO::CPU_SUBTYPE_ARM_V7S) - .Default(MachO::CPU_SUBTYPE_ARM_V7); - + MachO::CPUSubTypeARM CS = getMachOSubTypeFromArch(TheTriple.getArchName()); return new ARMAsmBackendDarwin(T, TheTriple, CS); } case Triple::COFF: Index: llvm/trunk/test/CodeGen/ARM/MachO-subtypes.ll =================================================================== --- llvm/trunk/test/CodeGen/ARM/MachO-subtypes.ll +++ llvm/trunk/test/CodeGen/ARM/MachO-subtypes.ll @@ -0,0 +1,68 @@ +; Check that MachO ARM CPU Subtypes are respected + +; RUN: llc -mtriple=armv4t-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V4T + +; RUN: llc -mtriple=armv5-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V5 +; RUN: llc -mtriple=armv5e-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V5 +; RUN: llc -mtriple=armv5t-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V5 +; RUN: llc -mtriple=armv5te-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V5 +; RUN: llc -mtriple=armv5tej-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V5 + +; RUN: llc -mtriple=armv6-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6 +; RUN: llc -mtriple=armv6k-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6 +; RUN: llc -mtriple=thumbv6-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6 +; RUN: llc -mtriple=thumbv6k-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6 + +; RUN: llc -mtriple=armv6m-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6M +; RUN: llc -mtriple=thumbv6m-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V6M + +; RUN: llc -mtriple=armv7-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7 +; RUN: llc -mtriple=thumbv7-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7 + +; RUN: llc -mtriple=thumbv7em-apple-darwin -mcpu=cortex-m4 -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7EM +; RUN: llc -mtriple=thumbv7em-apple-darwin -mcpu=cortex-m7 -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7EM + +; RUN: llc -mtriple=armv7k-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7K +; RUN: llc -mtriple=thumbv7k-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7K + +; RUN: llc -mtriple=thumbv7m-apple-darwin -mcpu=sc300 -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7M +; RUN: llc -mtriple=thumbv7m-apple-darwin -mcpu=cortex-m3 -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7M + +; RUN: llc -mtriple=armv7s-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7S +; RUN: llc -mtriple=thumbv7s-apple-darwin -filetype=obj -o - < %s \ +; RUN: | llvm-readobj -file-headers | FileCheck %s --check-prefix=CHECK-V7S + +define void @_test() { + ret void +} + +; CHECK-V4T: CpuSubType: CPU_SUBTYPE_ARM_V4T (0x5) +; CHECK-V5: CpuSubType: CPU_SUBTYPE_ARM_V5 (0x7) +; CHECK-V6: CpuSubType: CPU_SUBTYPE_ARM_V6 (0x6) +; CHECK-V6M: CpuSubType: CPU_SUBTYPE_ARM_V6M (0xE) +; CHECK-V7: CpuSubType: CPU_SUBTYPE_ARM_V7 (0x9) +; CHECK-V7EM: CpuSubType: CPU_SUBTYPE_ARM_V7EM (0x10) +; CHECK-V7K: CpuSubType: CPU_SUBTYPE_ARM_V7K (0xC) +; CHECK-V7M: CpuSubType: CPU_SUBTYPE_ARM_V7M (0xF) +; CHECK-V7S: CpuSubType: CPU_SUBTYPE_ARM_V7S (0xB)