1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:24:39 -07:00

runtime, math/big: allow R0 on s390x to contain values other than 0

The new SSA backend for s390x can use R0 as a general purpose register.
This change modifies assembly code to either avoid using R0 entirely
or explicitly set R0 to 0.

R0 can still be safely used as 0 in address calculations.

Change-Id: I3efa723e9ef322a91a408bd8c31768d7858526c8
Reviewed-on: https://go-review.googlesource.com/28976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Michael Munday 2016-09-12 13:33:00 -04:00
parent 43bdfa9337
commit f1515a01fd
3 changed files with 44 additions and 42 deletions

View File

@ -271,6 +271,7 @@ E4: MOVD R4, c+56(FP) // return c
// func shlVU(z, x []Word, s uint) (c Word) // func shlVU(z, x []Word, s uint) (c Word)
TEXT ·shlVU(SB),NOSPLIT,$0 TEXT ·shlVU(SB),NOSPLIT,$0
MOVD z_len+8(FP), R5 MOVD z_len+8(FP), R5
MOVD $0, R0
SUB $1, R5 // n-- SUB $1, R5 // n--
BLT X8b // n < 0 (n <= 0) BLT X8b // n < 0 (n <= 0)
@ -358,6 +359,7 @@ E864: CMPBGT R5, R0, L864 // i < n-1
// func shrVU(z, x []Word, s uint) (c Word) // func shrVU(z, x []Word, s uint) (c Word)
TEXT ·shrVU(SB),NOSPLIT,$0 TEXT ·shrVU(SB),NOSPLIT,$0
MOVD z_len+8(FP), R5 MOVD z_len+8(FP), R5
MOVD $0, R0
SUB $1, R5 // n-- SUB $1, R5 // n--
BLT X9b // n < 0 (n <= 0) BLT X9b // n < 0 (n <= 0)

View File

@ -110,22 +110,22 @@ nocgo:
MOVD $runtime·mainPC(SB), R2 // entry MOVD $runtime·mainPC(SB), R2 // entry
SUB $24, R15 SUB $24, R15
MOVD R2, 16(R15) MOVD R2, 16(R15)
MOVD R0, 8(R15) MOVD $0, 8(R15)
MOVD R0, 0(R15) MOVD $0, 0(R15)
BL runtime·newproc(SB) BL runtime·newproc(SB)
ADD $24, R15 ADD $24, R15
// start this M // start this M
BL runtime·mstart(SB) BL runtime·mstart(SB)
MOVD R0, 1(R0) MOVD $0, 1(R0)
RET RET
DATA runtime·mainPC+0(SB)/8,$runtime·main(SB) DATA runtime·mainPC+0(SB)/8,$runtime·main(SB)
GLOBL runtime·mainPC(SB),RODATA,$8 GLOBL runtime·mainPC(SB),RODATA,$8
TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0
MOVD R0, 2(R0) MOVD $0, 2(R0)
RET RET
TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0
@ -175,7 +175,7 @@ TEXT runtime·mcall(SB), NOSPLIT, $-8-8
// Save caller state in g->sched // Save caller state in g->sched
MOVD R15, (g_sched+gobuf_sp)(g) MOVD R15, (g_sched+gobuf_sp)(g)
MOVD LR, (g_sched+gobuf_pc)(g) MOVD LR, (g_sched+gobuf_pc)(g)
MOVD R0, (g_sched+gobuf_lr)(g) MOVD $0, (g_sched+gobuf_lr)(g)
MOVD g, (g_sched+gobuf_g)(g) MOVD g, (g_sched+gobuf_g)(g)
// Switch to m->g0 & its stack, call fn. // Switch to m->g0 & its stack, call fn.
@ -232,7 +232,7 @@ switch:
ADD $16, R6 // get past prologue ADD $16, R6 // get past prologue
MOVD R6, (g_sched+gobuf_pc)(g) MOVD R6, (g_sched+gobuf_pc)(g)
MOVD R15, (g_sched+gobuf_sp)(g) MOVD R15, (g_sched+gobuf_sp)(g)
MOVD R0, (g_sched+gobuf_lr)(g) MOVD $0, (g_sched+gobuf_lr)(g)
MOVD g, (g_sched+gobuf_g)(g) MOVD g, (g_sched+gobuf_g)(g)
// switch to g0 // switch to g0
@ -526,7 +526,7 @@ g0:
MOVD (g_stack+stack_hi)(R5), R5 MOVD (g_stack+stack_hi)(R5), R5
SUB R2, R5 SUB R2, R5
MOVD R5, 160(R15) // save depth in old g stack (can't just save SP, as stack might be copied during a callback) MOVD R5, 160(R15) // save depth in old g stack (can't just save SP, as stack might be copied during a callback)
MOVD R0, 0(R15) // clear back chain pointer (TODO can we give it real back trace information?) MOVD $0, 0(R15) // clear back chain pointer (TODO can we give it real back trace information?)
MOVD R4, R2 // arg in R2 MOVD R4, R2 // arg in R2
BL R3 // can clobber: R0-R5, R14, F0-F3, F5, F7-F15 BL R3 // can clobber: R0-R5, R14, F0-F3, F5, F7-F15

