examples/complex: and bugfixes
This commit is contained in:
@@ -46,11 +46,23 @@ func (a *Allocator) AddInterferenceSet(r reg.Register, s reg.Set) {
|
||||
}
|
||||
|
||||
func (a *Allocator) AddInterference(x, y reg.Register) {
|
||||
a.add(x)
|
||||
a.add(y)
|
||||
a.Add(x)
|
||||
a.Add(y)
|
||||
a.edges = append(a.edges, &edge{X: x, Y: y})
|
||||
}
|
||||
|
||||
// Add adds a register to be allocated. Does nothing if the register has already been added.
|
||||
func (a *Allocator) Add(r reg.Register) {
|
||||
v, ok := r.(reg.Virtual)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if _, found := a.possible[v]; found {
|
||||
return
|
||||
}
|
||||
a.possible[v] = a.registersofsize(v.Bytes())
|
||||
}
|
||||
|
||||
func (a *Allocator) Allocate() (reg.Allocation, error) {
|
||||
for a.remaining() > 0 {
|
||||
if err := a.update(); err != nil {
|
||||
@@ -65,15 +77,6 @@ func (a *Allocator) Allocate() (reg.Allocation, error) {
|
||||
return a.allocation, nil
|
||||
}
|
||||
|
||||
// add adds a register.
|
||||
func (a *Allocator) add(r reg.Register) {
|
||||
v, ok := r.(reg.Virtual)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
a.possible[v] = a.registersofsize(v.Bytes())
|
||||
}
|
||||
|
||||
// update possible allocations based on edges.
|
||||
func (a *Allocator) update() error {
|
||||
var rem []*edge
|
||||
|
||||
Reference in New Issue
Block a user