github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/exp/shiny/driver/internal/swizzle/swizzle_amd64.s (about) 1 // Copyright 2015 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 #include "textflag.h" 6 7 // func haveSSSE3() bool 8 TEXT ·haveSSSE3(SB),NOSPLIT,$0 9 MOVQ $1, AX 10 CPUID 11 SHRQ $9, CX 12 ANDQ $1, CX 13 MOVB CX, ret+0(FP) 14 RET 15 16 // func bgra16(p []byte) 17 TEXT ·bgra16(SB),NOSPLIT,$0-24 18 MOVQ p+0(FP), SI 19 MOVQ len+8(FP), DI 20 21 // Sanity check that len is a multiple of 16. 22 MOVQ DI, AX 23 ANDQ $15, AX 24 JNZ done 25 26 // Make the shuffle control mask (16-byte register X0) look like this, 27 // where the low order byte comes first: 28 // 29 // 02 01 00 03 06 05 04 07 0a 09 08 0b 0e 0d 0c 0f 30 // 31 // Load the bottom 8 bytes into X0, the top into X1, then interleave them 32 // into X0. 33 MOVQ $0x0704050603000102, AX 34 MOVQ AX, X0 35 MOVQ $0x0f0c0d0e0b08090a, AX 36 MOVQ AX, X1 37 PUNPCKLQDQ X1, X0 38 39 ADDQ SI, DI 40 loop: 41 CMPQ SI, DI 42 JEQ done 43 44 MOVOU (SI), X1 45 PSHUFB X0, X1 46 MOVOU X1, (SI) 47 48 ADDQ $16, SI 49 JMP loop 50 done: 51 RET 52 53 // func bgra4(p []byte) 54 TEXT ·bgra4(SB),NOSPLIT,$0-24 55 MOVQ p+0(FP), SI 56 MOVQ len+8(FP), DI 57 58 // Sanity check that len is a multiple of 4. 59 MOVQ DI, AX 60 ANDQ $3, AX 61 JNZ done 62 63 ADDQ SI, DI 64 loop: 65 CMPQ SI, DI 66 JEQ done 67 68 MOVB 0(SI), AX 69 MOVB 2(SI), BX 70 MOVB BX, 0(SI) 71 MOVB AX, 2(SI) 72 73 ADDQ $4, SI 74 JMP loop 75 done: 76 RET