[llvm] r356657 - [AArch64] Allow -mattr=tpidr-el[1|2|3]
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 04:30:17 PDT 2019
Author: olista01
Date: Thu Mar 21 04:30:17 2019
New Revision: 356657
URL: http://llvm.org/viewvc/llvm-project?rev=356657&view=rev
Log:
[AArch64] Allow -mattr=tpidr-el[1|2|3]
Added subtarget features for AArch64 to use TPIDR_EL[1|2|3] as the TLS base
register, rather than the default TPIDR_EL0.
Patch by Philip Derrin!
Differential revision: https://reviews.llvm.org/D54685
Modified:
llvm/trunk/lib/Target/AArch64/AArch64.td
llvm/trunk/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h
llvm/trunk/test/CodeGen/AArch64/arm64-builtins-linux.ll
Modified: llvm/trunk/lib/Target/AArch64/AArch64.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64.td?rev=356657&r1=356656&r2=356657&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64.td (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64.td Thu Mar 21 04:30:17 2019
@@ -385,6 +385,14 @@ def AArch64InstrInfo : InstrInfo;
include "AArch64SystemOperands.td"
//===----------------------------------------------------------------------===//
+// Access to privileged registers
+//===----------------------------------------------------------------------===//
+
+foreach i = 1-3 in
+def FeatureUseEL#i#ForTP : SubtargetFeature<"tpidr-el"#i, "UseEL"#i#"ForTP",
+ "true", "Permit use of TPIDR_EL"#i#" for the TLS base">;
+
+//===----------------------------------------------------------------------===//
// AArch64 Processors supported.
//
include "AArch64SchedA53.td"
Modified: llvm/trunk/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp?rev=356657&r1=356656&r2=356657&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp Thu Mar 21 04:30:17 2019
@@ -505,6 +505,12 @@ bool AArch64ExpandPseudo::expandMI(Machi
if (MF->getTarget().getTargetTriple().isOSFuchsia() &&
MF->getTarget().getCodeModel() == CodeModel::Kernel)
SysReg = AArch64SysReg::TPIDR_EL1;
+ else if (MF->getSubtarget<AArch64Subtarget>().useEL3ForTP())
+ SysReg = AArch64SysReg::TPIDR_EL3;
+ else if (MF->getSubtarget<AArch64Subtarget>().useEL2ForTP())
+ SysReg = AArch64SysReg::TPIDR_EL2;
+ else if (MF->getSubtarget<AArch64Subtarget>().useEL1ForTP())
+ SysReg = AArch64SysReg::TPIDR_EL1;
BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(AArch64::MRS), DstReg)
.addImm(SysReg);
MI.eraseFromParent();
Modified: llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h?rev=356657&r1=356656&r2=356657&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h Thu Mar 21 04:30:17 2019
@@ -173,6 +173,9 @@ protected:
bool DisableLatencySchedHeuristic = false;
bool UseRSqrt = false;
bool Force32BitJumpTables = false;
+ bool UseEL1ForTP = false;
+ bool UseEL2ForTP = false;
+ bool UseEL3ForTP = false;
uint8_t MaxInterleaveFactor = 2;
uint8_t VectorInsertExtractBaseCost = 3;
uint16_t CacheLineSize = 0;
@@ -324,6 +327,10 @@ public:
hasFuseCCSelect() || hasFuseLiterals();
}
+ bool useEL1ForTP() const { return UseEL1ForTP; }
+ bool useEL2ForTP() const { return UseEL2ForTP; }
+ bool useEL3ForTP() const { return UseEL3ForTP; }
+
bool useRSqrt() const { return UseRSqrt; }
bool force32BitJumpTables() const { return Force32BitJumpTables; }
unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
Modified: llvm/trunk/test/CodeGen/AArch64/arm64-builtins-linux.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-builtins-linux.ll?rev=356657&r1=356656&r2=356657&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/arm64-builtins-linux.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/arm64-builtins-linux.ll Thu Mar 21 04:30:17 2019
@@ -1,6 +1,9 @@
; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s
; RUN: llc < %s -mtriple=aarch64-fuchsia | FileCheck %s
; RUN: llc < %s -mtriple=aarch64-fuchsia -code-model=kernel | FileCheck --check-prefix=FUCHSIA-KERNEL %s
+; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+tpidr-el1 | FileCheck --check-prefix=USEEL1 %s
+; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+tpidr-el2 | FileCheck --check-prefix=USEEL2 %s
+; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+tpidr-el3 | FileCheck --check-prefix=USEEL3 %s
; Function Attrs: nounwind readnone
declare i8* @llvm.thread.pointer() #1
@@ -10,6 +13,12 @@ define i8* @thread_pointer() {
; CHECK: mrs {{x[0-9]+}}, TPIDR_EL0
; FUCHSIA-KERNEL: thread_pointer:
; FUCHSIA-KERNEL: mrs {{x[0-9]+}}, TPIDR_EL1
+; USEEL1: thread_pointer:
+; USEEL1: mrs {{x[0-9]+}}, TPIDR_EL1
+; USEEL2: thread_pointer:
+; USEEL2: mrs {{x[0-9]+}}, TPIDR_EL2
+; USEEL3: thread_pointer:
+; USEEL3: mrs {{x[0-9]+}}, TPIDR_EL3
%1 = tail call i8* @llvm.thread.pointer()
ret i8* %1
}
More information about the llvm-commits
mailing list