diff --git a/llvm/lib/Target/PowerPC/PPC.td b/llvm/lib/Target/PowerPC/PPC.td --- a/llvm/lib/Target/PowerPC/PPC.td +++ b/llvm/lib/Target/PowerPC/PPC.td @@ -318,6 +318,14 @@ SubtargetFeature<"privileged", "HasPrivileged", "true", "Add privileged instructions">; +def FeatureAIXLocalExecTLS : + SubtargetFeature<"aix-small-local-exec-tls", "HasAIXSmallLocalExecTLS", "true", + "Produce a faster access sequence for local-exec TLS " + "variables where the offset from the TLS base " + "is encoded as an immediate operand (AIX 64-bit only). " + "This access sequence is not used for variables larger " + "than 32KB.">; + def FeaturePredictableSelectIsExpensive : SubtargetFeature<"predictable-select-expensive", "PredictableSelectIsExpensive", diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp --- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp @@ -123,6 +123,17 @@ // Determine endianness. IsLittleEndian = TM.isLittleEndian(); + + if (HasAIXSmallLocalExecTLS) { + if (!TargetTriple.isOSAIX()) + report_fatal_error( + "The aix-small-local-exec-tls attribute is only supported on AIX.\n", + false); + if (!IsPPC64) + report_fatal_error( + "The aix-small-local-exec-tls attribute is currently only supported " + "on AIX (64-bit mode).\n", false); + } } bool PPCSubtarget::enableMachineScheduler() const { return true; } diff --git a/llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll b/llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll @@ -0,0 +1,23 @@ +; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \ +; RUN: -ppc-asm-full-reg-names < %s | FileCheck %s +; RUN: not llc -mtriple powerpc-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \ +; RUN: -ppc-asm-full-reg-names < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED-AIX32 +; RUN: not llc -mtriple powerpc64le-unknown-linux-gnu -mattr=+aix-small-local-exec-tls \ +; RUN: -ppc-asm-full-reg-names < %s 2>&1 | \ +; RUN: FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED + +define dso_local signext i32 @f() { +entry: + ret i32 0 +} + +; Check that the -maix-small-local-exec-tls option is not supported on Linux. +; CHECK-NOT-SUPPORTED: The aix-small-local-exec-tls attribute is only supported on AIX. + +; Check that the -maix-small-local-exec-tls option is not supported on AIX, 32-bit mode. +; CHECK-NOT-SUPPORTED-AIX32: The aix-small-local-exec-tls attribute is currently only supported on AIX (64-bit mode). + +; Make sure that the test was actually compiled successfully after using the +; -maix-small-local-exec-tls option. +; CHECK: li r3, 0 +; CHECK-NEXT: blr