cmd/internal/obj/arm64: refactor the extended/shifted register encoding to the backend

The current code encodes the register and the shift/extension into a.Offset
field and this is done in the frontend. The CL refactors it to have the
frontend record the register/shift/extension information in a.Reg or a.Index
and leave the encoding stuff for the backend.

Change-Id: I600f456aec95377b7b79cd58e94afcb30aca5d19
Reviewed-on: https://go-review.googlesource.com/106815
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
fanzha02 2018-04-08 12:36:30 +00:00 committed by Cherry Zhang
parent 50ccbe1fc2
commit 236c567ba9
3 changed files with 70 additions and 48 deletions

View file

@ -299,17 +299,7 @@ func Mconv(a *Addr) string {
case a.Offset == 0:
str = fmt.Sprintf("(%v)", Rconv(int(a.Reg)))
case a.Offset != 0:
switch objabi.GOARCH {
case "arm64":
// the register and the extension/shift are encoded in a.Offset.
if a.Index != 0 {
str = fmt.Sprintf("(%v)", Rconv(int(a.Reg)))
return str
}
fallthrough
default:
str = fmt.Sprintf("%d(%v)", a.Offset, Rconv(int(a.Reg)))
}
str = fmt.Sprintf("%d(%v)", a.Offset, Rconv(int(a.Reg)))
}
// Note: a.Reg == REG_NONE encodes the default base register for the NAME_ type.