All Downloads are FREE. Search and download functionalities are using the official Maven repository.

vendor.github.com.mmcloughlin.avo.pass.isa.go Maven / Gradle / Ivy

There is a newer version: 2.9.1
Show newest version
package pass

import (
	"sort"

	"github.com/mmcloughlin/avo/ir"
)

// RequiredISAExtensions determines ISA extensions required for the given
// function. Populates the ISA field.
func RequiredISAExtensions(fn *ir.Function) error {
	// Collect ISA set.
	set := map[string]bool{}
	for _, i := range fn.Instructions() {
		for _, isa := range i.ISA {
			set[isa] = true
		}
	}

	if len(set) == 0 {
		return nil
	}

	// Populate the function's ISA field with the unique sorted list.
	for isa := range set {
		fn.ISA = append(fn.ISA, isa)
	}
	sort.Strings(fn.ISA)

	return nil
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy