reg_sizes.asm 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
  3. ;
  4. ; Redistribution and use in source and binary forms, with or without
  5. ; modification, are permitted provided that the following conditions
  6. ; are met:
  7. ; * Redistributions of source code must retain the above copyright
  8. ; notice, this list of conditions and the following disclaimer.
  9. ; * Redistributions in binary form must reproduce the above copyright
  10. ; notice, this list of conditions and the following disclaimer in
  11. ; the documentation and/or other materials provided with the
  12. ; distribution.
  13. ; * Neither the name of Intel Corporation nor the names of its
  14. ; contributors may be used to endorse or promote products derived
  15. ; from this software without specific prior written permission.
  16. ;
  17. ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. %ifndef _REG_SIZES_ASM_
  30. %define _REG_SIZES_ASM_
  31. %ifdef __NASM_VER__
  32. %ifidn __OUTPUT_FORMAT__, win64
  33. %error nasm not supported in windows
  34. %else
  35. %define endproc_frame
  36. %endif
  37. %endif
  38. %ifndef AS_FEATURE_LEVEL
  39. %define AS_FEATURE_LEVEL 4
  40. %endif
  41. %define EFLAGS_HAS_CPUID (1<<21)
  42. %define FLAG_CPUID1_ECX_CLMUL (1<<1)
  43. %define FLAG_CPUID1_EDX_SSE2 (1<<26)
  44. %define FLAG_CPUID1_ECX_SSE3 (1)
  45. %define FLAG_CPUID1_ECX_SSE4_1 (1<<19)
  46. %define FLAG_CPUID1_ECX_SSE4_2 (1<<20)
  47. %define FLAG_CPUID1_ECX_POPCNT (1<<23)
  48. %define FLAG_CPUID1_ECX_AESNI (1<<25)
  49. %define FLAG_CPUID1_ECX_OSXSAVE (1<<27)
  50. %define FLAG_CPUID1_ECX_AVX (1<<28)
  51. %define FLAG_CPUID1_EBX_AVX2 (1<<5)
  52. %define FLAG_CPUID7_EBX_AVX2 (1<<5)
  53. %define FLAG_CPUID7_EBX_AVX512F (1<<16)
  54. %define FLAG_CPUID7_EBX_AVX512DQ (1<<17)
  55. %define FLAG_CPUID7_EBX_AVX512IFMA (1<<21)
  56. %define FLAG_CPUID7_EBX_AVX512PF (1<<26)
  57. %define FLAG_CPUID7_EBX_AVX512ER (1<<27)
  58. %define FLAG_CPUID7_EBX_AVX512CD (1<<28)
  59. %define FLAG_CPUID7_EBX_AVX512BW (1<<30)
  60. %define FLAG_CPUID7_EBX_AVX512VL (1<<31)
  61. %define FLAG_CPUID7_ECX_AVX512VBMI (1<<1)
  62. %define FLAG_CPUID7_ECX_AVX512VBMI2 (1 << 6)
  63. %define FLAG_CPUID7_ECX_GFNI (1 << 8)
  64. %define FLAG_CPUID7_ECX_VAES (1 << 9)
  65. %define FLAG_CPUID7_ECX_VPCLMULQDQ (1 << 10)
  66. %define FLAG_CPUID7_ECX_VNNI (1 << 11)
  67. %define FLAG_CPUID7_ECX_BITALG (1 << 12)
  68. %define FLAG_CPUID7_ECX_VPOPCNTDQ (1 << 14)
  69. %define FLAGS_CPUID7_EBX_AVX512_G1 (FLAG_CPUID7_EBX_AVX512F | FLAG_CPUID7_EBX_AVX512VL | FLAG_CPUID7_EBX_AVX512BW | FLAG_CPUID7_EBX_AVX512CD | FLAG_CPUID7_EBX_AVX512DQ)
  70. %define FLAGS_CPUID7_ECX_AVX512_G2 (FLAG_CPUID7_ECX_AVX512VBMI2 | FLAG_CPUID7_ECX_GFNI | FLAG_CPUID7_ECX_VAES | FLAG_CPUID7_ECX_VPCLMULQDQ | FLAG_CPUID7_ECX_VNNI | FLAG_CPUID7_ECX_BITALG | FLAG_CPUID7_ECX_VPOPCNTDQ)
  71. %define FLAG_XGETBV_EAX_XMM (1<<1)
  72. %define FLAG_XGETBV_EAX_YMM (1<<2)
  73. %define FLAG_XGETBV_EAX_XMM_YMM 0x6
  74. %define FLAG_XGETBV_EAX_ZMM_OPM 0xe0
  75. %define FLAG_CPUID1_EAX_AVOTON 0x000406d0
  76. %define FLAG_CPUID1_EAX_STEP_MASK 0xfffffff0
  77. ; define d and w variants for registers
  78. %define raxd eax
  79. %define raxw ax
  80. %define raxb al
  81. %define rbxd ebx
  82. %define rbxw bx
  83. %define rbxb bl
  84. %define rcxd ecx
  85. %define rcxw cx
  86. %define rcxb cl
  87. %define rdxd edx
  88. %define rdxw dx
  89. %define rdxb dl
  90. %define rsid esi
  91. %define rsiw si
  92. %define rsib sil
  93. %define rdid edi
  94. %define rdiw di
  95. %define rdib dil
  96. %define rbpd ebp
  97. %define rbpw bp
  98. %define rbpb bpl
  99. %define ymm0x xmm0
  100. %define ymm1x xmm1
  101. %define ymm2x xmm2
  102. %define ymm3x xmm3
  103. %define ymm4x xmm4
  104. %define ymm5x xmm5
  105. %define ymm6x xmm6
  106. %define ymm7x xmm7
  107. %define ymm8x xmm8
  108. %define ymm9x xmm9
  109. %define ymm10x xmm10
  110. %define ymm11x xmm11
  111. %define ymm12x xmm12
  112. %define ymm13x xmm13
  113. %define ymm14x xmm14
  114. %define ymm15x xmm15
  115. %define zmm0x xmm0
  116. %define zmm1x xmm1
  117. %define zmm2x xmm2
  118. %define zmm3x xmm3
  119. %define zmm4x xmm4
  120. %define zmm5x xmm5
  121. %define zmm6x xmm6
  122. %define zmm7x xmm7
  123. %define zmm8x xmm8
  124. %define zmm9x xmm9
  125. %define zmm10x xmm10
  126. %define zmm11x xmm11
  127. %define zmm12x xmm12
  128. %define zmm13x xmm13
  129. %define zmm14x xmm14
  130. %define zmm15x xmm15
  131. %define zmm16x xmm16
  132. %define zmm17x xmm17
  133. %define zmm18x xmm18
  134. %define zmm19x xmm19
  135. %define zmm20x xmm20
  136. %define zmm21x xmm21
  137. %define zmm22x xmm22
  138. %define zmm23x xmm23
  139. %define zmm24x xmm24
  140. %define zmm25x xmm25
  141. %define zmm26x xmm26
  142. %define zmm27x xmm27
  143. %define zmm28x xmm28
  144. %define zmm29x xmm29
  145. %define zmm30x xmm30
  146. %define zmm31x xmm31
  147. %define zmm0y ymm0
  148. %define zmm1y ymm1
  149. %define zmm2y ymm2
  150. %define zmm3y ymm3
  151. %define zmm4y ymm4
  152. %define zmm5y ymm5
  153. %define zmm6y ymm6
  154. %define zmm7y ymm7
  155. %define zmm8y ymm8
  156. %define zmm9y ymm9
  157. %define zmm10y ymm10
  158. %define zmm11y ymm11
  159. %define zmm12y ymm12
  160. %define zmm13y ymm13
  161. %define zmm14y ymm14
  162. %define zmm15y ymm15
  163. %define zmm16y ymm16
  164. %define zmm17y ymm17
  165. %define zmm18y ymm18
  166. %define zmm19y ymm19
  167. %define zmm20y ymm20
  168. %define zmm21y ymm21
  169. %define zmm22y ymm22
  170. %define zmm23y ymm23
  171. %define zmm24y ymm24
  172. %define zmm25y ymm25
  173. %define zmm26y ymm26
  174. %define zmm27y ymm27
  175. %define zmm28y ymm28
  176. %define zmm29y ymm29
  177. %define zmm30y ymm30
  178. %define zmm31y ymm31
  179. %define DWORD(reg) reg %+ d
  180. %define WORD(reg) reg %+ w
  181. %define BYTE(reg) reg %+ b
  182. %define XWORD(reg) reg %+ x
  183. %ifidn __OUTPUT_FORMAT__,elf32
  184. section .note.GNU-stack noalloc noexec nowrite progbits
  185. section .text
  186. %endif
  187. %ifidn __OUTPUT_FORMAT__,elf64
  188. section .note.GNU-stack noalloc noexec nowrite progbits
  189. section .text
  190. %endif
  191. %ifdef REL_TEXT
  192. %define WRT_OPT
  193. %elifidn __OUTPUT_FORMAT__, elf64
  194. %define WRT_OPT wrt ..plt
  195. %else
  196. %define WRT_OPT
  197. %endif
  198. %ifidn __OUTPUT_FORMAT__, macho64
  199. %define elf64 macho64
  200. mac_equ equ 1
  201. %ifdef __NASM_VER__
  202. %define ISAL_SYM_TYPE_FUNCTION
  203. %define ISAL_SYM_TYPE_DATA_INTERNAL
  204. %else
  205. %define ISAL_SYM_TYPE_FUNCTION function
  206. %define ISAL_SYM_TYPE_DATA_INTERNAL data internal
  207. %endif
  208. %else
  209. %define ISAL_SYM_TYPE_FUNCTION function
  210. %define ISAL_SYM_TYPE_DATA_INTERNAL data internal
  211. %endif
  212. %macro slversion 4
  213. section .text
  214. global %1_slver_%2%3%4
  215. global %1_slver
  216. %1_slver:
  217. %1_slver_%2%3%4:
  218. dw 0x%4
  219. db 0x%3, 0x%2
  220. %endmacro
  221. %endif ; ifndef _REG_SIZES_ASM_