Add TLS support for ELF and MachO (#1174)

* Add TLS support
* Add binemit and legalize tests
* Spill all caller-saved registers when necessary
This commit is contained in:
bjorn3
2020-02-26 02:50:04 +01:00
committed by GitHub
parent 0a11736fbf
commit 0a1bb3ba6c
27 changed files with 354 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
test regalloc
set tls_model=elf_gd
target x86_64
function u0:0(i32) -> i32, i64 {
gv0 = symbol colocated tls u1:0
block0(v0: i32):
; check: block0(v2: i32 [%rdi]):
; nextln: [RexOp1spillSib32#89,ss0] v0 = spill v2
v1 = global_value.i64 gv0
; nextln: [elf_tls_get_addr#00,%rax] v1 = x86_elf_tls_get_addr gv0
; nextln: [RexOp1fillSib32#8b,%r15] v3 = fill v0
return v0, v1
; nextln: [RexOp1rmov#8089] regmove v1, %rax -> %rdx
; nextln: [RexOp1rmov#89] regmove v3, %r15 -> %rax
; nextln: [Op1ret#c3] return v3, v1
}

View File

@@ -0,0 +1,11 @@
test binemit
target x86_64
function u0:0() -> i64, i64 {
gv0 = symbol colocated tls u1:0
block0:
[-, %rax] v0 = x86_elf_tls_get_addr gv0 ; bin: 66 48 8d 3d ElfX86_64TlsGd(u1:0-4) 00000000 66 66 48 e8 CallPLTRel4(%ElfTlsGetAddr-4) 00000000
[-, %rax] v1 = x86_macho_tls_get_addr gv0; bin: 48 8b 3d MachOX86_64Tlv(u1:0-4) 00000000 ff 17
return v0, v1
}

View File

@@ -0,0 +1,18 @@
test regalloc
set tls_model=macho
target x86_64
function u0:0(i32) -> i32, i64 {
gv0 = symbol colocated tls u1:0
block0(v0: i32):
; check: block0(v2: i32 [%rdi]):
; nextln: [RexOp1spillSib32#89,ss0] v0 = spill v2
v1 = global_value.i64 gv0
; nextln: [macho_tls_get_addr#00,%rax] v1 = x86_macho_tls_get_addr gv0
; nextln: [RexOp1fillSib32#8b,%r15] v3 = fill v0
return v0, v1
; nextln: [RexOp1rmov#8089] regmove v1, %rax -> %rdx
; nextln: [RexOp1rmov#89] regmove v3, %r15 -> %rax
; nextln: [Op1ret#c3] return v3, v1
}