aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm
diff options
context:
space:
mode:
authorMichael Munday <mike.munday@ibm.com>2019-08-15 20:43:46 +0100
committerMichael Munday <mike.munday@ibm.com>2019-09-25 22:24:41 +0000
commit8c99e45ef956be18677d862fd64d1ba5346ce403 (patch)
tree83a148c837b38019043af4ad449eebae18bab1fb /src/cmd/asm
parenteb96f8a57444d174bba500b3a5d2a8b21b7e6d1e (diff)
downloadgo-8c99e45ef956be18677d862fd64d1ba5346ce403.tar.xz
cmd/asm: add masked branch and conditional load instructions to s390x
The branch-relative-on-condition (BRC) instruction allows us to use an immediate to specify under what conditions the branch is taken. For example, `BRC $7, L1` is equivalent to `BNE L1`. It is sometimes useful to specify branches in this way when either we don't have an extended mnemonic for a particular mask value or we want to generate the condition code mask programmatically. The new load-on-condition (LOCR and LOCGR) and compare-and-branch (CRJ, CGRJ, CLRJ, CLGRJ, CIJ, CGIJ, CLIJ and CLGIJ) instructions provide the same flexibility for conditional loads and combined compare and branch instructions. Change-Id: Ic6f5d399b0157e278b39bd3645f4ee0f4df8e5fc Reviewed-on: https://go-review.googlesource.com/c/go/+/196558 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/asm')
-rw-r--r--src/cmd/asm/internal/arch/s390x.go11
-rw-r--r--src/cmd/asm/internal/asm/asm.go15
-rw-r--r--src/cmd/asm/internal/asm/testdata/s390x.s14
3 files changed, 37 insertions, 3 deletions
diff --git a/src/cmd/asm/internal/arch/s390x.go b/src/cmd/asm/internal/arch/s390x.go
index d6d46f86f2..6efae26e1c 100644
--- a/src/cmd/asm/internal/arch/s390x.go
+++ b/src/cmd/asm/internal/arch/s390x.go
@@ -15,7 +15,8 @@ import (
func jumpS390x(word string) bool {
switch word {
- case "BC",
+ case "BRC",
+ "BC",
"BCL",
"BEQ",
"BGE",
@@ -41,6 +42,14 @@ func jumpS390x(word string) bool {
"CMPUBLE",
"CMPUBLT",
"CMPUBNE",
+ "CRJ",
+ "CGRJ",
+ "CLRJ",
+ "CLGRJ",
+ "CIJ",
+ "CGIJ",
+ "CLIJ",
+ "CLGIJ",
"CALL",
"JMP":
return true
diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go
index c6f07832a7..26b355dee1 100644
--- a/src/cmd/asm/internal/asm/asm.go
+++ b/src/cmd/asm/internal/asm/asm.go
@@ -450,8 +450,19 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) {
target = &a[2]
break
}
-
- fallthrough
+ p.errorf("wrong number of arguments to %s instruction", op)
+ return
+ case 4:
+ if p.arch.Family == sys.S390X {
+ // 4-operand compare-and-branch.
+ prog.From = a[0]
+ prog.Reg = p.getRegister(prog, op, &a[1])
+ prog.SetFrom3(a[2])
+ target = &a[3]
+ break
+ }
+ p.errorf("wrong number of arguments to %s instruction", op)
+ return
default:
p.errorf("wrong number of arguments to %s instruction", op)
return
diff --git a/src/cmd/asm/internal/asm/testdata/s390x.s b/src/cmd/asm/internal/asm/testdata/s390x.s
index 62563d885e..4fc599416f 100644
--- a/src/cmd/asm/internal/asm/testdata/s390x.s
+++ b/src/cmd/asm/internal/asm/testdata/s390x.s
@@ -22,6 +22,9 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
MOVDLT R8, R9 // b9e24098
MOVDNE R10, R11 // b9e270ba
+ LOCR $3, R2, R1 // b9f23012
+ LOCGR $7, R5, R6 // b9e27065
+
MOVD (R15), R1 // e310f0000004
MOVW (R15), R2 // e320f0000014
MOVH (R15), R3 // e330f0000015
@@ -253,6 +256,7 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
IPM R3 // b2220030
IPM R12 // b22200c0
+ BRC $7, 0(PC) // a7740000
BNE 0(PC) // a7740000
BEQ 0(PC) // a7840000
BLT 0(PC) // a7440000
@@ -290,6 +294,16 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
CMPUBGT R9, $256, 0(PC) // ec920000007d
CMPUBGE R2, $0, 0(PC) // ec2a0000007d
+ CRJ $15, R1, R2, 0(PC) // ec120000f076
+ CGRJ $12, R3, R4, 0(PC) // ec340000c064
+ CLRJ $3, R5, R6, 0(PC) // ec5600003077
+ CLGRJ $0, R7, R8, 0(PC) // ec7800000065
+
+ CIJ $4, R9, $127, 0(PC) // ec9400007f7e
+ CGIJ $8, R11, $-128, 0(PC) // ecb80000807c
+ CLIJ $1, R1, $255, 0(PC) // ec110000ff7f
+ CLGIJ $2, R3, $0, 0(PC) // ec320000007d
+
LGDR F1, R12 // b3cd00c1
LDGR R2, F15 // b3c100f2