add reg.Type

This commit is contained in:
Michael McLoughlin
2018-12-02 15:15:00 -08:00
parent bc7d0fa410
commit f18271ada5
3 changed files with 20 additions and 8 deletions

View File

@@ -115,7 +115,7 @@ func IsYmm(op Op) bool {
// IsRegisterKindSize returns true if op is a register of the given kind and size in bytes.
func IsRegisterKindSize(op Op, k reg.Kind, n uint) bool {
r, ok := op.(reg.Register)
r, ok := op.(reg.Type)
return ok && r.Kind() == k && r.Bytes() == n
}

View File

@@ -37,7 +37,7 @@ func LabelTarget(fn *avo.Function) error {
return nil
}
// CFG constructs the call-flow-graph of each function.
// CFG constructs the call-flow-graph for the function.
func CFG(fn *avo.Function) error {
is := fn.Instructions()
n := len(is)

View File

@@ -1,5 +1,7 @@
package reg
import "fmt"
type Size uint
const (
@@ -44,10 +46,16 @@ type private interface {
private()
}
type Virtual interface {
VirtualID() uint16
type Type interface {
Kind() Kind
Bytes() uint
Asm() string
private
}
type Virtual interface {
VirtualID() uint16
Type
}
type virtual struct {
@@ -59,13 +67,17 @@ type virtual struct {
func (v virtual) VirtualID() uint16 { return v.id }
func (v virtual) Kind() Kind { return v.kind }
func (v virtual) Asm() string {
// TODO(mbm): decide on virtual register syntax
return fmt.Sprintf("<virtual:%v:%v:%v>", v.id, v.Kind(), v.Bytes())
}
func (v virtual) private() {}
type Register interface {
PhysicalID() uint16
Kind() Kind
Mask() uint16
Bytes() uint
Asm() string
private
Type
}
type register struct {