support signatures and param load/stores

This commit is contained in:
Michael McLoughlin
2018-12-08 21:16:03 -08:00
parent 69ee0e39cb
commit 5431f2edef
9 changed files with 115 additions and 18 deletions

View File

@@ -109,6 +109,11 @@ func IsR64(op Op) bool {
return IsGP(op, 8)
}
// IsPseudo returns true if op is a pseudo register.
func IsPseudo(op Op) bool {
return IsRegisterKindSize(op, reg.Internal, 0)
}
// IsGP returns true if op is a general-purpose register of size n bytes.
func IsGP(op Op, n uint) bool {
return IsRegisterKindSize(op, reg.GP, n)
@@ -171,7 +176,12 @@ func IsM64(op Op) bool {
func IsMSize(op Op, n uint) bool {
// TODO(mbm): should memory operands have a size attribute as well?
m, ok := op.(Mem)
return ok && IsGP(m.Base, n) && (m.Index == nil || IsGP(m.Index, n))
return ok && IsMRegSize(m.Base, n) && (m.Index == nil || IsMRegSize(m.Index, n))
}
// IsMRegSize returns true if op is a register that can be used in a memory operand of size n bytes.
func IsMRegSize(op Op, n uint) bool {
return IsPseudo(op) || IsGP(op, n)
}
// IsM128 returns true if op is a 128-bit memory operand.