]> granicus.if.org Git - llvm/commitdiff
[AArch64] Allow using emulated tls on platforms other than ELF
authorMartin Storsjo <martin@martin.st>
Mon, 4 Dec 2017 09:09:04 +0000 (09:09 +0000)
committerMartin Storsjo <martin@martin.st>
Mon, 4 Dec 2017 09:09:04 +0000 (09:09 +0000)
This matches how it is done on X86.

This allows using emulated tls on windows; in MinGW environments,
native tls isn't supported at the moment.

Set the right Data*bitsDirective for windows to match the existing
tests for other platforms. Make parts of the existing tests a regex,
to allow matching .section .rdata for windows, to avoid having to
duplicate the rest of the tests for windows.

Differential Revision: https://reviews.llvm.org/D40770

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
test/CodeGen/AArch64/emutls_generic.ll

index 589abaa5f7c8a95d917ff27edfeaf20dcb17e5d0..00c450446485851b061c6416111e90e1dcce83c9 100644 (file)
@@ -3885,9 +3885,6 @@ AArch64TargetLowering::LowerELFGlobalTLSAddress(SDValue Op,
 
   TLSModel::Model Model = getTargetMachine().getTLSModel(GA->getGlobal());
 
-  if (DAG.getTarget().Options.EmulatedTLS)
-    return LowerToTLSEmulatedModel(GA, DAG);
-
   if (!EnableAArch64ELFLocalDynamicTLSGeneration) {
     if (Model == TLSModel::LocalDynamic)
       Model = TLSModel::GeneralDynamic;
@@ -3973,6 +3970,10 @@ AArch64TargetLowering::LowerELFGlobalTLSAddress(SDValue Op,
 
 SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op,
                                                      SelectionDAG &DAG) const {
+  const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
+  if (DAG.getTarget().Options.EmulatedTLS)
+    return LowerToTLSEmulatedModel(GA, DAG);
+
   if (Subtarget->isTargetDarwin())
     return LowerDarwinGlobalTLSAddress(Op, DAG);
   if (Subtarget->isTargetELF())
index c5da457c38fff624ddbb7afd009326b4be689316..12b5a27b7699a036aa72d91e0b1ae38c54e28006 100644 (file)
@@ -104,6 +104,11 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
 AArch64MCAsmInfoCOFF::AArch64MCAsmInfoCOFF() {
   PrivateGlobalPrefix = ".L";
   PrivateLabelPrefix = ".L";
+
+  Data16bitsDirective = "\t.hword\t";
+  Data32bitsDirective = "\t.word\t";
+  Data64bitsDirective = "\t.xword\t";
+
   AlignmentIsInBytes = false;
   SupportsDebugInformation = true;
   CodePointerSize = 8;
index 03473cf80ee4f790345c784c21cff1f48f9fd285..f205078ed411dccb70fbf237b15da62ee37196a4 100644 (file)
@@ -4,6 +4,10 @@
 ; RUN:     | FileCheck -check-prefix=ARM_64 %s
 ; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -O3 \
 ; RUN:     | FileCheck -check-prefix=ARM_64 %s
+; RUN: llc < %s -emulated-tls -mtriple=aarch64-windows-gnu -O3 \
+; RUN:     | FileCheck -check-prefix=ARM_64 %s
+; RUN: llc < %s -emulated-tls -mtriple=aarch64-apple-darwin -O3 \
+; RUN:     | FileCheck -check-prefix=DARWIN %s
 
 ; Make sure that TLS symbols are emitted in expected order.
 
@@ -46,7 +50,7 @@ entry:
 ; ARM_64-NEXT:   .xword 0
 ; ARM_64-NEXT:   .xword __emutls_t.external_y
 ; ARM_64-NOT:    __emutls_v.external_x:
-; ARM_64:        .section .rodata,
+; ARM_64:        .section .r{{o?}}data,
 ; ARM_64-LABEL:  __emutls_t.external_y:
 ; ARM_64-NEXT:   .byte 7
 ; ARM_64:        .data{{$}}
@@ -57,6 +61,41 @@ entry:
 ; ARM_64-NEXT:   .xword 16
 ; ARM_64-NEXT:   .xword 0
 ; ARM_64-NEXT:   .xword __emutls_t.internal_y
-; ARM_64:        .section .rodata,
+; ARM_64:        .section .r{{o?}}data,
 ; ARM_64-LABEL:  __emutls_t.internal_y:
 ; ARM_64-NEXT:   .xword 9
+
+; DARWIN-LABEL:  _get_external_x:
+; DARWIN:        ___emutls_v.external_x
+; DARWIN:        ___emutls_get_address
+; DARWIN-LABEL:  _get_external_y:
+; DARWIN:        ___emutls_v.external_y
+; DARWIN:        ___emutls_get_address
+; DARWIN-LABEL:  _get_internal_y:
+; DARWIN:        ___emutls_v.internal_y
+; DARWIN:        ___emutls_get_address
+; DARWIN-NOT:    ___emutls_t.external_x
+; DARWIN-NOT:    ___emutls_v.external_x:
+; DARWIN:        .section __DATA,__data
+; DARWIN:        .globl ___emutls_v.external_y
+; DARWIN:        .p2align 3
+; DARWIN-LABEL:  ___emutls_v.external_y:
+; DARWIN-NEXT:   .quad 1
+; DARWIN-NEXT:   .quad 2
+; DARWIN-NEXT:   .quad 0
+; DARWIN-NEXT:   .quad ___emutls_t.external_y
+; DARWIN-NOT:    ___emutls_v.external_x:
+; DARWIN:        .section __TEXT,__const
+; DARWIN-LABEL:  ___emutls_t.external_y:
+; DARWIN-NEXT:   .byte 7
+; DARWIN:        .section __DATA,__data
+; DARWIN-NOT:    .globl ___emutls_v
+; DARWIN:        .p2align 3
+; DARWIN-LABEL:  ___emutls_v.internal_y:
+; DARWIN-NEXT:   .quad 8
+; DARWIN-NEXT:   .quad 16
+; DARWIN-NEXT:   .quad 0
+; DARWIN-NEXT:   .quad ___emutls_t.internal_y
+; DARWIN:        .section __TEXT,__const
+; DARWIN-LABEL:  ___emutls_t.internal_y:
+; DARWIN-NEXT:   .quad 9