add reg.Type
This commit is contained in:
@@ -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.
|
// 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 {
|
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
|
return ok && r.Kind() == k && r.Bytes() == n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func LabelTarget(fn *avo.Function) error {
|
|||||||
return nil
|
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 {
|
func CFG(fn *avo.Function) error {
|
||||||
is := fn.Instructions()
|
is := fn.Instructions()
|
||||||
n := len(is)
|
n := len(is)
|
||||||
|
|||||||
24
reg/types.go
24
reg/types.go
@@ -1,5 +1,7 @@
|
|||||||
package reg
|
package reg
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
type Size uint
|
type Size uint
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -44,10 +46,16 @@ type private interface {
|
|||||||
private()
|
private()
|
||||||
}
|
}
|
||||||
|
|
||||||
type Virtual interface {
|
type Type interface {
|
||||||
VirtualID() uint16
|
|
||||||
Kind() Kind
|
Kind() Kind
|
||||||
Bytes() uint
|
Bytes() uint
|
||||||
|
Asm() string
|
||||||
|
private
|
||||||
|
}
|
||||||
|
|
||||||
|
type Virtual interface {
|
||||||
|
VirtualID() uint16
|
||||||
|
Type
|
||||||
}
|
}
|
||||||
|
|
||||||
type virtual struct {
|
type virtual struct {
|
||||||
@@ -59,13 +67,17 @@ type virtual struct {
|
|||||||
func (v virtual) VirtualID() uint16 { return v.id }
|
func (v virtual) VirtualID() uint16 { return v.id }
|
||||||
func (v virtual) Kind() Kind { return v.kind }
|
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 {
|
type Register interface {
|
||||||
PhysicalID() uint16
|
PhysicalID() uint16
|
||||||
Kind() Kind
|
|
||||||
Mask() uint16
|
Mask() uint16
|
||||||
Bytes() uint
|
Type
|
||||||
Asm() string
|
|
||||||
private
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type register struct {
|
type register struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user