View File

@ -16,8 +16,8 @@ start:
CMPBLE R5, $15, clear12to15 CMPBLE R5, $15, clear12to15
CMP R5, $32 CMP R5, $32
BGE clearmt32 BGE clearmt32
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVD R0, 8(R4) MOVD $0, 8(R4)
ADD $16, R4 ADD $16, R4
SUB $16, R5 SUB $16, R5
BR start BR start
@ -25,79 +25,79 @@ start:
clear0to3: clear0to3:
CMPBEQ R5, $0, done CMPBEQ R5, $0, done
CMPBNE R5, $1, clear2 CMPBNE R5, $1, clear2
MOVB R0, 0(R4) MOVB $0, 0(R4)
RET RET
clear2: clear2:
CMPBNE R5, $2, clear3 CMPBNE R5, $2, clear3
MOVH R0, 0(R4) MOVH $0, 0(R4)
RET RET
clear3: clear3:
MOVH R0, 0(R4) MOVH $0, 0(R4)
MOVB R0, 2(R4) MOVB $0, 2(R4)
RET RET
clear4to7: clear4to7:
CMPBNE R5, $4, clear5 CMPBNE R5, $4, clear5
MOVW R0, 0(R4) MOVW $0, 0(R4)
RET RET
clear5: clear5:
CMPBNE R5, $5, clear6 CMPBNE R5, $5, clear6
MOVW R0, 0(R4) MOVW $0, 0(R4)
MOVB R0, 4(R4) MOVB $0, 4(R4)
RET RET
clear6: clear6:
CMPBNE R5, $6, clear7 CMPBNE R5, $6, clear7
MOVW R0, 0(R4) MOVW $0, 0(R4)
MOVH R0, 4(R4) MOVH $0, 4(R4)
RET RET
clear7: clear7:
MOVW R0, 0(R4) MOVW $0, 0(R4)
MOVH R0, 4(R4) MOVH $0, 4(R4)
MOVB R0, 6(R4) MOVB $0, 6(R4)
RET RET
clear8to11: clear8to11:
CMPBNE R5, $8, clear9 CMPBNE R5, $8, clear9
MOVD R0, 0(R4) MOVD $0, 0(R4)
RET RET
clear9: clear9:
CMPBNE R5, $9, clear10 CMPBNE R5, $9, clear10
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVB R0, 8(R4) MOVB $0, 8(R4)
RET RET
clear10: clear10:
CMPBNE R5, $10, clear11 CMPBNE R5, $10, clear11
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVH R0, 8(R4) MOVH $0, 8(R4)
RET RET
clear11: clear11:
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVH R0, 8(R4) MOVH $0, 8(R4)
MOVB R0, 10(R4) MOVB $0, 10(R4)
RET RET
clear12to15: clear12to15:
CMPBNE R5, $12, clear13 CMPBNE R5, $12, clear13
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVW R0, 8(R4) MOVW $0, 8(R4)
RET RET
clear13: clear13:
CMPBNE R5, $13, clear14 CMPBNE R5, $13, clear14
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVW R0, 8(R4) MOVW $0, 8(R4)
MOVB R0, 12(R4) MOVB $0, 12(R4)
RET RET
clear14: clear14:
CMPBNE R5, $14, clear15 CMPBNE R5, $14, clear15
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVW R0, 8(R4) MOVW $0, 8(R4)
MOVH R0, 12(R4) MOVH $0, 12(R4)
RET RET
clear15: clear15:
MOVD R0, 0(R4) MOVD $0, 0(R4)
MOVW R0, 8(R4) MOVW $0, 8(R4)
MOVH R0, 12(R4) MOVH $0, 12(R4)
MOVB R0, 14(R4) MOVB $0, 14(R4)
RET RET
clearmt32: clearmt32:
@ -117,6 +117,6 @@ done:
// DO NOT CALL - target for exrl (execute relative long) instruction. // DO NOT CALL - target for exrl (execute relative long) instruction.
TEXT runtime·memclr_s390x_exrl_xc(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·memclr_s390x_exrl_xc(SB),NOSPLIT|NOFRAME,$0-0
XC $1, 0(R4), 0(R4) XC $1, 0(R4), 0(R4)
MOVD R0, 0(R0) MOVD $0, 0(R0)
RET RET