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:
18
cranelift/filetests/filetests/isa/x86/tls_elf.clif
Normal file
18
cranelift/filetests/filetests/isa/x86/tls_elf.clif
Normal 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
|
||||
}
|
||||
11
cranelift/filetests/filetests/isa/x86/tls_enc.clif
Normal file
11
cranelift/filetests/filetests/isa/x86/tls_enc.clif
Normal 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
|
||||
}
|
||||
18
cranelift/filetests/filetests/isa/x86/tls_macho.clif
Normal file
18
cranelift/filetests/filetests/isa/x86/tls_macho.clif
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user