Source file src/simd/archsimd/_gen/simdgen/gen_simdGenericOps.go

     1  // Copyright 2025 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  package main
     6  
     7  import (
     8  	"bytes"
     9  	"simd/archsimd/_gen/sgutil"
    10  )
    11  
    12  // writeSIMDGenericOps generates the generic ops for the current architecture,
    13  // merges them with existing ops from other architectures, and returns the
    14  // result as a buffer ready for writing.
    15  func writeSIMDGenericOps(ops []Operation, genericOpsFilePath string) *bytes.Buffer {
    16  	// Generate fresh ops for current arch.
    17  	currentArch := CurrentArch().Arch
    18  	var newOps []sgutil.GenericOpsData
    19  	for _, op := range ops {
    20  		if op.NoGenericOps != nil && *op.NoGenericOps == "true" {
    21  			continue
    22  		}
    23  		if op.SkipMaskedMethod() {
    24  			continue
    25  		}
    26  		_, _, _, immType, gOp, _ := op.shape()
    27  
    28  		newOps = append(newOps, sgutil.GenericOpsData{
    29  			OpName:  gOp.GenericName(),
    30  			OpInLen: len(gOp.In),
    31  			Comm:    op.Commutative,
    32  			HasAux:  immType == VarImm || immType == VarImmLim || immType == ConstVarImm,
    33  			Archs:   []string{currentArch},
    34  		})
    35  	}
    36  
    37  	buf := sgutil.MergeSIMDGenericOps(newOps, genericOpsFilePath, currentArch)
    38  
    39  	return buf
    40  }
    41  

View as plain text