242 lines
3.5 KiB
Go
242 lines
3.5 KiB
Go
package types
|
|
|
|
import "unsafe"
|
|
|
|
type Vector interface {
|
|
Sizeable
|
|
Addressable
|
|
Lanes() int
|
|
LaneWidth() int
|
|
}
|
|
|
|
// Allow for type inference and downcasting if supported
|
|
|
|
type Vec128 interface {
|
|
Vector
|
|
Vec128() Vec128
|
|
}
|
|
|
|
type Vec256 interface {
|
|
Vec128
|
|
Vec256() Vec256
|
|
}
|
|
|
|
type Vec512 interface {
|
|
Vec256
|
|
Vec512() Vec512
|
|
}
|
|
|
|
type AllowedIntTypes interface {
|
|
~uint64 | ~int64 | ~uint32 | ~int32 | ~uint16 | ~int16 | ~uint8 | ~int8
|
|
}
|
|
|
|
type AllowedFloatTypes interface {
|
|
~float64 | ~float32
|
|
}
|
|
|
|
type VecInt[T AllowedIntTypes] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecUint8[T ~uint8] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecInt8[T ~int8] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecUint16[T ~uint16] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecInt16[T ~int16] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecUint32[T ~uint32] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecInt32[T ~int32] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecUint64[T ~uint64] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecInt64[T ~int64] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecFloat[T AllowedFloatTypes] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecFloat32[T ~float32] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type VecFloat64[T ~float64] interface {
|
|
Vector
|
|
Type() T
|
|
}
|
|
|
|
type Addressable128 interface {
|
|
Addressable
|
|
As128() MustAddressable128
|
|
}
|
|
|
|
type Addressable256 interface {
|
|
Addressable
|
|
As256() MustAddressable256
|
|
}
|
|
|
|
type Addressable512 interface {
|
|
Addressable
|
|
As512() MustAddressable512
|
|
}
|
|
|
|
type AddressableAll interface {
|
|
Addressable128
|
|
Addressable256
|
|
Addressable512
|
|
}
|
|
|
|
type MustAddressable128 interface {
|
|
AddressableAll
|
|
Must128() MustAddressable128
|
|
}
|
|
|
|
type MustAddressable256 interface {
|
|
AddressableAll
|
|
Must256() MustAddressable256
|
|
}
|
|
|
|
type MustAddressable512 interface {
|
|
AddressableAll
|
|
Must512() MustAddressable512
|
|
}
|
|
|
|
type VecLeast128Any interface {
|
|
Vec128
|
|
Addressable128
|
|
}
|
|
type VecLeast256Any interface {
|
|
Vec256
|
|
Addressable256
|
|
}
|
|
type VecLeast512Any interface {
|
|
Vec512
|
|
Addressable512
|
|
}
|
|
|
|
type Vec128Any interface {
|
|
Vec128
|
|
MustAddressable128
|
|
}
|
|
type Vec256Any interface {
|
|
Vec256
|
|
MustAddressable256
|
|
}
|
|
|
|
type VecAny interface {
|
|
Vector
|
|
AddressableAll
|
|
}
|
|
|
|
type Vec512Any interface {
|
|
Vec512
|
|
MustAddressable512
|
|
}
|
|
|
|
type VecLeast128Int[T AllowedIntTypes] interface {
|
|
Vec128
|
|
Addressable128
|
|
VecInt[T]
|
|
}
|
|
type VecLeast256Int[T AllowedIntTypes] interface {
|
|
Vec256
|
|
Addressable256
|
|
VecInt[T]
|
|
}
|
|
type VecLeast512Int[T AllowedIntTypes] interface {
|
|
Vec512
|
|
Addressable512
|
|
VecInt[T]
|
|
}
|
|
|
|
type Vec128Int[T AllowedIntTypes] interface {
|
|
Vec128
|
|
MustAddressable128
|
|
VecInt[T]
|
|
}
|
|
type Vec256Int[T AllowedIntTypes] interface {
|
|
Vec256
|
|
MustAddressable256
|
|
VecInt[T]
|
|
}
|
|
type Vec512Int[T AllowedIntTypes] interface {
|
|
Vec512
|
|
MustAddressable512
|
|
VecInt[T]
|
|
}
|
|
|
|
type VecLeast128Float[T AllowedFloatTypes] interface {
|
|
Vec128
|
|
Addressable128
|
|
VecFloat[T]
|
|
}
|
|
type VecLeast256Float[T AllowedFloatTypes] interface {
|
|
Vec256
|
|
Addressable256
|
|
VecFloat[T]
|
|
}
|
|
type VecLeast512Float[T AllowedFloatTypes] interface {
|
|
Vec512
|
|
Addressable512
|
|
VecFloat[T]
|
|
}
|
|
|
|
type Vec128Float[T AllowedFloatTypes] interface {
|
|
Vec128
|
|
MustAddressable128
|
|
VecFloat[T]
|
|
}
|
|
type Vec256Float[T AllowedFloatTypes] interface {
|
|
Vec256
|
|
MustAddressable256
|
|
VecFloat[T]
|
|
}
|
|
type Vec512Float[T AllowedFloatTypes] interface {
|
|
Vec512
|
|
MustAddressable512
|
|
VecFloat[T]
|
|
}
|
|
|
|
func VecCast128[To Vec128Any, From VecAny](v From) To {
|
|
var a = v.As128()
|
|
return *(*To)(unsafe.Pointer(&a))
|
|
}
|
|
|
|
func VecCast256[To Vec256Any, From VecAny](v From) To {
|
|
var a = v.As256()
|
|
return *(*To)(unsafe.Pointer(&a))
|
|
}
|
|
|
|
func VecCast512[To Vec512Any, From VecAny](v From) To {
|
|
var a = v.As512()
|
|
return *(*To)(unsafe.Pointer(&a))
|
|
}
|