[AArch64] Allow using emulated tls on platforms other than ELF

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

llvm-svn: 319644
This commit is contained in:
Martin Storsjo 2017-12-04 09:09:04 +00:00
parent c85cc41801
commit eca862de07
3 changed files with 50 additions and 5 deletions

View File

@ -3885,9 +3885,6 @@ AArch64TargetLowering::LowerELFGlobalTLSAddress(SDValue Op,
TLSModel::Model Model = getTargetMachine().getTLSModel(GA->getGlobal()); TLSModel::Model Model = getTargetMachine().getTLSModel(GA->getGlobal());
if (DAG.getTarget().Options.EmulatedTLS)
return LowerToTLSEmulatedModel(GA, DAG);
if (!EnableAArch64ELFLocalDynamicTLSGeneration) { if (!EnableAArch64ELFLocalDynamicTLSGeneration) {
if (Model == TLSModel::LocalDynamic) if (Model == TLSModel::LocalDynamic)
Model = TLSModel::GeneralDynamic; Model = TLSModel::GeneralDynamic;
@ -3973,6 +3970,10 @@ AArch64TargetLowering::LowerELFGlobalTLSAddress(SDValue Op,
SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op, SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op,
SelectionDAG &DAG) const { SelectionDAG &DAG) const {
const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
if (DAG.getTarget().Options.EmulatedTLS)
return LowerToTLSEmulatedModel(GA, DAG);
if (Subtarget->isTargetDarwin()) if (Subtarget->isTargetDarwin())
return LowerDarwinGlobalTLSAddress(Op, DAG); return LowerDarwinGlobalTLSAddress(Op, DAG);
if (Subtarget->isTargetELF()) if (Subtarget->isTargetELF())

View File

@ -104,6 +104,11 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
AArch64MCAsmInfoCOFF::AArch64MCAsmInfoCOFF() { AArch64MCAsmInfoCOFF::AArch64MCAsmInfoCOFF() {
PrivateGlobalPrefix = ".L"; PrivateGlobalPrefix = ".L";
PrivateLabelPrefix = ".L"; PrivateLabelPrefix = ".L";
Data16bitsDirective = "\t.hword\t";
Data32bitsDirective = "\t.word\t";
Data64bitsDirective = "\t.xword\t";
AlignmentIsInBytes = false; AlignmentIsInBytes = false;
SupportsDebugInformation = true; SupportsDebugInformation = true;
CodePointerSize = 8; CodePointerSize = 8;

View File

@ -4,6 +4,10 @@
; RUN: | FileCheck -check-prefix=ARM_64 %s ; RUN: | FileCheck -check-prefix=ARM_64 %s
; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -O3 \ ; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-android -O3 \
; RUN: | FileCheck -check-prefix=ARM_64 %s ; 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. ; Make sure that TLS symbols are emitted in expected order.
@ -46,7 +50,7 @@ entry:
; ARM_64-NEXT: .xword 0 ; ARM_64-NEXT: .xword 0
; ARM_64-NEXT: .xword __emutls_t.external_y ; ARM_64-NEXT: .xword __emutls_t.external_y
; ARM_64-NOT: __emutls_v.external_x: ; 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-LABEL: __emutls_t.external_y:
; ARM_64-NEXT: .byte 7 ; ARM_64-NEXT: .byte 7
; ARM_64: .data{{$}} ; ARM_64: .data{{$}}
@ -57,6 +61,41 @@ entry:
; ARM_64-NEXT: .xword 16 ; ARM_64-NEXT: .xword 16
; ARM_64-NEXT: .xword 0 ; ARM_64-NEXT: .xword 0
; ARM_64-NEXT: .xword __emutls_t.internal_y ; 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-LABEL: __emutls_t.internal_y:
; ARM_64-NEXT: .xword 9 ; 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