Btw, the assembly code was quite terrible... Here is a new version of it 
for people interested (feedback still welcomed):

TEXT ·AddVector16(SB),NOSPLIT,$0-48
MOVD $a+0(FP), R0
VLD1.P 32(R0), [V0.D2, V1.D2]
VADD V1.B16, V0.B16, V0.B16
MOVD $ret+32(FP), R0
VST1.P [V0.D2], (R0)
RET

TEXT ·AddVector32(SB),NOSPLIT,$0-96
MOVD $a+0(FP), R0
VLD1.P 64(R0), [V0.D2, V1.D2, V2.D2, V3.D2]
VADD V2.B16, V0.B16, V0.B16
VADD V3.B16, V1.B16, V1.B16
MOVD $ret+64(FP), R0
VST1.P [V0.D2, V1.D2], (R0)
RET

On Wednesday, December 20, 2023 at 7:40:36 AM UTC+8 Clément Jean wrote:

> That's what I thought. When I checked the assembly of a generic function I 
> could see the go.shape part and that's what made me think about 
> specialisation.
> However, after trying to write that myself it just didn't compile.
>
> I guess, I'll have to do lot of copy pasting ^^
>
> On Wednesday, December 20, 2023 at 2:23:01 AM UTC+8 David Finkel wrote:
>
>> On Thu, Dec 14, 2023 at 10:43 PM Clément Jean <clemen...@gmail.com> 
>> wrote:
>>
>>> Hi,
>>>
>>> I'm currently learning how to write Go assembly on arm64 and I made the 
>>> following functions:
>>>
>>> TEXT ·AddVector16(SB),NOSPLIT,$0-48
>>> MOVD a+0(FP), R0
>>> MOVD a+8(FP), R1
>>> MOVD a+16(FP), R2
>>> MOVD a+24(FP), R3
>>> VMOV R0, V0.D[0]
>>> VMOV R1, V0.D[1]
>>> VMOV R2, V1.D[0]
>>> VMOV R3, V1.D[1]
>>> VADD V1.B16, V0.B16, V0.B16
>>> VMOV V0.D[0], R0
>>> VMOV V0.D[1], R1
>>> MOVD R0, ret+32(FP)
>>> MOVD R1, ret+40(FP)
>>> RET
>>>
>>> TEXT ·AddVector32(SB),NOSPLIT,$0-96
>>> MOVD a+0(FP), R0
>>> MOVD a+8(FP), R1
>>> MOVD a+16(FP), R2
>>> MOVD a+24(FP), R3
>>> MOVD a+32(FP), R4
>>> MOVD a+40(FP), R5
>>> MOVD a+48(FP), R6
>>> MOVD a+56(FP), R7
>>> VMOV R0, V0.D[0]
>>> VMOV R1, V0.D[1]
>>> VMOV R2, V1.D[0]
>>> VMOV R3, V1.D[1]
>>> VMOV R4, V2.D[0]
>>> VMOV R5, V2.D[1]
>>> VMOV R6, V3.D[0]
>>> VMOV R7, V3.D[1]
>>> VADD V2.B16, V0.B16, V0.B16
>>> VADD V3.B16, V1.B16, V1.B16
>>> VMOV V0.D[0], R0
>>> VMOV V0.D[1], R1
>>> VMOV V1.D[0], R2
>>> VMOV V1.D[1], R3
>>> MOVD R0, ret+64(FP)
>>> MOVD R1, ret+72(FP)
>>> MOVD R2, ret+80(FP)
>>> MOVD R3, ret+88(FP)
>>> RET
>>> While these work, I'm forced to add the 16 and 32 suffixes. Is there any 
>>> way to have only one function name and link the assembly to something like:
>>> type Uint8x16 [16]uint8
>>> type Uint8x32 [32]uint8
>>>
>>> //go:noescape
>>> func AddVector[T Uint8x16 | Uint8x32](a, b T) T
>>> If there is let me know, otherwise is there some other alternatives?
>>>
>>>
>> Unfortunately, I think a suffix is the best you can do without jumping 
>> through some serious (and ugly) hoops.
>> The generics implementation opted for a "stenciling" approach, (and 
>> doesn't support specializations) so although the symbols do encode the GC 
>> shape a bit.
>> Here's the design doc for GC Shape Stenciling
>>
>> https://go.googlesource.com/proposal/+/refs/heads/master/design/generics-implementation-gcshape.md
>>   
>>  
>>
>>> Btw any feedback on the assembly is welcome, I'm new to it.
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/3224bd47-2747-4e1d-bbc5-4a5c4a300f85n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/3224bd47-2747-4e1d-bbc5-4a5c4a300f85n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b19562ac-5b2f-44f2-a6f9-77bf7eb8678en%40googlegroups.com.

Reply via email to