Source file src/simd/archsimd/_gen/simdgen/arm64/load.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // NOTE: This currently only supports the advsimd (NEON) instruction class.
     6  
     7  package arm64
     8  
     9  import (
    10  	"sort"
    11  
    12  	"_gen/unify"
    13  
    14  	"golang.org/x/arch/arm64/instgen/xmlspec"
    15  )
    16  
    17  // ParseInstructions loads and parses ARM64 instruction definitions from XML files at given path.
    18  func ParseInstructions(path string) ([]*Instruction, error) {
    19  	xmlInsts := xmlspec.ParseXMLFiles(path)
    20  
    21  	var instructions []*Instruction
    22  	for _, xmlInst := range xmlInsts {
    23  		if xmlInst == nil {
    24  			continue
    25  		}
    26  		inst := &Instruction{Instruction: xmlInst.Instruction}
    27  		if inst.Mnemonic() == "" {
    28  			continue
    29  		}
    30  		if inst.InstrClass() != "advsimd" {
    31  			continue
    32  		}
    33  		instructions = append(instructions, inst)
    34  	}
    35  
    36  	sort.Slice(instructions, func(i, j int) bool {
    37  		return instructions[i].Mnemonic() < instructions[j].Mnemonic()
    38  	})
    39  
    40  	return instructions, nil
    41  }
    42  
    43  // Load loads ARM64 instruction definitions from XML files at given path and returns them as unify values.
    44  func Load(path string) ([]*unify.Value, error) {
    45  	instructions, err := ParseInstructions(path)
    46  	if err != nil {
    47  		return nil, err
    48  	}
    49  	var defs []*unify.Value
    50  	for _, instruction := range instructions {
    51  		defs = append(defs, instruction.EmitAll()...)
    52  	}
    53  	return defs, nil
    54  }
    55  

View as plain text