aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorMichael Munday <mndygolang+git@gmail.com>2025-06-27 21:05:38 +0100
committerMichael Munday <mndygolang+git@gmail.com>2025-07-30 12:29:15 -0700
commitcedf63616a00c8a6a69f6bbe4bc93b6865cec842 (patch)
treee94c1a8afe63304f07725460363f7957325566b3 /src/cmd/internal
parent82a1921c3b6b493c4ff358f063c2ffffabba9fd5 (diff)
downloadgo-cedf63616a00c8a6a69f6bbe4bc93b6865cec842.tar.xz
cmd/compile: add floating point min/max intrinsics on s390x
Add the VECTOR FP (MINIMUM|MAXIMUM) instructions to the assembler and use them in the compiler to implement min and max. Note: I've allowed floating point registers to be used with the single element instructions (those with the W instead of V prefix) to allow easier integration into the compiler. Change-Id: I5f80a510bd248cf483cce95f1979bf63fbae7de6 Reviewed-on: https://go-review.googlesource.com/c/go/+/684715 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <mark@golang.org> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/obj/s390x/a.out.go8
-rw-r--r--src/cmd/internal/obj/s390x/anames.go8
-rw-r--r--src/cmd/internal/obj/s390x/asmz.go21
-rw-r--r--src/cmd/internal/obj/s390x/vector.go22
4 files changed, 58 insertions, 1 deletions
diff --git a/src/cmd/internal/obj/s390x/a.out.go b/src/cmd/internal/obj/s390x/a.out.go
index 1a64370efa..dc715182f5 100644
--- a/src/cmd/internal/obj/s390x/a.out.go
+++ b/src/cmd/internal/obj/s390x/a.out.go
@@ -715,6 +715,14 @@ const (
AWFLNDB
AVFLPDB
AWFLPDB
+ AVFMAXDB
+ AWFMAXDB
+ AVFMAXSB
+ AWFMAXSB
+ AVFMINDB
+ AWFMINDB
+ AVFMINSB
+ AWFMINSB
AVFSQ
AVFSQDB
AWFSQDB
diff --git a/src/cmd/internal/obj/s390x/anames.go b/src/cmd/internal/obj/s390x/anames.go
index c0a0c401fa..a6f2820f85 100644
--- a/src/cmd/internal/obj/s390x/anames.go
+++ b/src/cmd/internal/obj/s390x/anames.go
@@ -438,6 +438,14 @@ var Anames = []string{
"WFLNDB",
"VFLPDB",
"WFLPDB",
+ "VFMAXDB",
+ "WFMAXDB",
+ "VFMAXSB",
+ "WFMAXSB",
+ "VFMINDB",
+ "WFMINDB",
+ "VFMINSB",
+ "WFMINSB",
"VFSQ",
"VFSQDB",
"WFSQDB",
diff --git a/src/cmd/internal/obj/s390x/asmz.go b/src/cmd/internal/obj/s390x/asmz.go
index 72d92abbaf..957222a155 100644
--- a/src/cmd/internal/obj/s390x/asmz.go
+++ b/src/cmd/internal/obj/s390x/asmz.go
@@ -441,6 +441,11 @@ var optab = []Optab{
{i: 119, as: AVERLLVG, a1: C_VREG, a2: C_VREG, a6: C_VREG},
{i: 119, as: AVERLLVG, a1: C_VREG, a6: C_VREG},
+ // VRR-c floating point min/max
+ {i: 128, as: AVFMAXDB, a1: C_SCON, a2: C_VREG, a3: C_VREG, a6: C_VREG},
+ {i: 128, as: AWFMAXDB, a1: C_SCON, a2: C_VREG, a3: C_VREG, a6: C_VREG},
+ {i: 128, as: AWFMAXDB, a1: C_SCON, a2: C_FREG, a3: C_FREG, a6: C_FREG},
+
// VRR-d
{i: 120, as: AVACQ, a1: C_VREG, a2: C_VREG, a3: C_VREG, a6: C_VREG},
@@ -1480,6 +1485,14 @@ func buildop(ctxt *obj.Link) {
opset(AVFMSDB, r)
opset(AWFMSDB, r)
opset(AVPERM, r)
+ case AVFMAXDB:
+ opset(AVFMAXSB, r)
+ opset(AVFMINDB, r)
+ opset(AVFMINSB, r)
+ case AWFMAXDB:
+ opset(AWFMAXSB, r)
+ opset(AWFMINDB, r)
+ opset(AWFMINSB, r)
case AKM:
opset(AKMC, r)
opset(AKLMD, r)
@@ -2636,6 +2649,8 @@ const (
op_VUPLL uint32 = 0xE7D4 // VRR-a VECTOR UNPACK LOGICAL LOW
op_VUPL uint32 = 0xE7D6 // VRR-a VECTOR UNPACK LOW
op_VMSL uint32 = 0xE7B8 // VRR-d VECTOR MULTIPLY SUM LOGICAL
+ op_VFMAX uint32 = 0xE7EF // VRR-c VECTOR FP MAXIMUM
+ op_VFMIN uint32 = 0xE7EE // VRR-c VECTOR FP MINIMUM
// added in z15
op_KDSA uint32 = 0xB93A // FORMAT_RRE COMPUTE DIGITAL SIGNATURE AUTHENTICATION (KDSA)
@@ -4475,6 +4490,12 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
c.ctxt.Diag("padding byte register cannot be same as input or output register %v", p)
}
zRS(op_MVCLE, uint32(p.To.Reg), uint32(p.Reg), uint32(p.From.Reg), uint32(d2), asm)
+
+ case 128: // VRR-c floating point max/min
+ op, m4, _ := vop(p.As)
+ m5 := singleElementMask(p.As)
+ m6 := uint32(c.vregoff(&p.From))
+ zVRRc(op, uint32(p.To.Reg), uint32(p.Reg), uint32(p.GetFrom3().Reg), m6, m5, m4, asm)
}
}
diff --git a/src/cmd/internal/obj/s390x/vector.go b/src/cmd/internal/obj/s390x/vector.go
index e7e36eaf15..966cd04c27 100644
--- a/src/cmd/internal/obj/s390x/vector.go
+++ b/src/cmd/internal/obj/s390x/vector.go
@@ -1027,6 +1027,22 @@ func vop(as obj.As) (opcode, es, cs uint32) {
return op_VUPL, 1, 0
case AVUPLF:
return op_VUPL, 2, 0
+ case AVFMAXDB:
+ return op_VFMAX, 3, 0
+ case AWFMAXDB:
+ return op_VFMAX, 3, 0
+ case AVFMAXSB:
+ return op_VFMAX, 2, 0
+ case AWFMAXSB:
+ return op_VFMAX, 2, 0
+ case AVFMINDB:
+ return op_VFMIN, 3, 0
+ case AWFMINDB:
+ return op_VFMIN, 3, 0
+ case AVFMINSB:
+ return op_VFMIN, 2, 0
+ case AWFMINSB:
+ return op_VFMIN, 2, 0
}
}
@@ -1062,7 +1078,11 @@ func singleElementMask(as obj.As) uint32 {
AWFSQDB,
AWFSDB,
AWFTCIDB,
- AWFIDB:
+ AWFIDB,
+ AWFMAXDB,
+ AWFMAXSB,
+ AWFMINDB,
+ AWFMINSB:
return 8
}
return 0