Skip to content

Commit cd687c2

Browse files
committed
druntime/thread: add osthread support for s390x
1 parent 31b214d commit cd687c2

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

runtime/druntime/src/core/thread/osthread.d

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ version (LDC)
4646
}
4747

4848
pragma(LDC_intrinsic, "llvm.eh.unwind.init")
49-
void llvm_unwind_init();
49+
void llvm_unwind_init() nothrow @nogc;
5050
}
5151

5252

@@ -1571,8 +1571,8 @@ in (fn)
15711571
}}
15721572
asm pure nothrow @nogc {
15731573
("sd $gp, %0") : "=m" (regs[8]);
1574-
("sd $fp, %0") : "=m" (regs[9]);
1575-
("sd $ra, %0") : "=m" (sp);
1574+
("sd $fp, %0") : "=m" (regs[9]);
1575+
("sd $sp, %0") : "=m" (sp);
15761576
}
15771577
}
15781578
else version (MIPS_Any)
@@ -1638,22 +1638,14 @@ in (fn)
16381638
}
16391639
else version (SystemZ)
16401640
{
1641-
size_t[19] regs = void;
1641+
// Callee-save registers, according to SystemZ Calling Convention
1642+
// https://github.com/IBM/s390x-abi/blob/main/lzsabi.tex
1643+
size_t[10] regs = void;
16421644
asm pure nothrow @nogc {
1643-
// save argument/return register
1644-
"stg %%r2, %0" : "=m" (regs[0]);
1645-
// save callee-saved GPRs (%r6 - %r14)
1646-
"stmg %%r6, %%r14, %0" : "=m" (regs[1]);
1647-
// save floating point control register
1648-
"stfpc %0" : "=m" (regs[10]);
1645+
// save callee-saved GPRs (%r6 - %r15)
1646+
"stmg %%r6, %%r15, %0" : "=m" (regs[0]);
16491647
}
1650-
static foreach (i; 8 .. 16)
1651-
{{
1652-
enum int j = i;
1653-
// save %f8 - %f15
1654-
asm pure nothrow @nogc { ( "std %%f"~j.stringof~", %0") : "=m" (regs[i + 3]); }
1655-
}}
1656-
asm pure nothrow @nogc { ( "stg %%r15, %0") : "=m" (sp); }
1648+
sp = regs[9];
16571649
}
16581650
else
16591651
{
@@ -1723,6 +1715,7 @@ version (LDC)
17231715
version (ARM_Any) version = LDC_stackTopAsm;
17241716
version (PPC_Any) version = LDC_stackTopAsm;
17251717
version (MIPS_Any) version = LDC_stackTopAsm;
1718+
version (SystemZ) version = LDC_stackTopAsm;
17261719

17271720
version (LDC_stackTopAsm)
17281721
{
@@ -1742,6 +1735,8 @@ version (LDC)
17421735
return __asm!(void*)("mr $0, 1", "=r");
17431736
else version (MIPS_Any)
17441737
return __asm!(void*)("move $0, $$sp", "=r");
1738+
else version (SystemZ)
1739+
return __asm!(void*)("lgr $0, %r15", "=r");
17451740
else
17461741
static assert(0);
17471742
}

0 commit comments

Comments
 (0)