authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-16 18:54:38+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-18 00:36:52+02:00
log727942bc03a2cd74d10c80894816456f9f66e977
tree8381e05a4293b10609804c1d9185a275e11b5f9e
parent1f15e265fe0861cbfad4479c69b79b46158d8d16
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug.cpu_context: let the compiler deal with clobbers

Otherwise we might be restoring registers we don't even need to.

1 files changed, 8 insertions(+), 21 deletions(-)

lib/std/debug/cpu_context.zig+8-21
......@@ -242,10 +242,9 @@ const Aarch64 = extern struct {
242242 \\ str x1, [x0, #0x0f8]
243243 \\ adr x1, .
244244 \\ str x1, [x0, #0x100]
245 \\ ldr x1, [x0, #0x008]
246245 :
247246 : [ctx] "{x0}" (&ctx),
248 : .{ .memory = true });
247 : .{ .x1 = true, .memory = true });
249248 return ctx;
250249 }
251250
......@@ -469,10 +468,9 @@ const Hexagon = extern struct {
469468 \\ memw(r0 + #124) = r31
470469 \\ r1 = pc
471470 \\ memw(r0 + #128) = r1
472 \\ r1 = memw(r0 + #4)
473471 :
474472 : [ctx] "{r0}" (&ctx),
475 : .{ .memory = true });
473 : .{ .r1 = true, .memory = true });
476474 return ctx;
477475 }
478476
......@@ -594,7 +592,6 @@ const LoongArch = extern struct {
594592 \\ bl 1f
595593 \\1:
596594 \\ st.d $ra, $t0, 256
597 \\ ld.d $ra, $t0, 8
598595 else
599596 \\ st.w $zero, $t0, 0
600597 \\ st.w $ra, $t0, 4
......@@ -631,10 +628,9 @@ const LoongArch = extern struct {
631628 \\ bl 1f
632629 \\1:
633630 \\ st.w $ra, $t0, 128
634 \\ ld.w $ra, $t0, 4
635631 :
636632 : [ctx] "{$r12}" (&ctx),
637 : .{ .memory = true });
633 : .{ .r1 = true, .memory = true });
638634 return ctx;
639635 }
640636
......@@ -734,7 +730,6 @@ const Mips = extern struct {
734730 \\ bal 1f
735731 \\1:
736732 \\ sd $ra, 256($t0)
737 \\ ld $ra, 248($t0)
738733 \\ .set pop
739734 else
740735 \\ .set push
......@@ -776,11 +771,10 @@ const Mips = extern struct {
776771 \\ bal 1f
777772 \\1:
778773 \\ sw $ra, 128($t4)
779 \\ lw $ra, 124($t4)
780774 \\ .set pop
781775 :
782776 : [ctx] "{$12}" (&ctx),
783 : .{ .memory = true });
777 : .{ .r31 = true, .memory = true });
784778 return ctx;
785779 }
786780
......@@ -916,7 +910,6 @@ const Powerpc = extern struct {
916910 \\1:
917911 \\ mflr 8
918912 \\ std 8, 256(10)
919 \\ ld 8, 64(10)
920913 else
921914 \\ stw 0, 0(10)
922915 \\ stw 1, 4(10)
......@@ -956,10 +949,9 @@ const Powerpc = extern struct {
956949 \\1:
957950 \\ mflr 8
958951 \\ stw 8, 128(10)
959 \\ lwz 8, 32(10)
960952 :
961953 : [ctx] "{r10}" (&ctx),
962 : .{ .lr = true, .memory = true });
954 : .{ .r8 = true, .lr = true, .memory = true });
963955 return ctx;
964956 }
965957
......@@ -1068,7 +1060,6 @@ const Riscv = extern struct {
10681060 \\ jal ra, 1f
10691061 \\1:
10701062 \\ sd ra, 256(t0)
1071 \\ ld ra, 8(t0)
10721063 else
10731064 \\ sw zero, 0(t0)
10741065 \\ sw ra, 4(t0)
......@@ -1105,10 +1096,9 @@ const Riscv = extern struct {
11051096 \\ jal ra, 1f
11061097 \\1:
11071098 \\ sw ra, 128(t0)
1108 \\ lw ra, 4(t0)
11091099 :
11101100 : [ctx] "{t0}" (&ctx),
1111 : .{ .memory = true });
1101 : .{ .x1 = true, .memory = true });
11121102 return ctx;
11131103 }
11141104
......@@ -1146,11 +1136,9 @@ const S390x = extern struct {
11461136 \\ stm %%r0, %%r1, 128(%%r2)
11471137 \\ larl %%r0, .
11481138 \\ stg %%r0, 136(%%r2)
1149 \\ lg %%r0, 0(%%r2)
1150 \\ lg %%r1, 8(%%r2)
11511139 :
11521140 : [ctx] "{r2}" (&ctx),
1153 : .{ .memory = true });
1141 : .{ .r0 = true, .r1 = true, .memory = true });
11541142 return ctx;
11551143 }
11561144
......@@ -1458,10 +1446,9 @@ const X86_64 = struct {
14581446 \\ movq %%r15, 0x78(%%rdi)
14591447 \\ leaq (%%rip), %%rax
14601448 \\ movq %%rax, 0x80(%%rdi)
1461 \\ movq 0x00(%%rdi), %%rax
14621449 :
14631450 : [gprs] "{rdi}" (&ctx.gprs.values),
1464 : .{ .memory = true });
1451 : .{ .rax = true, .memory = true });
14651452 return ctx;
14661453 }
14671454