crct10dif-pcl-asm_64.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. ########################################################################
  2. # Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions
  3. #
  4. # Copyright (c) 2013, Intel Corporation
  5. #
  6. # Authors:
  7. # Erdinc Ozturk <erdinc.ozturk@intel.com>
  8. # Vinodh Gopal <vinodh.gopal@intel.com>
  9. # James Guilford <james.guilford@intel.com>
  10. # Tim Chen <tim.c.chen@linux.intel.com>
  11. #
  12. # This software is available to you under a choice of one of two
  13. # licenses. You may choose to be licensed under the terms of the GNU
  14. # General Public License (GPL) Version 2, available from the file
  15. # COPYING in the main directory of this source tree, or the
  16. # OpenIB.org BSD license below:
  17. #
  18. # Redistribution and use in source and binary forms, with or without
  19. # modification, are permitted provided that the following conditions are
  20. # met:
  21. #
  22. # * Redistributions of source code must retain the above copyright
  23. # notice, this list of conditions and the following disclaimer.
  24. #
  25. # * Redistributions in binary form must reproduce the above copyright
  26. # notice, this list of conditions and the following disclaimer in the
  27. # documentation and/or other materials provided with the
  28. # distribution.
  29. #
  30. # * Neither the name of the Intel Corporation nor the names of its
  31. # contributors may be used to endorse or promote products derived from
  32. # this software without specific prior written permission.
  33. #
  34. #
  35. # THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY
  36. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR
  39. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  40. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  41. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  42. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  45. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. ########################################################################
  47. # Function API:
  48. # UINT16 crc_t10dif_pcl(
  49. # UINT16 init_crc, //initial CRC value, 16 bits
  50. # const unsigned char *buf, //buffer pointer to calculate CRC on
  51. # UINT64 len //buffer length in bytes (64-bit data)
  52. # );
  53. #
  54. # Reference paper titled "Fast CRC Computation for Generic
  55. # Polynomials Using PCLMULQDQ Instruction"
  56. # URL: http://www.intel.com/content/dam/www/public/us/en/documents
  57. # /white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
  58. #
  59. #
  60. #include <linux/linkage.h>
  61. .text
  62. #define arg1 %rdi
  63. #define arg2 %rsi
  64. #define arg3 %rdx
  65. #define arg1_low32 %edi
  66. ENTRY(crc_t10dif_pcl)
  67. .align 16
  68. # adjust the 16-bit initial_crc value, scale it to 32 bits
  69. shl $16, arg1_low32
  70. # Allocate Stack Space
  71. mov %rsp, %rcx
  72. sub $16*2, %rsp
  73. # align stack to 16 byte boundary
  74. and $~(0x10 - 1), %rsp
  75. # check if smaller than 256
  76. cmp $256, arg3
  77. # for sizes less than 128, we can't fold 64B at a time...
  78. jl _less_than_128
  79. # load the initial crc value
  80. movd arg1_low32, %xmm10 # initial crc
  81. # crc value does not need to be byte-reflected, but it needs
  82. # to be moved to the high part of the register.
  83. # because data will be byte-reflected and will align with
  84. # initial crc at correct place.
  85. pslldq $12, %xmm10
  86. movdqa SHUF_MASK(%rip), %xmm11
  87. # receive the initial 64B data, xor the initial crc value
  88. movdqu 16*0(arg2), %xmm0
  89. movdqu 16*1(arg2), %xmm1
  90. movdqu 16*2(arg2), %xmm2
  91. movdqu 16*3(arg2), %xmm3
  92. movdqu 16*4(arg2), %xmm4
  93. movdqu 16*5(arg2), %xmm5
  94. movdqu 16*6(arg2), %xmm6
  95. movdqu 16*7(arg2), %xmm7
  96. pshufb %xmm11, %xmm0
  97. # XOR the initial_crc value
  98. pxor %xmm10, %xmm0
  99. pshufb %xmm11, %xmm1
  100. pshufb %xmm11, %xmm2
  101. pshufb %xmm11, %xmm3
  102. pshufb %xmm11, %xmm4
  103. pshufb %xmm11, %xmm5
  104. pshufb %xmm11, %xmm6
  105. pshufb %xmm11, %xmm7
  106. movdqa rk3(%rip), %xmm10 #xmm10 has rk3 and rk4
  107. #imm value of pclmulqdq instruction
  108. #will determine which constant to use
  109. #################################################################
  110. # we subtract 256 instead of 128 to save one instruction from the loop
  111. sub $256, arg3
  112. # at this section of the code, there is 64*x+y (0<=y<64) bytes of
  113. # buffer. The _fold_64_B_loop will fold 64B at a time
  114. # until we have 64+y Bytes of buffer
  115. # fold 64B at a time. This section of the code folds 4 xmm
  116. # registers in parallel
  117. _fold_64_B_loop:
  118. # update the buffer pointer
  119. add $128, arg2 # buf += 64#
  120. movdqu 16*0(arg2), %xmm9
  121. movdqu 16*1(arg2), %xmm12
  122. pshufb %xmm11, %xmm9
  123. pshufb %xmm11, %xmm12
  124. movdqa %xmm0, %xmm8
  125. movdqa %xmm1, %xmm13
  126. pclmulqdq $0x0 , %xmm10, %xmm0
  127. pclmulqdq $0x11, %xmm10, %xmm8
  128. pclmulqdq $0x0 , %xmm10, %xmm1
  129. pclmulqdq $0x11, %xmm10, %xmm13
  130. pxor %xmm9 , %xmm0
  131. xorps %xmm8 , %xmm0
  132. pxor %xmm12, %xmm1
  133. xorps %xmm13, %xmm1
  134. movdqu 16*2(arg2), %xmm9
  135. movdqu 16*3(arg2), %xmm12
  136. pshufb %xmm11, %xmm9
  137. pshufb %xmm11, %xmm12
  138. movdqa %xmm2, %xmm8
  139. movdqa %xmm3, %xmm13
  140. pclmulqdq $0x0, %xmm10, %xmm2
  141. pclmulqdq $0x11, %xmm10, %xmm8
  142. pclmulqdq $0x0, %xmm10, %xmm3
  143. pclmulqdq $0x11, %xmm10, %xmm13
  144. pxor %xmm9 , %xmm2
  145. xorps %xmm8 , %xmm2
  146. pxor %xmm12, %xmm3
  147. xorps %xmm13, %xmm3
  148. movdqu 16*4(arg2), %xmm9
  149. movdqu 16*5(arg2), %xmm12
  150. pshufb %xmm11, %xmm9
  151. pshufb %xmm11, %xmm12
  152. movdqa %xmm4, %xmm8
  153. movdqa %xmm5, %xmm13
  154. pclmulqdq $0x0, %xmm10, %xmm4
  155. pclmulqdq $0x11, %xmm10, %xmm8
  156. pclmulqdq $0x0, %xmm10, %xmm5
  157. pclmulqdq $0x11, %xmm10, %xmm13
  158. pxor %xmm9 , %xmm4
  159. xorps %xmm8 , %xmm4
  160. pxor %xmm12, %xmm5
  161. xorps %xmm13, %xmm5
  162. movdqu 16*6(arg2), %xmm9
  163. movdqu 16*7(arg2), %xmm12
  164. pshufb %xmm11, %xmm9
  165. pshufb %xmm11, %xmm12
  166. movdqa %xmm6 , %xmm8
  167. movdqa %xmm7 , %xmm13
  168. pclmulqdq $0x0 , %xmm10, %xmm6
  169. pclmulqdq $0x11, %xmm10, %xmm8
  170. pclmulqdq $0x0 , %xmm10, %xmm7
  171. pclmulqdq $0x11, %xmm10, %xmm13
  172. pxor %xmm9 , %xmm6
  173. xorps %xmm8 , %xmm6
  174. pxor %xmm12, %xmm7
  175. xorps %xmm13, %xmm7
  176. sub $128, arg3
  177. # check if there is another 64B in the buffer to be able to fold
  178. jge _fold_64_B_loop
  179. ##################################################################
  180. add $128, arg2
  181. # at this point, the buffer pointer is pointing at the last y Bytes
  182. # of the buffer the 64B of folded data is in 4 of the xmm
  183. # registers: xmm0, xmm1, xmm2, xmm3
  184. # fold the 8 xmm registers to 1 xmm register with different constants
  185. movdqa rk9(%rip), %xmm10
  186. movdqa %xmm0, %xmm8
  187. pclmulqdq $0x11, %xmm10, %xmm0
  188. pclmulqdq $0x0 , %xmm10, %xmm8
  189. pxor %xmm8, %xmm7
  190. xorps %xmm0, %xmm7
  191. movdqa rk11(%rip), %xmm10
  192. movdqa %xmm1, %xmm8
  193. pclmulqdq $0x11, %xmm10, %xmm1
  194. pclmulqdq $0x0 , %xmm10, %xmm8
  195. pxor %xmm8, %xmm7
  196. xorps %xmm1, %xmm7
  197. movdqa rk13(%rip), %xmm10
  198. movdqa %xmm2, %xmm8
  199. pclmulqdq $0x11, %xmm10, %xmm2
  200. pclmulqdq $0x0 , %xmm10, %xmm8
  201. pxor %xmm8, %xmm7
  202. pxor %xmm2, %xmm7
  203. movdqa rk15(%rip), %xmm10
  204. movdqa %xmm3, %xmm8
  205. pclmulqdq $0x11, %xmm10, %xmm3
  206. pclmulqdq $0x0 , %xmm10, %xmm8
  207. pxor %xmm8, %xmm7
  208. xorps %xmm3, %xmm7
  209. movdqa rk17(%rip), %xmm10
  210. movdqa %xmm4, %xmm8
  211. pclmulqdq $0x11, %xmm10, %xmm4
  212. pclmulqdq $0x0 , %xmm10, %xmm8
  213. pxor %xmm8, %xmm7
  214. pxor %xmm4, %xmm7
  215. movdqa rk19(%rip), %xmm10
  216. movdqa %xmm5, %xmm8
  217. pclmulqdq $0x11, %xmm10, %xmm5
  218. pclmulqdq $0x0 , %xmm10, %xmm8
  219. pxor %xmm8, %xmm7
  220. xorps %xmm5, %xmm7
  221. movdqa rk1(%rip), %xmm10 #xmm10 has rk1 and rk2
  222. #imm value of pclmulqdq instruction
  223. #will determine which constant to use
  224. movdqa %xmm6, %xmm8
  225. pclmulqdq $0x11, %xmm10, %xmm6
  226. pclmulqdq $0x0 , %xmm10, %xmm8
  227. pxor %xmm8, %xmm7
  228. pxor %xmm6, %xmm7
  229. # instead of 64, we add 48 to the loop counter to save 1 instruction
  230. # from the loop instead of a cmp instruction, we use the negative
  231. # flag with the jl instruction
  232. add $128-16, arg3
  233. jl _final_reduction_for_128
  234. # now we have 16+y bytes left to reduce. 16 Bytes is in register xmm7
  235. # and the rest is in memory. We can fold 16 bytes at a time if y>=16
  236. # continue folding 16B at a time
  237. _16B_reduction_loop:
  238. movdqa %xmm7, %xmm8
  239. pclmulqdq $0x11, %xmm10, %xmm7
  240. pclmulqdq $0x0 , %xmm10, %xmm8
  241. pxor %xmm8, %xmm7
  242. movdqu (arg2), %xmm0
  243. pshufb %xmm11, %xmm0
  244. pxor %xmm0 , %xmm7
  245. add $16, arg2
  246. sub $16, arg3
  247. # instead of a cmp instruction, we utilize the flags with the
  248. # jge instruction equivalent of: cmp arg3, 16-16
  249. # check if there is any more 16B in the buffer to be able to fold
  250. jge _16B_reduction_loop
  251. #now we have 16+z bytes left to reduce, where 0<= z < 16.
  252. #first, we reduce the data in the xmm7 register
  253. _final_reduction_for_128:
  254. # check if any more data to fold. If not, compute the CRC of
  255. # the final 128 bits
  256. add $16, arg3
  257. je _128_done
  258. # here we are getting data that is less than 16 bytes.
  259. # since we know that there was data before the pointer, we can
  260. # offset the input pointer before the actual point, to receive
  261. # exactly 16 bytes. after that the registers need to be adjusted.
  262. _get_last_two_xmms:
  263. movdqa %xmm7, %xmm2
  264. movdqu -16(arg2, arg3), %xmm1
  265. pshufb %xmm11, %xmm1
  266. # get rid of the extra data that was loaded before
  267. # load the shift constant
  268. lea pshufb_shf_table+16(%rip), %rax
  269. sub arg3, %rax
  270. movdqu (%rax), %xmm0
  271. # shift xmm2 to the left by arg3 bytes
  272. pshufb %xmm0, %xmm2
  273. # shift xmm7 to the right by 16-arg3 bytes
  274. pxor mask1(%rip), %xmm0
  275. pshufb %xmm0, %xmm7
  276. pblendvb %xmm2, %xmm1 #xmm0 is implicit
  277. # fold 16 Bytes
  278. movdqa %xmm1, %xmm2
  279. movdqa %xmm7, %xmm8
  280. pclmulqdq $0x11, %xmm10, %xmm7
  281. pclmulqdq $0x0 , %xmm10, %xmm8
  282. pxor %xmm8, %xmm7
  283. pxor %xmm2, %xmm7
  284. _128_done:
  285. # compute crc of a 128-bit value
  286. movdqa rk5(%rip), %xmm10 # rk5 and rk6 in xmm10
  287. movdqa %xmm7, %xmm0
  288. #64b fold
  289. pclmulqdq $0x1, %xmm10, %xmm7
  290. pslldq $8 , %xmm0
  291. pxor %xmm0, %xmm7
  292. #32b fold
  293. movdqa %xmm7, %xmm0
  294. pand mask2(%rip), %xmm0
  295. psrldq $12, %xmm7
  296. pclmulqdq $0x10, %xmm10, %xmm7
  297. pxor %xmm0, %xmm7
  298. #barrett reduction
  299. _barrett:
  300. movdqa rk7(%rip), %xmm10 # rk7 and rk8 in xmm10
  301. movdqa %xmm7, %xmm0
  302. pclmulqdq $0x01, %xmm10, %xmm7
  303. pslldq $4, %xmm7
  304. pclmulqdq $0x11, %xmm10, %xmm7
  305. pslldq $4, %xmm7
  306. pxor %xmm0, %xmm7
  307. pextrd $1, %xmm7, %eax
  308. _cleanup:
  309. # scale the result back to 16 bits
  310. shr $16, %eax
  311. mov %rcx, %rsp
  312. ret
  313. ########################################################################
  314. .align 16
  315. _less_than_128:
  316. # check if there is enough buffer to be able to fold 16B at a time
  317. cmp $32, arg3
  318. jl _less_than_32
  319. movdqa SHUF_MASK(%rip), %xmm11
  320. # now if there is, load the constants
  321. movdqa rk1(%rip), %xmm10 # rk1 and rk2 in xmm10
  322. movd arg1_low32, %xmm0 # get the initial crc value
  323. pslldq $12, %xmm0 # align it to its correct place
  324. movdqu (arg2), %xmm7 # load the plaintext
  325. pshufb %xmm11, %xmm7 # byte-reflect the plaintext
  326. pxor %xmm0, %xmm7
  327. # update the buffer pointer
  328. add $16, arg2
  329. # update the counter. subtract 32 instead of 16 to save one
  330. # instruction from the loop
  331. sub $32, arg3
  332. jmp _16B_reduction_loop
  333. .align 16
  334. _less_than_32:
  335. # mov initial crc to the return value. this is necessary for
  336. # zero-length buffers.
  337. mov arg1_low32, %eax
  338. test arg3, arg3
  339. je _cleanup
  340. movdqa SHUF_MASK(%rip), %xmm11
  341. movd arg1_low32, %xmm0 # get the initial crc value
  342. pslldq $12, %xmm0 # align it to its correct place
  343. cmp $16, arg3
  344. je _exact_16_left
  345. jl _less_than_16_left
  346. movdqu (arg2), %xmm7 # load the plaintext
  347. pshufb %xmm11, %xmm7 # byte-reflect the plaintext
  348. pxor %xmm0 , %xmm7 # xor the initial crc value
  349. add $16, arg2
  350. sub $16, arg3
  351. movdqa rk1(%rip), %xmm10 # rk1 and rk2 in xmm10
  352. jmp _get_last_two_xmms
  353. .align 16
  354. _less_than_16_left:
  355. # use stack space to load data less than 16 bytes, zero-out
  356. # the 16B in memory first.
  357. pxor %xmm1, %xmm1
  358. mov %rsp, %r11
  359. movdqa %xmm1, (%r11)
  360. cmp $4, arg3
  361. jl _only_less_than_4
  362. # backup the counter value
  363. mov arg3, %r9
  364. cmp $8, arg3
  365. jl _less_than_8_left
  366. # load 8 Bytes
  367. mov (arg2), %rax
  368. mov %rax, (%r11)
  369. add $8, %r11
  370. sub $8, arg3
  371. add $8, arg2
  372. _less_than_8_left:
  373. cmp $4, arg3
  374. jl _less_than_4_left
  375. # load 4 Bytes
  376. mov (arg2), %eax
  377. mov %eax, (%r11)
  378. add $4, %r11
  379. sub $4, arg3
  380. add $4, arg2
  381. _less_than_4_left:
  382. cmp $2, arg3
  383. jl _less_than_2_left
  384. # load 2 Bytes
  385. mov (arg2), %ax
  386. mov %ax, (%r11)
  387. add $2, %r11
  388. sub $2, arg3
  389. add $2, arg2
  390. _less_than_2_left:
  391. cmp $1, arg3
  392. jl _zero_left
  393. # load 1 Byte
  394. mov (arg2), %al
  395. mov %al, (%r11)
  396. _zero_left:
  397. movdqa (%rsp), %xmm7
  398. pshufb %xmm11, %xmm7
  399. pxor %xmm0 , %xmm7 # xor the initial crc value
  400. # shl r9, 4
  401. lea pshufb_shf_table+16(%rip), %rax
  402. sub %r9, %rax
  403. movdqu (%rax), %xmm0
  404. pxor mask1(%rip), %xmm0
  405. pshufb %xmm0, %xmm7
  406. jmp _128_done
  407. .align 16
  408. _exact_16_left:
  409. movdqu (arg2), %xmm7
  410. pshufb %xmm11, %xmm7
  411. pxor %xmm0 , %xmm7 # xor the initial crc value
  412. jmp _128_done
  413. _only_less_than_4:
  414. cmp $3, arg3
  415. jl _only_less_than_3
  416. # load 3 Bytes
  417. mov (arg2), %al
  418. mov %al, (%r11)
  419. mov 1(arg2), %al
  420. mov %al, 1(%r11)
  421. mov 2(arg2), %al
  422. mov %al, 2(%r11)
  423. movdqa (%rsp), %xmm7
  424. pshufb %xmm11, %xmm7
  425. pxor %xmm0 , %xmm7 # xor the initial crc value
  426. psrldq $5, %xmm7
  427. jmp _barrett
  428. _only_less_than_3:
  429. cmp $2, arg3
  430. jl _only_less_than_2
  431. # load 2 Bytes
  432. mov (arg2), %al
  433. mov %al, (%r11)
  434. mov 1(arg2), %al
  435. mov %al, 1(%r11)
  436. movdqa (%rsp), %xmm7
  437. pshufb %xmm11, %xmm7
  438. pxor %xmm0 , %xmm7 # xor the initial crc value
  439. psrldq $6, %xmm7
  440. jmp _barrett
  441. _only_less_than_2:
  442. # load 1 Byte
  443. mov (arg2), %al
  444. mov %al, (%r11)
  445. movdqa (%rsp), %xmm7
  446. pshufb %xmm11, %xmm7
  447. pxor %xmm0 , %xmm7 # xor the initial crc value
  448. psrldq $7, %xmm7
  449. jmp _barrett
  450. ENDPROC(crc_t10dif_pcl)
  451. .data
  452. # precomputed constants
  453. # these constants are precomputed from the poly:
  454. # 0x8bb70000 (0x8bb7 scaled to 32 bits)
  455. .align 16
  456. # Q = 0x18BB70000
  457. # rk1 = 2^(32*3) mod Q << 32
  458. # rk2 = 2^(32*5) mod Q << 32
  459. # rk3 = 2^(32*15) mod Q << 32
  460. # rk4 = 2^(32*17) mod Q << 32
  461. # rk5 = 2^(32*3) mod Q << 32
  462. # rk6 = 2^(32*2) mod Q << 32
  463. # rk7 = floor(2^64/Q)
  464. # rk8 = Q
  465. rk1:
  466. .quad 0x2d56000000000000
  467. rk2:
  468. .quad 0x06df000000000000
  469. rk3:
  470. .quad 0x9d9d000000000000
  471. rk4:
  472. .quad 0x7cf5000000000000
  473. rk5:
  474. .quad 0x2d56000000000000
  475. rk6:
  476. .quad 0x1368000000000000
  477. rk7:
  478. .quad 0x00000001f65a57f8
  479. rk8:
  480. .quad 0x000000018bb70000
  481. rk9:
  482. .quad 0xceae000000000000
  483. rk10:
  484. .quad 0xbfd6000000000000
  485. rk11:
  486. .quad 0x1e16000000000000
  487. rk12:
  488. .quad 0x713c000000000000
  489. rk13:
  490. .quad 0xf7f9000000000000
  491. rk14:
  492. .quad 0x80a6000000000000
  493. rk15:
  494. .quad 0x044c000000000000
  495. rk16:
  496. .quad 0xe658000000000000
  497. rk17:
  498. .quad 0xad18000000000000
  499. rk18:
  500. .quad 0xa497000000000000
  501. rk19:
  502. .quad 0x6ee3000000000000
  503. rk20:
  504. .quad 0xe7b5000000000000
  505. mask1:
  506. .octa 0x80808080808080808080808080808080
  507. mask2:
  508. .octa 0x00000000FFFFFFFFFFFFFFFFFFFFFFFF
  509. SHUF_MASK:
  510. .octa 0x000102030405060708090A0B0C0D0E0F
  511. pshufb_shf_table:
  512. # use these values for shift constants for the pshufb instruction
  513. # different alignments result in values as shown:
  514. # DDQ 0x008f8e8d8c8b8a898887868584838281 # shl 15 (16-1) / shr1
  515. # DDQ 0x01008f8e8d8c8b8a8988878685848382 # shl 14 (16-3) / shr2
  516. # DDQ 0x0201008f8e8d8c8b8a89888786858483 # shl 13 (16-4) / shr3
  517. # DDQ 0x030201008f8e8d8c8b8a898887868584 # shl 12 (16-4) / shr4
  518. # DDQ 0x04030201008f8e8d8c8b8a8988878685 # shl 11 (16-5) / shr5
  519. # DDQ 0x0504030201008f8e8d8c8b8a89888786 # shl 10 (16-6) / shr6
  520. # DDQ 0x060504030201008f8e8d8c8b8a898887 # shl 9 (16-7) / shr7
  521. # DDQ 0x07060504030201008f8e8d8c8b8a8988 # shl 8 (16-8) / shr8
  522. # DDQ 0x0807060504030201008f8e8d8c8b8a89 # shl 7 (16-9) / shr9
  523. # DDQ 0x090807060504030201008f8e8d8c8b8a # shl 6 (16-10) / shr10
  524. # DDQ 0x0a090807060504030201008f8e8d8c8b # shl 5 (16-11) / shr11
  525. # DDQ 0x0b0a090807060504030201008f8e8d8c # shl 4 (16-12) / shr12
  526. # DDQ 0x0c0b0a090807060504030201008f8e8d # shl 3 (16-13) / shr13
  527. # DDQ 0x0d0c0b0a090807060504030201008f8e # shl 2 (16-14) / shr14
  528. # DDQ 0x0e0d0c0b0a090807060504030201008f # shl 1 (16-15) / shr15
  529. .octa 0x8f8e8d8c8b8a89888786858483828100
  530. .octa 0x000e0d0c0b0a09080706050403020100