Debian Codegraph @

pass/isa.go

raw symbols SCIP
1 package pass
2
3 import (
4 "sort"
5
6 "github.com/mmcloughlin/avo/ir"
7 )
8
9 // RequiredISAExtensions determines ISA extensions required for the given
10 // function. Populates the ISA field.
11 func RequiredISAExtensions(fn *ir.Function) error {
12 // Collect ISA set.
13 set := map[string]bool{}
14 for _, i := range fn.Instructions() {
15 for _, isa := range i.ISA {
16 set[isa] = true
17 }
18 }
19
20 if len(set) == 0 {
21 return nil
22 }
23
24 // Populate the function's ISA field with the unique sorted list.
25 for isa := range set {
26 fn.ISA = append(fn.ISA, isa)
27 }
28 sort.Strings(fn.ISA)
29
30 return nil
31 }