Open rleiwang opened 4 years ago
Would you be able to make this work if your function signature took a pointer to the output? Like:
shuffle(mask, data []byte, out *byte)
I may be able to extend the gotypes.Component
interface to make this possible. I'd need to think about this some more.
@mmcloughlin Thanks for the quick response. For now, I would prefer use Store(xmm, ReturnIndex(0).Index(0))
if it works, since [4]uint32 is a value type.
@klauspost has encountered the same problem:
I am trying to generate a function in avo that has func(data [n][16]byte) signature, and I'm trying to load the [16]byte into YMM registers. My problem is that if I use Load(Param("data").Index(i), YMM()) (and XMM) I get component is not primitive and I cannot find a way to get it back to a VecVirtual anyway. I would like to send values directly on the stack, since slices are bigger and pointers is just an extra indirection. I also tried to resolve the address so I could just use a MOVOU myself, but couldn't make that work either.
https://gophers.slack.com/archives/C6WDZJ70S/p1589142748014600
As discussed on Slack, probably the solution here is to provide an accessor method Component.Addr()
for:
The only question in my mind is what to do with errors that can occur in method chaining, like when i
is too large in Param("data").Index(i).Addr()
. Should the signature be:
Addr() operand.Mem
which panics when there is an errorAddr() (operand.Mem, error)
If it returns an error, a Must
function might be useful. This could possibly belong in the operand
package.
@mmcloughlin Thanks for the update. I did what you suggested for the time being.
func(masks, data []byte, offset int, out []uint32)
https://github.com/rleiwang/svb/blob/10f63e6855cff78e14a0371425cbf569e8456590/asm.go#L11
I am trying to implement https://github.com/lemire/streamvbyte/blob/master/src/streamvbyte_x64_decode.c#L2.
However, Using
Store(xmm, ReturnIndex(0))
resulted an error in go generateasm.go:85: component is not primitive exit status 1
. Instead I changed toStore(xmm, ReturnIndex(0).Index(0))
to work around it.I also manually changed to use AVX512, VMOVDQU8. The following is Go assembler code.