Source file src/simd/archsimd/types_sve.go

     1  // Code generated by 'simdgen -o godefs -goroot $GOROOT -arch sve -arm64Path $ARM64_ISA_PATH go_sve.yaml types.yaml categories.yaml'; DO NOT EDIT.
     2  
     3  //go:build goexperiment.simd && arm64
     4  
     5  package archsimd
     6  
     7  // psve is a tag type that tells the compiler that this is an SVE predicate.
     8  type psve struct {
     9  	_sve [0]func() // uncomparable
    10  }
    11  
    12  // v256 is a tag type that tells the compiler that this is really 256-bit SIMD
    13  type v256 struct {
    14  	_256 [0]func() // uncomparable
    15  }
    16  
    17  // Float32s is a scalable SIMD vector of float32s.
    18  type Float32s struct {
    19  	float32x8 v256
    20  	vals      [8]float32
    21  }
    22  
    23  // Len returns the number of elements in a Float32s.
    24  func (x Float32s) Len() int { return vl() / 4 }
    25  
    26  // LoadFloat32s loads a Float32s from the first Len() elements of s.
    27  // It panics if len(s) < Len().
    28  //
    29  // Asm: Emulated (a length check that can panic, then ZLDR).
    30  func LoadFloat32s(s []float32) Float32s {
    31  	var z Float32s
    32  	if len(s) < z.Len() {
    33  		panic("simd: LoadFloat32s: slice shorter than the vector")
    34  	}
    35  	return loadFloat32s(s)
    36  }
    37  
    38  //go:noescape
    39  func loadFloat32s(s []float32) Float32s
    40  
    41  // Store stores x's Len() elements into the first Len() elements of s. It panics
    42  // if len(s) < Len().
    43  //
    44  // Asm: Emulated (a length check that can panic, then ZSTR).
    45  func (x Float32s) Store(s []float32) {
    46  	if len(s) < x.Len() {
    47  		panic("simd: Float32s.Store: slice shorter than the vector")
    48  	}
    49  	x.store(s)
    50  }
    51  
    52  //go:noescape
    53  func (x Float32s) store(s []float32)
    54  
    55  // LoadFloat32sPart loads a Float32s from s, reading n = min(len(s),
    56  // Len()) elements and returning the vector and n; the remaining elements are
    57  // zero.
    58  //
    59  // Asm: Emulated (predicate construction + LD1B).
    60  func LoadFloat32sPart(s []float32) (Float32s, int) {
    61  	if len(s) == 0 {
    62  		return Float32s{}, 0
    63  	}
    64  	return loadFloat32sPart(s), min(len(s), Float32s{}.Len())
    65  }
    66  
    67  //go:noescape
    68  func loadFloat32sPart(s []float32) Float32s
    69  
    70  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
    71  // returns n.
    72  //
    73  // Asm: Emulated (predicate construction + ST1B).
    74  func (x Float32s) StorePart(s []float32) int {
    75  	if len(s) == 0 {
    76  		return 0
    77  	}
    78  	x.storePart(s)
    79  	return min(len(s), x.Len())
    80  }
    81  
    82  //go:noescape
    83  func (x Float32s) storePart(s []float32)
    84  
    85  // IfElse returns the elements of x where the corresponding element of mask is
    86  // true, and the elements of y where it is false.
    87  //
    88  // Asm: ZSEL
    89  func (x Float32s) IfElse(mask Mask32s, y Float32s) Float32s
    90  
    91  // Masked returns the elements of x where the corresponding element of mask is
    92  // true, and zero where it is false.
    93  //
    94  // Asm: Emulated
    95  func (x Float32s) Masked(mask Mask32s) Float32s {
    96  	var zero Float32s
    97  	return x.IfElse(mask, zero)
    98  }
    99  
   100  // String returns a string representation of SIMD vector x. Only the x.Len()
   101  // elements that exist at the runtime vector length are shown.
   102  func (x Float32s) String() string {
   103  	var s [8]float32
   104  	n := x.Len()
   105  	x.Store(s[:])
   106  	return sliceToString(s[:n])
   107  }
   108  
   109  // Float64s is a scalable SIMD vector of float64s.
   110  type Float64s struct {
   111  	float64x4 v256
   112  	vals      [4]float64
   113  }
   114  
   115  // Len returns the number of elements in a Float64s.
   116  func (x Float64s) Len() int { return vl() / 8 }
   117  
   118  // LoadFloat64s loads a Float64s from the first Len() elements of s.
   119  // It panics if len(s) < Len().
   120  //
   121  // Asm: Emulated (a length check that can panic, then ZLDR).
   122  func LoadFloat64s(s []float64) Float64s {
   123  	var z Float64s
   124  	if len(s) < z.Len() {
   125  		panic("simd: LoadFloat64s: slice shorter than the vector")
   126  	}
   127  	return loadFloat64s(s)
   128  }
   129  
   130  //go:noescape
   131  func loadFloat64s(s []float64) Float64s
   132  
   133  // Store stores x's Len() elements into the first Len() elements of s. It panics
   134  // if len(s) < Len().
   135  //
   136  // Asm: Emulated (a length check that can panic, then ZSTR).
   137  func (x Float64s) Store(s []float64) {
   138  	if len(s) < x.Len() {
   139  		panic("simd: Float64s.Store: slice shorter than the vector")
   140  	}
   141  	x.store(s)
   142  }
   143  
   144  //go:noescape
   145  func (x Float64s) store(s []float64)
   146  
   147  // LoadFloat64sPart loads a Float64s from s, reading n = min(len(s),
   148  // Len()) elements and returning the vector and n; the remaining elements are
   149  // zero.
   150  //
   151  // Asm: Emulated (predicate construction + LD1B).
   152  func LoadFloat64sPart(s []float64) (Float64s, int) {
   153  	if len(s) == 0 {
   154  		return Float64s{}, 0
   155  	}
   156  	return loadFloat64sPart(s), min(len(s), Float64s{}.Len())
   157  }
   158  
   159  //go:noescape
   160  func loadFloat64sPart(s []float64) Float64s
   161  
   162  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   163  // returns n.
   164  //
   165  // Asm: Emulated (predicate construction + ST1B).
   166  func (x Float64s) StorePart(s []float64) int {
   167  	if len(s) == 0 {
   168  		return 0
   169  	}
   170  	x.storePart(s)
   171  	return min(len(s), x.Len())
   172  }
   173  
   174  //go:noescape
   175  func (x Float64s) storePart(s []float64)
   176  
   177  // IfElse returns the elements of x where the corresponding element of mask is
   178  // true, and the elements of y where it is false.
   179  //
   180  // Asm: ZSEL
   181  func (x Float64s) IfElse(mask Mask64s, y Float64s) Float64s
   182  
   183  // Masked returns the elements of x where the corresponding element of mask is
   184  // true, and zero where it is false.
   185  //
   186  // Asm: Emulated
   187  func (x Float64s) Masked(mask Mask64s) Float64s {
   188  	var zero Float64s
   189  	return x.IfElse(mask, zero)
   190  }
   191  
   192  // String returns a string representation of SIMD vector x. Only the x.Len()
   193  // elements that exist at the runtime vector length are shown.
   194  func (x Float64s) String() string {
   195  	var s [4]float64
   196  	n := x.Len()
   197  	x.Store(s[:])
   198  	return sliceToString(s[:n])
   199  }
   200  
   201  // Int8s is a scalable SIMD vector of int8s.
   202  type Int8s struct {
   203  	int8x32 v256
   204  	vals    [32]int8
   205  }
   206  
   207  // Len returns the number of elements in an Int8s.
   208  func (x Int8s) Len() int { return vl() }
   209  
   210  // LoadInt8s loads an Int8s from the first Len() elements of s.
   211  // It panics if len(s) < Len().
   212  //
   213  // Asm: Emulated (a length check that can panic, then ZLDR).
   214  func LoadInt8s(s []int8) Int8s {
   215  	var z Int8s
   216  	if len(s) < z.Len() {
   217  		panic("simd: LoadInt8s: slice shorter than the vector")
   218  	}
   219  	return loadInt8s(s)
   220  }
   221  
   222  //go:noescape
   223  func loadInt8s(s []int8) Int8s
   224  
   225  // Store stores x's Len() elements into the first Len() elements of s. It panics
   226  // if len(s) < Len().
   227  //
   228  // Asm: Emulated (a length check that can panic, then ZSTR).
   229  func (x Int8s) Store(s []int8) {
   230  	if len(s) < x.Len() {
   231  		panic("simd: Int8s.Store: slice shorter than the vector")
   232  	}
   233  	x.store(s)
   234  }
   235  
   236  //go:noescape
   237  func (x Int8s) store(s []int8)
   238  
   239  // LoadInt8sPart loads an Int8s from s, reading n = min(len(s),
   240  // Len()) elements and returning the vector and n; the remaining elements are
   241  // zero.
   242  //
   243  // Asm: Emulated (predicate construction + LD1B).
   244  func LoadInt8sPart(s []int8) (Int8s, int) {
   245  	if len(s) == 0 {
   246  		return Int8s{}, 0
   247  	}
   248  	return loadInt8sPart(s), min(len(s), Int8s{}.Len())
   249  }
   250  
   251  //go:noescape
   252  func loadInt8sPart(s []int8) Int8s
   253  
   254  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   255  // returns n.
   256  //
   257  // Asm: Emulated (predicate construction + ST1B).
   258  func (x Int8s) StorePart(s []int8) int {
   259  	if len(s) == 0 {
   260  		return 0
   261  	}
   262  	x.storePart(s)
   263  	return min(len(s), x.Len())
   264  }
   265  
   266  //go:noescape
   267  func (x Int8s) storePart(s []int8)
   268  
   269  // IfElse returns the elements of x where the corresponding element of mask is
   270  // true, and the elements of y where it is false.
   271  //
   272  // Asm: ZSEL
   273  func (x Int8s) IfElse(mask Mask8s, y Int8s) Int8s
   274  
   275  // Masked returns the elements of x where the corresponding element of mask is
   276  // true, and zero where it is false.
   277  //
   278  // Asm: Emulated
   279  func (x Int8s) Masked(mask Mask8s) Int8s {
   280  	var zero Int8s
   281  	return x.IfElse(mask, zero)
   282  }
   283  
   284  // String returns a string representation of SIMD vector x. Only the x.Len()
   285  // elements that exist at the runtime vector length are shown.
   286  func (x Int8s) String() string {
   287  	var s [32]int8
   288  	n := x.Len()
   289  	x.Store(s[:])
   290  	return sliceToString(s[:n])
   291  }
   292  
   293  // Int16s is a scalable SIMD vector of int16s.
   294  type Int16s struct {
   295  	int16x16 v256
   296  	vals     [16]int16
   297  }
   298  
   299  // Len returns the number of elements in an Int16s.
   300  func (x Int16s) Len() int { return vl() / 2 }
   301  
   302  // LoadInt16s loads an Int16s from the first Len() elements of s.
   303  // It panics if len(s) < Len().
   304  //
   305  // Asm: Emulated (a length check that can panic, then ZLDR).
   306  func LoadInt16s(s []int16) Int16s {
   307  	var z Int16s
   308  	if len(s) < z.Len() {
   309  		panic("simd: LoadInt16s: slice shorter than the vector")
   310  	}
   311  	return loadInt16s(s)
   312  }
   313  
   314  //go:noescape
   315  func loadInt16s(s []int16) Int16s
   316  
   317  // Store stores x's Len() elements into the first Len() elements of s. It panics
   318  // if len(s) < Len().
   319  //
   320  // Asm: Emulated (a length check that can panic, then ZSTR).
   321  func (x Int16s) Store(s []int16) {
   322  	if len(s) < x.Len() {
   323  		panic("simd: Int16s.Store: slice shorter than the vector")
   324  	}
   325  	x.store(s)
   326  }
   327  
   328  //go:noescape
   329  func (x Int16s) store(s []int16)
   330  
   331  // LoadInt16sPart loads an Int16s from s, reading n = min(len(s),
   332  // Len()) elements and returning the vector and n; the remaining elements are
   333  // zero.
   334  //
   335  // Asm: Emulated (predicate construction + LD1B).
   336  func LoadInt16sPart(s []int16) (Int16s, int) {
   337  	if len(s) == 0 {
   338  		return Int16s{}, 0
   339  	}
   340  	return loadInt16sPart(s), min(len(s), Int16s{}.Len())
   341  }
   342  
   343  //go:noescape
   344  func loadInt16sPart(s []int16) Int16s
   345  
   346  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   347  // returns n.
   348  //
   349  // Asm: Emulated (predicate construction + ST1B).
   350  func (x Int16s) StorePart(s []int16) int {
   351  	if len(s) == 0 {
   352  		return 0
   353  	}
   354  	x.storePart(s)
   355  	return min(len(s), x.Len())
   356  }
   357  
   358  //go:noescape
   359  func (x Int16s) storePart(s []int16)
   360  
   361  // IfElse returns the elements of x where the corresponding element of mask is
   362  // true, and the elements of y where it is false.
   363  //
   364  // Asm: ZSEL
   365  func (x Int16s) IfElse(mask Mask16s, y Int16s) Int16s
   366  
   367  // Masked returns the elements of x where the corresponding element of mask is
   368  // true, and zero where it is false.
   369  //
   370  // Asm: Emulated
   371  func (x Int16s) Masked(mask Mask16s) Int16s {
   372  	var zero Int16s
   373  	return x.IfElse(mask, zero)
   374  }
   375  
   376  // String returns a string representation of SIMD vector x. Only the x.Len()
   377  // elements that exist at the runtime vector length are shown.
   378  func (x Int16s) String() string {
   379  	var s [16]int16
   380  	n := x.Len()
   381  	x.Store(s[:])
   382  	return sliceToString(s[:n])
   383  }
   384  
   385  // Int32s is a scalable SIMD vector of int32s.
   386  type Int32s struct {
   387  	int32x8 v256
   388  	vals    [8]int32
   389  }
   390  
   391  // Len returns the number of elements in an Int32s.
   392  func (x Int32s) Len() int { return vl() / 4 }
   393  
   394  // LoadInt32s loads an Int32s from the first Len() elements of s.
   395  // It panics if len(s) < Len().
   396  //
   397  // Asm: Emulated (a length check that can panic, then ZLDR).
   398  func LoadInt32s(s []int32) Int32s {
   399  	var z Int32s
   400  	if len(s) < z.Len() {
   401  		panic("simd: LoadInt32s: slice shorter than the vector")
   402  	}
   403  	return loadInt32s(s)
   404  }
   405  
   406  //go:noescape
   407  func loadInt32s(s []int32) Int32s
   408  
   409  // Store stores x's Len() elements into the first Len() elements of s. It panics
   410  // if len(s) < Len().
   411  //
   412  // Asm: Emulated (a length check that can panic, then ZSTR).
   413  func (x Int32s) Store(s []int32) {
   414  	if len(s) < x.Len() {
   415  		panic("simd: Int32s.Store: slice shorter than the vector")
   416  	}
   417  	x.store(s)
   418  }
   419  
   420  //go:noescape
   421  func (x Int32s) store(s []int32)
   422  
   423  // LoadInt32sPart loads an Int32s from s, reading n = min(len(s),
   424  // Len()) elements and returning the vector and n; the remaining elements are
   425  // zero.
   426  //
   427  // Asm: Emulated (predicate construction + LD1B).
   428  func LoadInt32sPart(s []int32) (Int32s, int) {
   429  	if len(s) == 0 {
   430  		return Int32s{}, 0
   431  	}
   432  	return loadInt32sPart(s), min(len(s), Int32s{}.Len())
   433  }
   434  
   435  //go:noescape
   436  func loadInt32sPart(s []int32) Int32s
   437  
   438  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   439  // returns n.
   440  //
   441  // Asm: Emulated (predicate construction + ST1B).
   442  func (x Int32s) StorePart(s []int32) int {
   443  	if len(s) == 0 {
   444  		return 0
   445  	}
   446  	x.storePart(s)
   447  	return min(len(s), x.Len())
   448  }
   449  
   450  //go:noescape
   451  func (x Int32s) storePart(s []int32)
   452  
   453  // IfElse returns the elements of x where the corresponding element of mask is
   454  // true, and the elements of y where it is false.
   455  //
   456  // Asm: ZSEL
   457  func (x Int32s) IfElse(mask Mask32s, y Int32s) Int32s
   458  
   459  // Masked returns the elements of x where the corresponding element of mask is
   460  // true, and zero where it is false.
   461  //
   462  // Asm: Emulated
   463  func (x Int32s) Masked(mask Mask32s) Int32s {
   464  	var zero Int32s
   465  	return x.IfElse(mask, zero)
   466  }
   467  
   468  // String returns a string representation of SIMD vector x. Only the x.Len()
   469  // elements that exist at the runtime vector length are shown.
   470  func (x Int32s) String() string {
   471  	var s [8]int32
   472  	n := x.Len()
   473  	x.Store(s[:])
   474  	return sliceToString(s[:n])
   475  }
   476  
   477  // Int64s is a scalable SIMD vector of int64s.
   478  type Int64s struct {
   479  	int64x4 v256
   480  	vals    [4]int64
   481  }
   482  
   483  // Len returns the number of elements in an Int64s.
   484  func (x Int64s) Len() int { return vl() / 8 }
   485  
   486  // LoadInt64s loads an Int64s from the first Len() elements of s.
   487  // It panics if len(s) < Len().
   488  //
   489  // Asm: Emulated (a length check that can panic, then ZLDR).
   490  func LoadInt64s(s []int64) Int64s {
   491  	var z Int64s
   492  	if len(s) < z.Len() {
   493  		panic("simd: LoadInt64s: slice shorter than the vector")
   494  	}
   495  	return loadInt64s(s)
   496  }
   497  
   498  //go:noescape
   499  func loadInt64s(s []int64) Int64s
   500  
   501  // Store stores x's Len() elements into the first Len() elements of s. It panics
   502  // if len(s) < Len().
   503  //
   504  // Asm: Emulated (a length check that can panic, then ZSTR).
   505  func (x Int64s) Store(s []int64) {
   506  	if len(s) < x.Len() {
   507  		panic("simd: Int64s.Store: slice shorter than the vector")
   508  	}
   509  	x.store(s)
   510  }
   511  
   512  //go:noescape
   513  func (x Int64s) store(s []int64)
   514  
   515  // LoadInt64sPart loads an Int64s from s, reading n = min(len(s),
   516  // Len()) elements and returning the vector and n; the remaining elements are
   517  // zero.
   518  //
   519  // Asm: Emulated (predicate construction + LD1B).
   520  func LoadInt64sPart(s []int64) (Int64s, int) {
   521  	if len(s) == 0 {
   522  		return Int64s{}, 0
   523  	}
   524  	return loadInt64sPart(s), min(len(s), Int64s{}.Len())
   525  }
   526  
   527  //go:noescape
   528  func loadInt64sPart(s []int64) Int64s
   529  
   530  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   531  // returns n.
   532  //
   533  // Asm: Emulated (predicate construction + ST1B).
   534  func (x Int64s) StorePart(s []int64) int {
   535  	if len(s) == 0 {
   536  		return 0
   537  	}
   538  	x.storePart(s)
   539  	return min(len(s), x.Len())
   540  }
   541  
   542  //go:noescape
   543  func (x Int64s) storePart(s []int64)
   544  
   545  // IfElse returns the elements of x where the corresponding element of mask is
   546  // true, and the elements of y where it is false.
   547  //
   548  // Asm: ZSEL
   549  func (x Int64s) IfElse(mask Mask64s, y Int64s) Int64s
   550  
   551  // Masked returns the elements of x where the corresponding element of mask is
   552  // true, and zero where it is false.
   553  //
   554  // Asm: Emulated
   555  func (x Int64s) Masked(mask Mask64s) Int64s {
   556  	var zero Int64s
   557  	return x.IfElse(mask, zero)
   558  }
   559  
   560  // String returns a string representation of SIMD vector x. Only the x.Len()
   561  // elements that exist at the runtime vector length are shown.
   562  func (x Int64s) String() string {
   563  	var s [4]int64
   564  	n := x.Len()
   565  	x.Store(s[:])
   566  	return sliceToString(s[:n])
   567  }
   568  
   569  // Uint8s is a scalable SIMD vector of uint8s.
   570  type Uint8s struct {
   571  	uint8x32 v256
   572  	vals     [32]uint8
   573  }
   574  
   575  // Len returns the number of elements in a Uint8s.
   576  func (x Uint8s) Len() int { return vl() }
   577  
   578  // LoadUint8s loads a Uint8s from the first Len() elements of s.
   579  // It panics if len(s) < Len().
   580  //
   581  // Asm: Emulated (a length check that can panic, then ZLDR).
   582  func LoadUint8s(s []uint8) Uint8s {
   583  	var z Uint8s
   584  	if len(s) < z.Len() {
   585  		panic("simd: LoadUint8s: slice shorter than the vector")
   586  	}
   587  	return loadUint8s(s)
   588  }
   589  
   590  //go:noescape
   591  func loadUint8s(s []uint8) Uint8s
   592  
   593  // Store stores x's Len() elements into the first Len() elements of s. It panics
   594  // if len(s) < Len().
   595  //
   596  // Asm: Emulated (a length check that can panic, then ZSTR).
   597  func (x Uint8s) Store(s []uint8) {
   598  	if len(s) < x.Len() {
   599  		panic("simd: Uint8s.Store: slice shorter than the vector")
   600  	}
   601  	x.store(s)
   602  }
   603  
   604  //go:noescape
   605  func (x Uint8s) store(s []uint8)
   606  
   607  // LoadUint8sPart loads a Uint8s from s, reading n = min(len(s),
   608  // Len()) elements and returning the vector and n; the remaining elements are
   609  // zero.
   610  //
   611  // Asm: Emulated (predicate construction + LD1B).
   612  func LoadUint8sPart(s []uint8) (Uint8s, int) {
   613  	if len(s) == 0 {
   614  		return Uint8s{}, 0
   615  	}
   616  	return loadUint8sPart(s), min(len(s), Uint8s{}.Len())
   617  }
   618  
   619  //go:noescape
   620  func loadUint8sPart(s []uint8) Uint8s
   621  
   622  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   623  // returns n.
   624  //
   625  // Asm: Emulated (predicate construction + ST1B).
   626  func (x Uint8s) StorePart(s []uint8) int {
   627  	if len(s) == 0 {
   628  		return 0
   629  	}
   630  	x.storePart(s)
   631  	return min(len(s), x.Len())
   632  }
   633  
   634  //go:noescape
   635  func (x Uint8s) storePart(s []uint8)
   636  
   637  // IfElse returns the elements of x where the corresponding element of mask is
   638  // true, and the elements of y where it is false.
   639  //
   640  // Asm: ZSEL
   641  func (x Uint8s) IfElse(mask Mask8s, y Uint8s) Uint8s
   642  
   643  // Masked returns the elements of x where the corresponding element of mask is
   644  // true, and zero where it is false.
   645  //
   646  // Asm: Emulated
   647  func (x Uint8s) Masked(mask Mask8s) Uint8s {
   648  	var zero Uint8s
   649  	return x.IfElse(mask, zero)
   650  }
   651  
   652  // String returns a string representation of SIMD vector x. Only the x.Len()
   653  // elements that exist at the runtime vector length are shown.
   654  func (x Uint8s) String() string {
   655  	var s [32]uint8
   656  	n := x.Len()
   657  	x.Store(s[:])
   658  	return sliceToString(s[:n])
   659  }
   660  
   661  // Uint16s is a scalable SIMD vector of uint16s.
   662  type Uint16s struct {
   663  	uint16x16 v256
   664  	vals      [16]uint16
   665  }
   666  
   667  // Len returns the number of elements in a Uint16s.
   668  func (x Uint16s) Len() int { return vl() / 2 }
   669  
   670  // LoadUint16s loads a Uint16s from the first Len() elements of s.
   671  // It panics if len(s) < Len().
   672  //
   673  // Asm: Emulated (a length check that can panic, then ZLDR).
   674  func LoadUint16s(s []uint16) Uint16s {
   675  	var z Uint16s
   676  	if len(s) < z.Len() {
   677  		panic("simd: LoadUint16s: slice shorter than the vector")
   678  	}
   679  	return loadUint16s(s)
   680  }
   681  
   682  //go:noescape
   683  func loadUint16s(s []uint16) Uint16s
   684  
   685  // Store stores x's Len() elements into the first Len() elements of s. It panics
   686  // if len(s) < Len().
   687  //
   688  // Asm: Emulated (a length check that can panic, then ZSTR).
   689  func (x Uint16s) Store(s []uint16) {
   690  	if len(s) < x.Len() {
   691  		panic("simd: Uint16s.Store: slice shorter than the vector")
   692  	}
   693  	x.store(s)
   694  }
   695  
   696  //go:noescape
   697  func (x Uint16s) store(s []uint16)
   698  
   699  // LoadUint16sPart loads a Uint16s from s, reading n = min(len(s),
   700  // Len()) elements and returning the vector and n; the remaining elements are
   701  // zero.
   702  //
   703  // Asm: Emulated (predicate construction + LD1B).
   704  func LoadUint16sPart(s []uint16) (Uint16s, int) {
   705  	if len(s) == 0 {
   706  		return Uint16s{}, 0
   707  	}
   708  	return loadUint16sPart(s), min(len(s), Uint16s{}.Len())
   709  }
   710  
   711  //go:noescape
   712  func loadUint16sPart(s []uint16) Uint16s
   713  
   714  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   715  // returns n.
   716  //
   717  // Asm: Emulated (predicate construction + ST1B).
   718  func (x Uint16s) StorePart(s []uint16) int {
   719  	if len(s) == 0 {
   720  		return 0
   721  	}
   722  	x.storePart(s)
   723  	return min(len(s), x.Len())
   724  }
   725  
   726  //go:noescape
   727  func (x Uint16s) storePart(s []uint16)
   728  
   729  // IfElse returns the elements of x where the corresponding element of mask is
   730  // true, and the elements of y where it is false.
   731  //
   732  // Asm: ZSEL
   733  func (x Uint16s) IfElse(mask Mask16s, y Uint16s) Uint16s
   734  
   735  // Masked returns the elements of x where the corresponding element of mask is
   736  // true, and zero where it is false.
   737  //
   738  // Asm: Emulated
   739  func (x Uint16s) Masked(mask Mask16s) Uint16s {
   740  	var zero Uint16s
   741  	return x.IfElse(mask, zero)
   742  }
   743  
   744  // String returns a string representation of SIMD vector x. Only the x.Len()
   745  // elements that exist at the runtime vector length are shown.
   746  func (x Uint16s) String() string {
   747  	var s [16]uint16
   748  	n := x.Len()
   749  	x.Store(s[:])
   750  	return sliceToString(s[:n])
   751  }
   752  
   753  // Uint32s is a scalable SIMD vector of uint32s.
   754  type Uint32s struct {
   755  	uint32x8 v256
   756  	vals     [8]uint32
   757  }
   758  
   759  // Len returns the number of elements in a Uint32s.
   760  func (x Uint32s) Len() int { return vl() / 4 }
   761  
   762  // LoadUint32s loads a Uint32s from the first Len() elements of s.
   763  // It panics if len(s) < Len().
   764  //
   765  // Asm: Emulated (a length check that can panic, then ZLDR).
   766  func LoadUint32s(s []uint32) Uint32s {
   767  	var z Uint32s
   768  	if len(s) < z.Len() {
   769  		panic("simd: LoadUint32s: slice shorter than the vector")
   770  	}
   771  	return loadUint32s(s)
   772  }
   773  
   774  //go:noescape
   775  func loadUint32s(s []uint32) Uint32s
   776  
   777  // Store stores x's Len() elements into the first Len() elements of s. It panics
   778  // if len(s) < Len().
   779  //
   780  // Asm: Emulated (a length check that can panic, then ZSTR).
   781  func (x Uint32s) Store(s []uint32) {
   782  	if len(s) < x.Len() {
   783  		panic("simd: Uint32s.Store: slice shorter than the vector")
   784  	}
   785  	x.store(s)
   786  }
   787  
   788  //go:noescape
   789  func (x Uint32s) store(s []uint32)
   790  
   791  // LoadUint32sPart loads a Uint32s from s, reading n = min(len(s),
   792  // Len()) elements and returning the vector and n; the remaining elements are
   793  // zero.
   794  //
   795  // Asm: Emulated (predicate construction + LD1B).
   796  func LoadUint32sPart(s []uint32) (Uint32s, int) {
   797  	if len(s) == 0 {
   798  		return Uint32s{}, 0
   799  	}
   800  	return loadUint32sPart(s), min(len(s), Uint32s{}.Len())
   801  }
   802  
   803  //go:noescape
   804  func loadUint32sPart(s []uint32) Uint32s
   805  
   806  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   807  // returns n.
   808  //
   809  // Asm: Emulated (predicate construction + ST1B).
   810  func (x Uint32s) StorePart(s []uint32) int {
   811  	if len(s) == 0 {
   812  		return 0
   813  	}
   814  	x.storePart(s)
   815  	return min(len(s), x.Len())
   816  }
   817  
   818  //go:noescape
   819  func (x Uint32s) storePart(s []uint32)
   820  
   821  // IfElse returns the elements of x where the corresponding element of mask is
   822  // true, and the elements of y where it is false.
   823  //
   824  // Asm: ZSEL
   825  func (x Uint32s) IfElse(mask Mask32s, y Uint32s) Uint32s
   826  
   827  // Masked returns the elements of x where the corresponding element of mask is
   828  // true, and zero where it is false.
   829  //
   830  // Asm: Emulated
   831  func (x Uint32s) Masked(mask Mask32s) Uint32s {
   832  	var zero Uint32s
   833  	return x.IfElse(mask, zero)
   834  }
   835  
   836  // String returns a string representation of SIMD vector x. Only the x.Len()
   837  // elements that exist at the runtime vector length are shown.
   838  func (x Uint32s) String() string {
   839  	var s [8]uint32
   840  	n := x.Len()
   841  	x.Store(s[:])
   842  	return sliceToString(s[:n])
   843  }
   844  
   845  // Uint64s is a scalable SIMD vector of uint64s.
   846  type Uint64s struct {
   847  	uint64x4 v256
   848  	vals     [4]uint64
   849  }
   850  
   851  // Len returns the number of elements in a Uint64s.
   852  func (x Uint64s) Len() int { return vl() / 8 }
   853  
   854  // LoadUint64s loads a Uint64s from the first Len() elements of s.
   855  // It panics if len(s) < Len().
   856  //
   857  // Asm: Emulated (a length check that can panic, then ZLDR).
   858  func LoadUint64s(s []uint64) Uint64s {
   859  	var z Uint64s
   860  	if len(s) < z.Len() {
   861  		panic("simd: LoadUint64s: slice shorter than the vector")
   862  	}
   863  	return loadUint64s(s)
   864  }
   865  
   866  //go:noescape
   867  func loadUint64s(s []uint64) Uint64s
   868  
   869  // Store stores x's Len() elements into the first Len() elements of s. It panics
   870  // if len(s) < Len().
   871  //
   872  // Asm: Emulated (a length check that can panic, then ZSTR).
   873  func (x Uint64s) Store(s []uint64) {
   874  	if len(s) < x.Len() {
   875  		panic("simd: Uint64s.Store: slice shorter than the vector")
   876  	}
   877  	x.store(s)
   878  }
   879  
   880  //go:noescape
   881  func (x Uint64s) store(s []uint64)
   882  
   883  // LoadUint64sPart loads a Uint64s from s, reading n = min(len(s),
   884  // Len()) elements and returning the vector and n; the remaining elements are
   885  // zero.
   886  //
   887  // Asm: Emulated (predicate construction + LD1B).
   888  func LoadUint64sPart(s []uint64) (Uint64s, int) {
   889  	if len(s) == 0 {
   890  		return Uint64s{}, 0
   891  	}
   892  	return loadUint64sPart(s), min(len(s), Uint64s{}.Len())
   893  }
   894  
   895  //go:noescape
   896  func loadUint64sPart(s []uint64) Uint64s
   897  
   898  // StorePart stores the low n = min(len(s), Len()) elements of x into s and
   899  // returns n.
   900  //
   901  // Asm: Emulated (predicate construction + ST1B).
   902  func (x Uint64s) StorePart(s []uint64) int {
   903  	if len(s) == 0 {
   904  		return 0
   905  	}
   906  	x.storePart(s)
   907  	return min(len(s), x.Len())
   908  }
   909  
   910  //go:noescape
   911  func (x Uint64s) storePart(s []uint64)
   912  
   913  // IfElse returns the elements of x where the corresponding element of mask is
   914  // true, and the elements of y where it is false.
   915  //
   916  // Asm: ZSEL
   917  func (x Uint64s) IfElse(mask Mask64s, y Uint64s) Uint64s
   918  
   919  // Masked returns the elements of x where the corresponding element of mask is
   920  // true, and zero where it is false.
   921  //
   922  // Asm: Emulated
   923  func (x Uint64s) Masked(mask Mask64s) Uint64s {
   924  	var zero Uint64s
   925  	return x.IfElse(mask, zero)
   926  }
   927  
   928  // String returns a string representation of SIMD vector x. Only the x.Len()
   929  // elements that exist at the runtime vector length are shown.
   930  func (x Uint64s) String() string {
   931  	var s [4]uint64
   932  	n := x.Len()
   933  	x.Store(s[:])
   934  	return sliceToString(s[:n])
   935  }
   936  
   937  // Mask8s is a scalable mask for a SIMD vector of 8-bit elements.
   938  //
   939  // An SVE predicate holds one bit per byte of the vector it governs, so a
   940  // Mask8s carries one bit for each byte of the runtime vector length, and
   941  // lane i is governed by bit i.
   942  type Mask8s struct {
   943  	mask8s psve
   944  	vals   uint32
   945  }
   946  
   947  // LoadMask8s loads a Mask8s from the predicate bits packed into bits.
   948  // The bits are concatenated in little-endian order: bit i of bits[j] governs
   949  // vector byte 16*j+i, and so lane k is governed by bit k.
   950  //
   951  // One uint16 covers 16 bytes of vector, the length of the smallest vector SVE
   952  // defines, so bits must hold one uint16 per 16 bytes of the runtime vector
   953  // length. LoadMask8s panics if bits is shorter than that.
   954  //
   955  // Asm: Emulated (a length check that can panic, then PLDR (predicate)).
   956  func LoadMask8s(bits []uint16) Mask8s {
   957  	if len(bits) < (vl()+15)/16 {
   958  		panic("simd: LoadMask8s: bits is too short to hold the predicate")
   959  	}
   960  	return loadMask8s(bits)
   961  }
   962  
   963  //go:noescape
   964  func loadMask8s(bits []uint16) Mask8s
   965  
   966  // Store stores m's predicate bits into bits, concatenated in little-endian
   967  // order: bit i of bits[j] governs vector byte 16*j+i, and so lane k is
   968  // governed by bit k.
   969  //
   970  // bits must hold one uint16 per 16 bytes of the runtime vector length; Store
   971  // panics if it is shorter.
   972  //
   973  // Asm: Emulated (a length check that can panic, then PSTR (predicate)).
   974  func (m Mask8s) Store(bits []uint16) {
   975  	if len(bits) < (vl()+15)/16 {
   976  		panic("simd: Mask8s.Store: bits is too short to hold the predicate")
   977  	}
   978  	m.store(bits)
   979  }
   980  
   981  //go:noescape
   982  func (m Mask8s) store(bits []uint16)
   983  
   984  // String returns a string representation of SIMD mask m: 1 for an active lane,
   985  // 0 for an inactive one. Only the vl() lanes that exist at the runtime
   986  // vector length are shown.
   987  func (m Mask8s) String() string {
   988  	var bits [2]uint16
   989  	m.Store(bits[:])
   990  	var s [32]int8
   991  	n := vl()
   992  	for i := range n {
   993  		if b := i; bits[b/16]>>(b%16)&1 != 0 {
   994  			s[i] = 1
   995  		}
   996  	}
   997  	return sliceToString(s[:n])
   998  }
   999  
  1000  // Mask16s is a scalable mask for a SIMD vector of 16-bit elements.
  1001  //
  1002  // An SVE predicate holds one bit per byte of the vector it governs, so a
  1003  // Mask16s carries one bit for each byte of the runtime vector length, and
  1004  // lane i is governed by bit 2*i. The bits in between are ignored.
  1005  type Mask16s struct {
  1006  	mask16s psve
  1007  	vals    uint32
  1008  }
  1009  
  1010  // LoadMask16s loads a Mask16s from the predicate bits packed into bits.
  1011  // The bits are concatenated in little-endian order: bit i of bits[j] governs
  1012  // vector byte 16*j+i, and so lane k is governed by bit 2*k.
  1013  //
  1014  // One uint16 covers 16 bytes of vector, the length of the smallest vector SVE
  1015  // defines, so bits must hold one uint16 per 16 bytes of the runtime vector
  1016  // length. LoadMask16s panics if bits is shorter than that.
  1017  //
  1018  // Asm: Emulated (a length check that can panic, then PLDR (predicate)).
  1019  func LoadMask16s(bits []uint16) Mask16s {
  1020  	if len(bits) < (vl()+15)/16 {
  1021  		panic("simd: LoadMask16s: bits is too short to hold the predicate")
  1022  	}
  1023  	return loadMask16s(bits)
  1024  }
  1025  
  1026  //go:noescape
  1027  func loadMask16s(bits []uint16) Mask16s
  1028  
  1029  // Store stores m's predicate bits into bits, concatenated in little-endian
  1030  // order: bit i of bits[j] governs vector byte 16*j+i, and so lane k is
  1031  // governed by bit 2*k.
  1032  //
  1033  // bits must hold one uint16 per 16 bytes of the runtime vector length; Store
  1034  // panics if it is shorter.
  1035  //
  1036  // Asm: Emulated (a length check that can panic, then PSTR (predicate)).
  1037  func (m Mask16s) Store(bits []uint16) {
  1038  	if len(bits) < (vl()+15)/16 {
  1039  		panic("simd: Mask16s.Store: bits is too short to hold the predicate")
  1040  	}
  1041  	m.store(bits)
  1042  }
  1043  
  1044  //go:noescape
  1045  func (m Mask16s) store(bits []uint16)
  1046  
  1047  // String returns a string representation of SIMD mask m: 1 for an active lane,
  1048  // 0 for an inactive one. Only the vl() / 2 lanes that exist at the runtime
  1049  // vector length are shown.
  1050  func (m Mask16s) String() string {
  1051  	var bits [2]uint16
  1052  	m.Store(bits[:])
  1053  	var s [16]int16
  1054  	n := vl() / 2
  1055  	for i := range n {
  1056  		if b := i * 2; bits[b/16]>>(b%16)&1 != 0 {
  1057  			s[i] = 1
  1058  		}
  1059  	}
  1060  	return sliceToString(s[:n])
  1061  }
  1062  
  1063  // Mask32s is a scalable mask for a SIMD vector of 32-bit elements.
  1064  //
  1065  // An SVE predicate holds one bit per byte of the vector it governs, so a
  1066  // Mask32s carries one bit for each byte of the runtime vector length, and
  1067  // lane i is governed by bit 4*i. The bits in between are ignored.
  1068  type Mask32s struct {
  1069  	mask32s psve
  1070  	vals    uint32
  1071  }
  1072  
  1073  // LoadMask32s loads a Mask32s from the predicate bits packed into bits.
  1074  // The bits are concatenated in little-endian order: bit i of bits[j] governs
  1075  // vector byte 16*j+i, and so lane k is governed by bit 4*k.
  1076  //
  1077  // One uint16 covers 16 bytes of vector, the length of the smallest vector SVE
  1078  // defines, so bits must hold one uint16 per 16 bytes of the runtime vector
  1079  // length. LoadMask32s panics if bits is shorter than that.
  1080  //
  1081  // Asm: Emulated (a length check that can panic, then PLDR (predicate)).
  1082  func LoadMask32s(bits []uint16) Mask32s {
  1083  	if len(bits) < (vl()+15)/16 {
  1084  		panic("simd: LoadMask32s: bits is too short to hold the predicate")
  1085  	}
  1086  	return loadMask32s(bits)
  1087  }
  1088  
  1089  //go:noescape
  1090  func loadMask32s(bits []uint16) Mask32s
  1091  
  1092  // Store stores m's predicate bits into bits, concatenated in little-endian
  1093  // order: bit i of bits[j] governs vector byte 16*j+i, and so lane k is
  1094  // governed by bit 4*k.
  1095  //
  1096  // bits must hold one uint16 per 16 bytes of the runtime vector length; Store
  1097  // panics if it is shorter.
  1098  //
  1099  // Asm: Emulated (a length check that can panic, then PSTR (predicate)).
  1100  func (m Mask32s) Store(bits []uint16) {
  1101  	if len(bits) < (vl()+15)/16 {
  1102  		panic("simd: Mask32s.Store: bits is too short to hold the predicate")
  1103  	}
  1104  	m.store(bits)
  1105  }
  1106  
  1107  //go:noescape
  1108  func (m Mask32s) store(bits []uint16)
  1109  
  1110  // String returns a string representation of SIMD mask m: 1 for an active lane,
  1111  // 0 for an inactive one. Only the vl() / 4 lanes that exist at the runtime
  1112  // vector length are shown.
  1113  func (m Mask32s) String() string {
  1114  	var bits [2]uint16
  1115  	m.Store(bits[:])
  1116  	var s [8]int32
  1117  	n := vl() / 4
  1118  	for i := range n {
  1119  		if b := i * 4; bits[b/16]>>(b%16)&1 != 0 {
  1120  			s[i] = 1
  1121  		}
  1122  	}
  1123  	return sliceToString(s[:n])
  1124  }
  1125  
  1126  // Mask64s is a scalable mask for a SIMD vector of 64-bit elements.
  1127  //
  1128  // An SVE predicate holds one bit per byte of the vector it governs, so a
  1129  // Mask64s carries one bit for each byte of the runtime vector length, and
  1130  // lane i is governed by bit 8*i. The bits in between are ignored.
  1131  type Mask64s struct {
  1132  	mask64s psve
  1133  	vals    uint32
  1134  }
  1135  
  1136  // LoadMask64s loads a Mask64s from the predicate bits packed into bits.
  1137  // The bits are concatenated in little-endian order: bit i of bits[j] governs
  1138  // vector byte 16*j+i, and so lane k is governed by bit 8*k.
  1139  //
  1140  // One uint16 covers 16 bytes of vector, the length of the smallest vector SVE
  1141  // defines, so bits must hold one uint16 per 16 bytes of the runtime vector
  1142  // length. LoadMask64s panics if bits is shorter than that.
  1143  //
  1144  // Asm: Emulated (a length check that can panic, then PLDR (predicate)).
  1145  func LoadMask64s(bits []uint16) Mask64s {
  1146  	if len(bits) < (vl()+15)/16 {
  1147  		panic("simd: LoadMask64s: bits is too short to hold the predicate")
  1148  	}
  1149  	return loadMask64s(bits)
  1150  }
  1151  
  1152  //go:noescape
  1153  func loadMask64s(bits []uint16) Mask64s
  1154  
  1155  // Store stores m's predicate bits into bits, concatenated in little-endian
  1156  // order: bit i of bits[j] governs vector byte 16*j+i, and so lane k is
  1157  // governed by bit 8*k.
  1158  //
  1159  // bits must hold one uint16 per 16 bytes of the runtime vector length; Store
  1160  // panics if it is shorter.
  1161  //
  1162  // Asm: Emulated (a length check that can panic, then PSTR (predicate)).
  1163  func (m Mask64s) Store(bits []uint16) {
  1164  	if len(bits) < (vl()+15)/16 {
  1165  		panic("simd: Mask64s.Store: bits is too short to hold the predicate")
  1166  	}
  1167  	m.store(bits)
  1168  }
  1169  
  1170  //go:noescape
  1171  func (m Mask64s) store(bits []uint16)
  1172  
  1173  // String returns a string representation of SIMD mask m: 1 for an active lane,
  1174  // 0 for an inactive one. Only the vl() / 8 lanes that exist at the runtime
  1175  // vector length are shown.
  1176  func (m Mask64s) String() string {
  1177  	var bits [2]uint16
  1178  	m.Store(bits[:])
  1179  	var s [4]int64
  1180  	n := vl() / 8
  1181  	for i := range n {
  1182  		if b := i * 8; bits[b/16]>>(b%16)&1 != 0 {
  1183  			s[i] = 1
  1184  		}
  1185  	}
  1186  	return sliceToString(s[:n])
  1187  }
  1188  

View as plain text