Commit 4eb48a33 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/ssa: refactor ARM64 address folding

These patterns are the only uses of isArg and isAuto, and they all
follow a common pattern too. Extract out so that we can more easily
tweak the interface for isArg/isAuto.

Passes toolstash -cmp for linux/arm64.

Change-Id: I9c509dabdc123c93cb1ad2f34fe8c12a9f313f6d
Reviewed-on: https://go-review.googlesource.com/40490
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
parent 2e60882f
......@@ -284,6 +284,20 @@ func isAuto(s interface{}) bool {
return ok
}
func fitsARM64Offset(off, align int64, sym interface{}) bool {
// only small offset (between -256 and 256) or offset that is a multiple of data size
// can be encoded in the instructions
// since this rewriting takes place before stack allocation, the offset to SP is unknown,
// so don't do it for args and locals with unaligned offset
if !is32Bit(off) {
return false
}
if align == 1 {
return true
}
return !isArg(sym) && (off%align == 0 || off < 256 && off > -256 && !isAuto(sym))
}
// isSameSym returns whether sym is the same as the given named symbol
func isSameSym(sym interface{}, name string) bool {
s, ok := sym.(fmt.Stringer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment