mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.
This also teaches MachO writers/readers about the MachO cpu subtype, beyond the minimal subtype reader support present at the moment. This also defines a preprocessor macro to allow users to distinguish __arm64__ from __arm64e__. arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing pointer-authentication codegen. It also currently defaults to ios14 and macos11. Differential Revision: https://reviews.llvm.org/D87095
This commit is contained in:
parent
e737a423ce
commit
fe6a3c2668
@ -129,6 +129,8 @@ public:
|
||||
ARMSubArch_v5te,
|
||||
ARMSubArch_v4t,
|
||||
|
||||
AArch64SubArch_arm64e,
|
||||
|
||||
KalimbaSubArch_v3,
|
||||
KalimbaSubArch_v4,
|
||||
KalimbaSubArch_v5,
|
||||
@ -777,6 +779,12 @@ public:
|
||||
return getArch() == Triple::csky;
|
||||
}
|
||||
|
||||
/// Tests whether the target is the Apple "arm64e" AArch64 subarch.
|
||||
bool isArm64e() const {
|
||||
return getArch() == Triple::aarch64 &&
|
||||
getSubArch() == Triple::AArch64SubArch_arm64e;
|
||||
}
|
||||
|
||||
/// Tests whether the target supports comdat
|
||||
bool supportsCOMDAT() const {
|
||||
return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
|
||||
|
@ -58,7 +58,7 @@ static MachO::CPUSubTypeARM64 getARM64SubType(const Triple &T) {
|
||||
assert(T.isAArch64());
|
||||
if (T.isArch32Bit())
|
||||
return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
|
||||
if (T.getArchName() == "arm64e")
|
||||
if (T.isArm64e())
|
||||
return MachO::CPU_SUBTYPE_ARM64E;
|
||||
|
||||
return MachO::CPU_SUBTYPE_ARM64_ALL;
|
||||
|
@ -377,6 +377,8 @@ bool LTOCodeGenerator::determineTarget() {
|
||||
MCpu = "core2";
|
||||
else if (Triple.getArch() == llvm::Triple::x86)
|
||||
MCpu = "yonah";
|
||||
else if (Triple.isArm64e())
|
||||
MCpu = "apple-a12";
|
||||
else if (Triple.getArch() == llvm::Triple::aarch64 ||
|
||||
Triple.getArch() == llvm::Triple::aarch64_32)
|
||||
MCpu = "cyclone";
|
||||
|
@ -222,6 +222,8 @@ LTOModule::makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options,
|
||||
CPU = "core2";
|
||||
else if (Triple.getArch() == llvm::Triple::x86)
|
||||
CPU = "yonah";
|
||||
else if (Triple.isArm64e())
|
||||
CPU = "apple-a12";
|
||||
else if (Triple.getArch() == llvm::Triple::aarch64 ||
|
||||
Triple.getArch() == llvm::Triple::aarch64_32)
|
||||
CPU = "cyclone";
|
||||
|
@ -2694,6 +2694,12 @@ Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "arm64";
|
||||
return Triple("arm64-apple-darwin");
|
||||
case MachO::CPU_SUBTYPE_ARM64E:
|
||||
if (McpuDefault)
|
||||
*McpuDefault = "apple-a12";
|
||||
if (ArchFlag)
|
||||
*ArchFlag = "arm64e";
|
||||
return Triple("arm64e-apple-darwin");
|
||||
default:
|
||||
return Triple();
|
||||
}
|
||||
@ -2741,13 +2747,28 @@ bool MachOObjectFile::isValidArch(StringRef ArchFlag) {
|
||||
}
|
||||
|
||||
ArrayRef<StringRef> MachOObjectFile::getValidArchs() {
|
||||
static const std::array<StringRef, 17> validArchs = {{
|
||||
"i386", "x86_64", "x86_64h", "armv4t", "arm", "armv5e",
|
||||
"armv6", "armv6m", "armv7", "armv7em", "armv7k", "armv7m",
|
||||
"armv7s", "arm64", "arm64_32", "ppc", "ppc64",
|
||||
static const std::array<StringRef, 18> ValidArchs = {{
|
||||
"i386",
|
||||
"x86_64",
|
||||
"x86_64h",
|
||||
"armv4t",
|
||||
"arm",
|
||||
"armv5e",
|
||||
"armv6",
|
||||
"armv6m",
|
||||
"armv7",
|
||||
"armv7em",
|
||||
"armv7k",
|
||||
"armv7m",
|
||||
"armv7s",
|
||||
"arm64",
|
||||
"arm64e",
|
||||
"arm64_32",
|
||||
"ppc",
|
||||
"ppc64",
|
||||
}};
|
||||
|
||||
return validArchs;
|
||||
return ValidArchs;
|
||||
}
|
||||
|
||||
Triple::ArchType MachOObjectFile::getArch() const {
|
||||
|
@ -280,6 +280,8 @@ StringRef ARM::getCanonicalArchName(StringRef Arch) {
|
||||
// Begins with "arm" / "thumb", move past it.
|
||||
if (A.startswith("arm64_32"))
|
||||
offset = 8;
|
||||
else if (A.startswith("arm64e"))
|
||||
offset = 6;
|
||||
else if (A.startswith("arm64"))
|
||||
offset = 5;
|
||||
else if (A.startswith("aarch64_32"))
|
||||
|
@ -407,6 +407,7 @@ static Triple::ArchType parseArch(StringRef ArchName) {
|
||||
.Case("arc", Triple::arc)
|
||||
.Case("arm64", Triple::aarch64)
|
||||
.Case("arm64_32", Triple::aarch64_32)
|
||||
.Case("arm64e", Triple::aarch64)
|
||||
.Case("arm", Triple::arm)
|
||||
.Case("armeb", Triple::armeb)
|
||||
.Case("thumb", Triple::thumb)
|
||||
@ -572,6 +573,9 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) {
|
||||
if (SubArchName == "powerpcspe")
|
||||
return Triple::PPCSubArch_spe;
|
||||
|
||||
if (SubArchName == "arm64e")
|
||||
return Triple::AArch64SubArch_arm64e;
|
||||
|
||||
StringRef ARMSubArch = ARM::getCanonicalArchName(SubArchName);
|
||||
|
||||
// For now, this is the small part. Early return.
|
||||
@ -1648,6 +1652,9 @@ VersionTuple Triple::getMinimumSupportedOSVersion() const {
|
||||
// ARM64 simulators are supported for iOS 14+.
|
||||
if (isMacCatalystEnvironment() || isSimulatorEnvironment())
|
||||
return VersionTuple(14, 0, 0);
|
||||
// ARM64e slice is supported starting from iOS 14.
|
||||
if (isArm64e())
|
||||
return VersionTuple(14, 0, 0);
|
||||
break;
|
||||
case Triple::TvOS:
|
||||
// ARM64 simulators are supported for tvOS 14+.
|
||||
|
@ -229,6 +229,12 @@ static std::string computeDataLayout(const Triple &TT,
|
||||
return "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
|
||||
}
|
||||
|
||||
static StringRef computeDefaultCPU(const Triple &TT, StringRef CPU) {
|
||||
if (CPU.empty() && TT.isArm64e())
|
||||
return "apple-a12";
|
||||
return CPU;
|
||||
}
|
||||
|
||||
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
|
||||
Optional<Reloc::Model> RM) {
|
||||
// AArch64 Darwin and Windows are always PIC.
|
||||
@ -276,7 +282,8 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
|
||||
bool LittleEndian)
|
||||
: LLVMTargetMachine(T,
|
||||
computeDataLayout(TT, Options.MCOptions, LittleEndian),
|
||||
TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM),
|
||||
TT, computeDefaultCPU(TT, CPU), FS, Options,
|
||||
getEffectiveRelocModel(TT, RM),
|
||||
getEffectiveAArch64CodeModel(TT, CM, JIT), OL),
|
||||
TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
|
||||
initAsmInfo();
|
||||
|
@ -50,9 +50,13 @@ static MCInstrInfo *createAArch64MCInstrInfo() {
|
||||
|
||||
static MCSubtargetInfo *
|
||||
createAArch64MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
|
||||
if (CPU.empty())
|
||||
if (CPU.empty()) {
|
||||
CPU = "generic";
|
||||
|
||||
if (TT.isArm64e())
|
||||
CPU = "apple-a12";
|
||||
}
|
||||
|
||||
return createAArch64MCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
|
||||
}
|
||||
|
||||
|
12
test/MC/AArch64/arm64e-subtype.s
Normal file
12
test/MC/AArch64/arm64e-subtype.s
Normal file
@ -0,0 +1,12 @@
|
||||
; RUN: llvm-mc -triple=arm64e-apple-ios -filetype=obj %s -o - | llvm-objdump --macho -d -p - | FileCheck %s
|
||||
|
||||
; CHECK: _foo:
|
||||
; CHECK: 0: c0 03 5f d6 ret
|
||||
|
||||
; CHECK: Mach header
|
||||
; CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
|
||||
; CHECK: MH_MAGIC_64 ARM64 E 0x00 OBJECT 3 256 0x00000000
|
||||
|
||||
.globl _foo
|
||||
_foo:
|
||||
ret
|
9
test/MC/AArch64/arm64e.s
Normal file
9
test/MC/AArch64/arm64e.s
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: not llvm-mc -triple arm64-- -show-encoding < %s 2> %t
|
||||
// RUN: FileCheck --check-prefix=CHECK-GENERIC < %t %s
|
||||
|
||||
// RUN: llvm-mc -triple arm64e-- -show-encoding < %s |\
|
||||
// RUN: FileCheck %s --check-prefix=CHECK-ARM64E
|
||||
|
||||
// CHECK-GENERIC: error: instruction requires: pa
|
||||
// CHECK-ARM64E: pacia x0, x1 // encoding: [0x20,0x00,0xc1,0xda]
|
||||
pacia x0, x1
|
@ -1,16 +1,39 @@
|
||||
// RUN: llvm-mc -triple arm64-apple-macos10.10.2 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-MACOS-ARM64
|
||||
// RUN: llvm-mc -triple arm64e-apple-macos10.10 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-MACOS-ARM64
|
||||
// RUN: llvm-mc -triple arm64-apple-macos11 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-MACOS-ARM64
|
||||
// RUN: llvm-mc -triple arm64-apple-macos11.1 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-MACOS-ARM64_1
|
||||
// RUN: llvm-mc -triple arm64-apple-ios13.0-macabi %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-MACCATALYST-ARM64
|
||||
// RUN: llvm-mc -triple arm64e-apple-ios13.0-macabi %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-MACCATALYST-ARM64
|
||||
// RUN: llvm-mc -triple arm64-apple-ios14.1-macabi %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-MACCATALYST-ARM64_1
|
||||
|
||||
// RUN: llvm-mc -triple arm64e-apple-ios10.3 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOS-ARM64E
|
||||
// RUN: llvm-mc -triple arm64e-apple-ios13 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOS-ARM64E
|
||||
// RUN: llvm-mc -triple arm64e-apple-ios14.1 %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOS-ARM64E3
|
||||
|
||||
// RUN: llvm-mc -triple arm64-apple-ios10-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOSSIM2
|
||||
// RUN: llvm-mc -triple arm64e-apple-ios10-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOSSIM2
|
||||
// RUN: llvm-mc -triple arm64-apple-ios13-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOSSIM2
|
||||
// RUN: llvm-mc -triple arm64-apple-ios14-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOSSIM2
|
||||
// RUN: llvm-mc -triple arm64-apple-ios14.1-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-IOSSIM3
|
||||
// RUN: llvm-mc -triple arm64-apple-tvos10-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-TVOSSIM2
|
||||
// RUN: llvm-mc -triple arm64-apple-watchos3-simulator %s -filetype=obj -o - | llvm-objdump --macho --private-headers - | FileCheck %s --check-prefix=CHECK-BUILD-WATCHOSSIM2
|
||||
|
||||
// CHECK-BUILD-IOS-ARM64E: cmd LC_BUILD_VERSION
|
||||
// CHECK-BUILD-IOS-ARM64E-NEXT: cmdsize 24
|
||||
// CHECK-BUILD-IOS-ARM64E-NEXT: platform ios
|
||||
// CHECK-BUILD-IOS-ARM64E-NEXT: sdk n/a
|
||||
// CHECK-BUILD-IOS-ARM64E-NEXT: minos 14.0
|
||||
// CHECK-BUILD-IOS-ARM64E-NEXT: ntools 0
|
||||
// CHECK-BUILD-IOS-ARM64E-NOT: LC_VERSION_MIN
|
||||
|
||||
// CHECK-BUILD-IOS-ARM64E3: cmd LC_BUILD_VERSION
|
||||
// CHECK-BUILD-IOS-ARM64E3-NEXT: cmdsize 24
|
||||
// CHECK-BUILD-IOS-ARM64E3-NEXT: platform ios
|
||||
// CHECK-BUILD-IOS-ARM64E3-NEXT: sdk n/a
|
||||
// CHECK-BUILD-IOS-ARM64E3-NEXT: minos 14.1
|
||||
// CHECK-BUILD-IOS-ARM64E3-NEXT: ntools 0
|
||||
// CHECK-BUILD-IOS-ARM64E3-NOT: LC_VERSION_MIN
|
||||
|
||||
// CHECK-BUILD-IOSSIM2: cmd LC_BUILD_VERSION
|
||||
// CHECK-BUILD-IOSSIM2-NEXT: cmdsize 24
|
||||
// CHECK-BUILD-IOSSIM2-NEXT: platform iossim
|
||||
|
17
test/tools/llvm-dwarfdump/AArch64/arm64e.ll
Normal file
17
test/tools/llvm-dwarfdump/AArch64/arm64e.ll
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: llc -O0 %s -filetype=obj -o - \
|
||||
; RUN: | llvm-dwarfdump -arch arm64e - | FileCheck %s
|
||||
; CHECK: file format Mach-O arm64
|
||||
|
||||
source_filename = "/tmp/empty.c"
|
||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
|
||||
target triple = "arm64e-apple-ios"
|
||||
|
||||
!llvm.module.flags = !{!1, !2, !3, !4}
|
||||
!llvm.dbg.cu = !{!5}
|
||||
|
||||
!1 = !{i32 2, !"Dwarf Version", i32 4}
|
||||
!2 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!3 = !{i32 1, !"wchar_size", i32 4}
|
||||
!4 = !{i32 7, !"PIC Level", i32 2}
|
||||
!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "Apple clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
!6 = !DIFile(filename: "/tmp/empty.c", directory: "/Volumes/Data/llvm-project")
|
@ -22,7 +22,7 @@
|
||||
# CHECK-NEXT: offset 16384
|
||||
# CHECK-NEXT: size 384
|
||||
# CHECK-NEXT: align 2^14 (16384)
|
||||
# CHECK-NEXT: architecture
|
||||
# CHECK-NEXT: architecture arm64e
|
||||
# CHECK-NEXT: cputype CPU_TYPE_ARM64
|
||||
# CHECK-NEXT: cpusubtype CPU_SUBTYPE_ARM64E
|
||||
# CHECK-NEXT: capabilities 0x0
|
||||
|
17
test/tools/llvm-readobj/macho-arm64e.test
Normal file
17
test/tools/llvm-readobj/macho-arm64e.test
Normal file
@ -0,0 +1,17 @@
|
||||
# RUN: yaml2obj %s -o %t.o
|
||||
# RUN: llvm-readobj -h %t.o | FileCheck %s
|
||||
|
||||
# CHECK: Magic: Magic64 (0xFEEDFACF)
|
||||
# CHECK: CpuType: Arm64 (0x100000C)
|
||||
# CHECK: CpuSubType: CPU_SUBTYPE_ARM64E (0x2)
|
||||
|
||||
--- !mach-o
|
||||
FileHeader:
|
||||
magic: 0xFEEDFACF
|
||||
cputype: 0x0100000C
|
||||
cpusubtype: 0x00000002
|
||||
filetype: 0x00000001
|
||||
ncmds: 0
|
||||
sizeofcmds: 0
|
||||
flags: 0x00000000
|
||||
reserved: 0x00000000
|
@ -1590,5 +1590,10 @@ TEST(TripleTest, ParseARMArch) {
|
||||
Triple T = Triple("aarch64_be");
|
||||
EXPECT_EQ(Triple::aarch64_be, T.getArch());
|
||||
}
|
||||
{
|
||||
Triple T = Triple("arm64e");
|
||||
EXPECT_EQ(Triple::aarch64, T.getArch());
|
||||
EXPECT_EQ(Triple::AArch64SubArch_arm64e, T.getSubArch());
|
||||
}
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
@ -336,6 +336,7 @@ def build_function_body_dictionary_for_triple(args, raw_tool_output, triple,
|
||||
'amdgcn': (scrub_asm_amdgpu, ASM_FUNCTION_AMDGPU_RE),
|
||||
'arm': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
|
||||
'arm64': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_RE),
|
||||
'arm64e': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
|
||||
'arm64-apple-ios': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
|
||||
'armv7-apple-ios' : (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_IOS_RE),
|
||||
'armv7-apple-darwin': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_DARWIN_RE),
|
||||
|
Loading…
Reference in New Issue
Block a user