aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-01-26 17:25:44 -0800
committerGopher Robot <gobot@golang.org>2023-01-30 14:56:56 +0000
commitee5ce77c62483933ae4d5dbdbcbadf6f82dd3f6c (patch)
tree6c7c429a14a56a5a6703e701da5b2b5cb5138d39 /src/cmd/internal
parent49520907394c0a1060b51dc4a5d5ce1ac470a5f1 (diff)
downloadgo-ee5ce77c62483933ae4d5dbdbcbadf6f82dd3f6c.tar.xz
cmd/asm: reject avx512 .Z instructions without a mask register
Zeroing requires a non-K0 mask register be specified. (gcc enforces this when assembling.) The non-K0 restriction is already handled by the Yknot0 restriction. But if the mask register is missing altogether, we misassemble the instruction. Fixes #57952 Not sure if this is really worth mentioning in the release notes, but just in case I'll mark it. RELNOTE=yes Change-Id: I8f05d3155503f1f16d1b5ab9d67686fe5b64dfea Reviewed-on: https://go-review.googlesource.com/c/go/+/463229 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Илья Токарь <tocarip@gmail.com> Reviewed-by: Iskander Sharipov <quasilyte@gmail.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/obj/x86/asm6.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index de08b42ab5..b441964492 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -4070,6 +4070,16 @@ func (ab *AsmBuf) asmevex(ctxt *obj.Link, p *obj.Prog, rm, v, r, k *obj.Addr) {
if !evex.ZeroingEnabled() {
ctxt.Diag("unsupported zeroing: %v", p)
}
+ if k == nil {
+ // When you request zeroing you must specify a mask register.
+ // See issue 57952.
+ ctxt.Diag("mask register must be specified for .Z instructions: %v", p)
+ } else if k.Reg == REG_K0 {
+ // The mask register must not be K0. That restriction is already
+ // handled by the Yknot0 restriction in the opcode tables, so we
+ // won't ever reach here. But put something sensible here just in case.
+ ctxt.Diag("mask register must not be K0 for .Z instructions: %v", p)
+ }
evexZ = 1
}
switch {