aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/arm64/inst.go
diff options
context:
space:
mode:
authorJunyang Shao <shaojunyang@google.com>2026-04-08 22:08:30 +0000
committerJunyang Shao <shaojunyang@google.com>2026-04-13 13:36:26 -0700
commit14685c05aae4e87c455f8489258ad9ee13b0273c (patch)
tree5e414827dc2145bc0be882c51a26a223da353c2a /src/cmd/internal/obj/arm64/inst.go
parent1aa9d9a69bbf1c9bf1a5806d554ab932c587efd0 (diff)
downloadgo-14685c05aae4e87c455f8489258ad9ee13b0273c.tar.xz
cmd/asm, cmd/internal/obj/arm64: support memory with extensions in SVE
This CL is generated by CL 764800. Supported addressing patterns: (Z7.D.SXTW<<2)(Z6.D), where Z6.D is the base, Z7.D is the indices. SXTW/UXTW represents signed/unsigned extension, << represents LSL. Change-Id: Ifc6c47833d5113be7cfe96943d369ab977b3a6ee Reviewed-on: https://go-review.googlesource.com/c/go/+/764780 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Junyang Shao <shaojunyang@google.com>
Diffstat (limited to 'src/cmd/internal/obj/arm64/inst.go')
-rw-r--r--src/cmd/internal/obj/arm64/inst.go40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/arm64/inst.go b/src/cmd/internal/obj/arm64/inst.go
index 688e990bcf..0bf4b9950d 100644
--- a/src/cmd/internal/obj/arm64/inst.go
+++ b/src/cmd/internal/obj/arm64/inst.go
@@ -143,6 +143,9 @@ func aclass(a *obj.Addr) AClass {
return AC_REGLIST4
}
}
+ if a.Type == obj.TYPE_MEM {
+ return AC_MEMEXT
+ }
panic("unknown AClass")
}
@@ -329,6 +332,39 @@ func addrComponent(a *obj.Addr, acl AClass, index int) uint32 {
default:
panic(fmt.Errorf("unknown elm index at %d in AClass %d", index, acl))
}
+ // AClass: AC_MEMEXT
+ // GNU mnemonic: [<reg1>.<T1>, <reg2>.<T2>, <mod> <amount>]
+ // Go mnemonic:
+ // (reg2.T2.mod<<amount)(reg1.T1)
+ // Encoding:
+ // Type = TYPE_MEM
+ // Reg = Index register (with arrangement if applicable)
+ // Index = Base register (with arrangement if applicable)
+ // Scale = Packed mod and amount
+ case AC_MEMEXT:
+ switch index {
+ case 0:
+ return uint32(a.Index)
+ case 1:
+ return uint32((a.Index >> 5) & 15)
+ case 2:
+ return uint32(a.Reg)
+ case 3:
+ return uint32((a.Reg >> 5) & 15)
+ case 4:
+ // mod is either 1 (UXTW), 2 (SXTW), or 4 (LSL)
+ mod := uint32((a.Scale >> 9) & 0x7)
+ amount := uint32((a.Scale >> 12) & 0x7)
+ if mod == 0 && amount > 0 {
+ // LSL is implied when no extension is specified but amount > 0
+ mod |= 1 << 2
+ }
+ return mod
+ case 5:
+ return uint32((a.Scale >> 12) & 0x7)
+ default:
+ panic(fmt.Errorf("unknown elm index at %d in AClass %d", index, acl))
+ }
}
// TODO: handle more AClasses.
panic(fmt.Errorf("unknown AClass %d", acl))
@@ -696,7 +732,8 @@ func (i *instEncoder) tryEncode(p *obj.Prog) (uint32, bool) {
}
return 0, false
}
- if enc.comp != enc_NIL {
+ if enc.comp != enc_NIL && specialB != codeNoOp {
+ // NoOp encodings don't need bookkeeping.
encoded[enc.comp] = b
}
} else {
@@ -704,6 +741,5 @@ func (i *instEncoder) tryEncode(p *obj.Prog) (uint32, bool) {
}
}
}
-
return bin, true
}