2 * Generate .byte code for some instructions not supported by old
10 #define REG_NUM_INVALID 100
12 #define REG_TYPE_R64 0
13 #define REG_TYPE_XMM 1
14 #define REG_TYPE_INVALID 100
16 .macro R64_NUM opd r64
17 \opd = REG_NUM_INVALID
68 .macro XMM_NUM opd xmm
69 \opd = REG_NUM_INVALID
120 .macro REG_TYPE type reg
121 R64_NUM reg_type_r64 \reg
122 XMM_NUM reg_type_xmm \reg
123 .if reg_type_r64 <> REG_NUM_INVALID
125 .elseif reg_type_xmm <> REG_NUM_INVALID
128 \type = REG_TYPE_INVALID
136 .macro PFX_REX opd1 opd2 W=0
137 .if ((\opd1 | \opd2) & 8) || \W
138 .byte 0x40 | ((\opd1 & 8) >> 3) | ((\opd2 & 8) >> 1) | (\W << 3)
142 .macro MODRM mod opd1 opd2
143 .byte \mod | (\opd1 & 7) | ((\opd2 & 7) << 3)
146 .macro PSHUFB_XMM xmm1 xmm2
147 XMM_NUM pshufb_opd1 \xmm1
148 XMM_NUM pshufb_opd2 \xmm2
150 PFX_REX pshufb_opd1 pshufb_opd2
151 .byte 0x0f, 0x38, 0x00
152 MODRM 0xc0 pshufb_opd1 pshufb_opd2
155 .macro PCLMULQDQ imm8 xmm1 xmm2
156 XMM_NUM clmul_opd1 \xmm1
157 XMM_NUM clmul_opd2 \xmm2
159 PFX_REX clmul_opd1 clmul_opd2
160 .byte 0x0f, 0x3a, 0x44
161 MODRM 0xc0 clmul_opd1 clmul_opd2
165 .macro AESKEYGENASSIST rcon xmm1 xmm2
166 XMM_NUM aeskeygen_opd1 \xmm1
167 XMM_NUM aeskeygen_opd2 \xmm2
169 PFX_REX aeskeygen_opd1 aeskeygen_opd2
170 .byte 0x0f, 0x3a, 0xdf
171 MODRM 0xc0 aeskeygen_opd1 aeskeygen_opd2
175 .macro AESIMC xmm1 xmm2
176 XMM_NUM aesimc_opd1 \xmm1
177 XMM_NUM aesimc_opd2 \xmm2
179 PFX_REX aesimc_opd1 aesimc_opd2
180 .byte 0x0f, 0x38, 0xdb
181 MODRM 0xc0 aesimc_opd1 aesimc_opd2
184 .macro AESENC xmm1 xmm2
185 XMM_NUM aesenc_opd1 \xmm1
186 XMM_NUM aesenc_opd2 \xmm2
188 PFX_REX aesenc_opd1 aesenc_opd2
189 .byte 0x0f, 0x38, 0xdc
190 MODRM 0xc0 aesenc_opd1 aesenc_opd2
193 .macro AESENCLAST xmm1 xmm2
194 XMM_NUM aesenclast_opd1 \xmm1
195 XMM_NUM aesenclast_opd2 \xmm2
197 PFX_REX aesenclast_opd1 aesenclast_opd2
198 .byte 0x0f, 0x38, 0xdd
199 MODRM 0xc0 aesenclast_opd1 aesenclast_opd2
202 .macro AESDEC xmm1 xmm2
203 XMM_NUM aesdec_opd1 \xmm1
204 XMM_NUM aesdec_opd2 \xmm2
206 PFX_REX aesdec_opd1 aesdec_opd2
207 .byte 0x0f, 0x38, 0xde
208 MODRM 0xc0 aesdec_opd1 aesdec_opd2
211 .macro AESDECLAST xmm1 xmm2
212 XMM_NUM aesdeclast_opd1 \xmm1
213 XMM_NUM aesdeclast_opd2 \xmm2
215 PFX_REX aesdeclast_opd1 aesdeclast_opd2
216 .byte 0x0f, 0x38, 0xdf
217 MODRM 0xc0 aesdeclast_opd1 aesdeclast_opd2
220 .macro MOVQ_R64_XMM opd1 opd2
221 REG_TYPE movq_r64_xmm_opd1_type \opd1
222 .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
223 XMM_NUM movq_r64_xmm_opd1 \opd1
224 R64_NUM movq_r64_xmm_opd2 \opd2
226 R64_NUM movq_r64_xmm_opd1 \opd1
227 XMM_NUM movq_r64_xmm_opd2 \opd2
230 PFX_REX movq_r64_xmm_opd1 movq_r64_xmm_opd2 1
231 .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
236 MODRM 0xc0 movq_r64_xmm_opd1 movq_r64_xmm_opd2