1 //===-- X86InstComments.cpp - Generate verbose-asm comments for instrs ----===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This defines functionality used to emit comments about X86 instructions to
10 // an output stream for -fverbose-asm.
12 //===----------------------------------------------------------------------===//
14 #include "X86InstComments.h"
15 #include "X86ATTInstPrinter.h"
16 #include "X86BaseInfo.h"
17 #include "X86MCTargetDesc.h"
18 #include "X86ShuffleDecode.h"
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/Support/raw_ostream.h"
22 #include <string_view>
26 #define CASE_SSE_INS_COMMON(Inst, src) \
29 #define CASE_AVX_INS_COMMON(Inst, Suffix, src) \
30 case X86::V##Inst##Suffix##src:
32 #define CASE_MASK_INS_COMMON(Inst, Suffix, src) \
33 case X86::V##Inst##Suffix##src##k:
35 #define CASE_MASKZ_INS_COMMON(Inst, Suffix, src) \
36 case X86::V##Inst##Suffix##src##kz:
38 #define CASE_AVX512_INS_COMMON(Inst, Suffix, src) \
39 CASE_AVX_INS_COMMON(Inst, Suffix, src) \
40 CASE_MASK_INS_COMMON(Inst, Suffix, src) \
41 CASE_MASKZ_INS_COMMON(Inst, Suffix, src)
43 #define CASE_FPCLASS_PACKED(Inst, src) \
44 CASE_AVX_INS_COMMON(Inst, Z, src##i) \
45 CASE_AVX_INS_COMMON(Inst, Z256, src##i) \
46 CASE_AVX_INS_COMMON(Inst, Z128, src##i) \
47 CASE_MASK_INS_COMMON(Inst, Z, src##i)
49 #define CASE_FPCLASS_PACKED_MEM(Inst) \
50 CASE_FPCLASS_PACKED(Inst, m) \
51 CASE_FPCLASS_PACKED(Inst, mb)
53 #define CASE_FPCLASS_SCALAR(Inst, src) \
54 CASE_AVX_INS_COMMON(Inst, Z, src##i) \
55 CASE_MASK_INS_COMMON(Inst, Z, src##i)
57 #define CASE_PTERNLOG(Inst, src) \
58 CASE_AVX512_INS_COMMON(Inst, Z, r##src##i) \
59 CASE_AVX512_INS_COMMON(Inst, Z256, r##src##i) \
60 CASE_AVX512_INS_COMMON(Inst, Z128, r##src##i)
62 #define CASE_MOVDUP(Inst, src) \
63 CASE_AVX512_INS_COMMON(Inst, Z, r##src) \
64 CASE_AVX512_INS_COMMON(Inst, Z256, r##src) \
65 CASE_AVX512_INS_COMMON(Inst, Z128, r##src) \
66 CASE_AVX_INS_COMMON(Inst, , r##src) \
67 CASE_AVX_INS_COMMON(Inst, Y, r##src) \
68 CASE_SSE_INS_COMMON(Inst, r##src)
70 #define CASE_MASK_MOVDUP(Inst, src) \
71 CASE_MASK_INS_COMMON(Inst, Z, r##src) \
72 CASE_MASK_INS_COMMON(Inst, Z256, r##src) \
73 CASE_MASK_INS_COMMON(Inst, Z128, r##src)
75 #define CASE_MASKZ_MOVDUP(Inst, src) \
76 CASE_MASKZ_INS_COMMON(Inst, Z, r##src) \
77 CASE_MASKZ_INS_COMMON(Inst, Z256, r##src) \
78 CASE_MASKZ_INS_COMMON(Inst, Z128, r##src)
80 #define CASE_PMOVZX(Inst, src) \
81 CASE_AVX512_INS_COMMON(Inst, Z, r##src) \
82 CASE_AVX512_INS_COMMON(Inst, Z256, r##src) \
83 CASE_AVX512_INS_COMMON(Inst, Z128, r##src) \
84 CASE_AVX_INS_COMMON(Inst, , r##src) \
85 CASE_AVX_INS_COMMON(Inst, Y, r##src) \
86 CASE_SSE_INS_COMMON(Inst, r##src)
88 #define CASE_UNPCK(Inst, src) \
89 CASE_AVX512_INS_COMMON(Inst, Z, r##src) \
90 CASE_AVX512_INS_COMMON(Inst, Z256, r##src) \
91 CASE_AVX512_INS_COMMON(Inst, Z128, r##src) \
92 CASE_AVX_INS_COMMON(Inst, , r##src) \
93 CASE_AVX_INS_COMMON(Inst, Y, r##src) \
94 CASE_SSE_INS_COMMON(Inst, r##src)
96 #define CASE_MASK_UNPCK(Inst, src) \
97 CASE_MASK_INS_COMMON(Inst, Z, r##src) \
98 CASE_MASK_INS_COMMON(Inst, Z256, r##src) \
99 CASE_MASK_INS_COMMON(Inst, Z128, r##src)
101 #define CASE_MASKZ_UNPCK(Inst, src) \
102 CASE_MASKZ_INS_COMMON(Inst, Z, r##src) \
103 CASE_MASKZ_INS_COMMON(Inst, Z256, r##src) \
104 CASE_MASKZ_INS_COMMON(Inst, Z128, r##src)
106 #define CASE_SHUF(Inst, suf) \
107 CASE_AVX512_INS_COMMON(Inst, Z, suf) \
108 CASE_AVX512_INS_COMMON(Inst, Z256, suf) \
109 CASE_AVX512_INS_COMMON(Inst, Z128, suf) \
110 CASE_AVX_INS_COMMON(Inst, , suf) \
111 CASE_AVX_INS_COMMON(Inst, Y, suf) \
112 CASE_SSE_INS_COMMON(Inst, suf)
114 #define CASE_MASK_SHUF(Inst, src) \
115 CASE_MASK_INS_COMMON(Inst, Z, r##src##i) \
116 CASE_MASK_INS_COMMON(Inst, Z256, r##src##i) \
117 CASE_MASK_INS_COMMON(Inst, Z128, r##src##i)
119 #define CASE_MASKZ_SHUF(Inst, src) \
120 CASE_MASKZ_INS_COMMON(Inst, Z, r##src##i) \
121 CASE_MASKZ_INS_COMMON(Inst, Z256, r##src##i) \
122 CASE_MASKZ_INS_COMMON(Inst, Z128, r##src##i)
124 #define CASE_VPERMILPI(Inst, src) \
125 CASE_AVX512_INS_COMMON(Inst, Z, src##i) \
126 CASE_AVX512_INS_COMMON(Inst, Z256, src##i) \
127 CASE_AVX512_INS_COMMON(Inst, Z128, src##i) \
128 CASE_AVX_INS_COMMON(Inst, , src##i) \
129 CASE_AVX_INS_COMMON(Inst, Y, src##i)
131 #define CASE_MASK_VPERMILPI(Inst, src) \
132 CASE_MASK_INS_COMMON(Inst, Z, src##i) \
133 CASE_MASK_INS_COMMON(Inst, Z256, src##i) \
134 CASE_MASK_INS_COMMON(Inst, Z128, src##i)
136 #define CASE_MASKZ_VPERMILPI(Inst, src) \
137 CASE_MASKZ_INS_COMMON(Inst, Z, src##i) \
138 CASE_MASKZ_INS_COMMON(Inst, Z256, src##i) \
139 CASE_MASKZ_INS_COMMON(Inst, Z128, src##i)
141 #define CASE_VPERM(Inst, src) \
142 CASE_AVX512_INS_COMMON(Inst, Z, src##i) \
143 CASE_AVX512_INS_COMMON(Inst, Z256, src##i) \
144 CASE_AVX_INS_COMMON(Inst, Y, src##i)
146 #define CASE_MASK_VPERM(Inst, src) \
147 CASE_MASK_INS_COMMON(Inst, Z, src##i) \
148 CASE_MASK_INS_COMMON(Inst, Z256, src##i)
150 #define CASE_MASKZ_VPERM(Inst, src) \
151 CASE_MASKZ_INS_COMMON(Inst, Z, src##i) \
152 CASE_MASKZ_INS_COMMON(Inst, Z256, src##i)
154 #define CASE_VSHUF(Inst, src) \
155 CASE_AVX512_INS_COMMON(SHUFF##Inst, Z, r##src##i) \
156 CASE_AVX512_INS_COMMON(SHUFI##Inst, Z, r##src##i) \
157 CASE_AVX512_INS_COMMON(SHUFF##Inst, Z256, r##src##i) \
158 CASE_AVX512_INS_COMMON(SHUFI##Inst, Z256, r##src##i)
160 #define CASE_MASK_VSHUF(Inst, src) \
161 CASE_MASK_INS_COMMON(SHUFF##Inst, Z, r##src##i) \
162 CASE_MASK_INS_COMMON(SHUFI##Inst, Z, r##src##i) \
163 CASE_MASK_INS_COMMON(SHUFF##Inst, Z256, r##src##i) \
164 CASE_MASK_INS_COMMON(SHUFI##Inst, Z256, r##src##i)
166 #define CASE_MASKZ_VSHUF(Inst, src) \
167 CASE_MASKZ_INS_COMMON(SHUFF##Inst, Z, r##src##i) \
168 CASE_MASKZ_INS_COMMON(SHUFI##Inst, Z, r##src##i) \
169 CASE_MASKZ_INS_COMMON(SHUFF##Inst, Z256, r##src##i) \
170 CASE_MASKZ_INS_COMMON(SHUFI##Inst, Z256, r##src##i)
172 #define CASE_AVX512_FMA(Inst, suf) \
173 CASE_AVX512_INS_COMMON(Inst, Z, suf) \
174 CASE_AVX512_INS_COMMON(Inst, Z256, suf) \
175 CASE_AVX512_INS_COMMON(Inst, Z128, suf)
177 #define CASE_FMA(Inst, suf) \
178 CASE_AVX512_FMA(Inst, suf) \
179 CASE_AVX_INS_COMMON(Inst, , suf) \
180 CASE_AVX_INS_COMMON(Inst, Y, suf)
182 #define CASE_FMA_PACKED_REG(Inst) \
183 CASE_FMA(Inst##PD, r) \
184 CASE_FMA(Inst##PS, r)
186 #define CASE_FMA_PACKED_MEM(Inst) \
187 CASE_FMA(Inst##PD, m) \
188 CASE_FMA(Inst##PS, m) \
189 CASE_AVX512_FMA(Inst##PD, mb) \
190 CASE_AVX512_FMA(Inst##PS, mb)
192 #define CASE_FMA_SCALAR_REG(Inst) \
193 CASE_AVX_INS_COMMON(Inst##SD, , r) \
194 CASE_AVX_INS_COMMON(Inst##SS, , r) \
195 CASE_AVX_INS_COMMON(Inst##SD, , r_Int) \
196 CASE_AVX_INS_COMMON(Inst##SS, , r_Int) \
197 CASE_AVX_INS_COMMON(Inst##SD, Z, r) \
198 CASE_AVX_INS_COMMON(Inst##SS, Z, r) \
199 CASE_AVX512_INS_COMMON(Inst##SD, Z, r_Int) \
200 CASE_AVX512_INS_COMMON(Inst##SS, Z, r_Int)
202 #define CASE_FMA_SCALAR_MEM(Inst) \
203 CASE_AVX_INS_COMMON(Inst##SD, , m) \
204 CASE_AVX_INS_COMMON(Inst##SS, , m) \
205 CASE_AVX_INS_COMMON(Inst##SD, , m_Int) \
206 CASE_AVX_INS_COMMON(Inst##SS, , m_Int) \
207 CASE_AVX_INS_COMMON(Inst##SD, Z, m) \
208 CASE_AVX_INS_COMMON(Inst##SS, Z, m) \
209 CASE_AVX512_INS_COMMON(Inst##SD, Z, m_Int) \
210 CASE_AVX512_INS_COMMON(Inst##SS, Z, m_Int)
212 #define CASE_FMA4(Inst, suf) \
213 CASE_AVX_INS_COMMON(Inst, 4, suf) \
214 CASE_AVX_INS_COMMON(Inst, 4Y, suf)
216 #define CASE_FMA4_PACKED_RR(Inst) \
217 CASE_FMA4(Inst##PD, rr) \
218 CASE_FMA4(Inst##PS, rr)
220 #define CASE_FMA4_PACKED_RM(Inst) \
221 CASE_FMA4(Inst##PD, rm) \
222 CASE_FMA4(Inst##PS, rm)
224 #define CASE_FMA4_PACKED_MR(Inst) \
225 CASE_FMA4(Inst##PD, mr) \
226 CASE_FMA4(Inst##PS, mr)
228 #define CASE_FMA4_SCALAR_RR(Inst) \
229 CASE_AVX_INS_COMMON(Inst##SD4, , rr) \
230 CASE_AVX_INS_COMMON(Inst##SS4, , rr) \
231 CASE_AVX_INS_COMMON(Inst##SD4, , rr_Int) \
232 CASE_AVX_INS_COMMON(Inst##SS4, , rr_Int)
234 #define CASE_FMA4_SCALAR_RM(Inst) \
235 CASE_AVX_INS_COMMON(Inst##SD4, , rm) \
236 CASE_AVX_INS_COMMON(Inst##SS4, , rm) \
237 CASE_AVX_INS_COMMON(Inst##SD4, , rm_Int) \
238 CASE_AVX_INS_COMMON(Inst##SS4, , rm_Int)
240 #define CASE_FMA4_SCALAR_MR(Inst) \
241 CASE_AVX_INS_COMMON(Inst##SD4, , mr) \
242 CASE_AVX_INS_COMMON(Inst##SS4, , mr) \
243 CASE_AVX_INS_COMMON(Inst##SD4, , mr_Int) \
244 CASE_AVX_INS_COMMON(Inst##SS4, , mr_Int)
246 static unsigned getVectorRegSize(MCRegister Reg
) {
247 if (X86II::isZMMReg(Reg
))
249 if (X86II::isYMMReg(Reg
))
251 if (X86II::isXMMReg(Reg
))
253 if (Reg
>= X86::MM0
&& Reg
<= X86::MM7
)
256 llvm_unreachable("Unknown vector reg!");
259 static unsigned getRegOperandNumElts(const MCInst
*MI
, unsigned ScalarSize
,
260 unsigned OperandIndex
) {
261 MCRegister OpReg
= MI
->getOperand(OperandIndex
).getReg();
262 return getVectorRegSize(OpReg
) / ScalarSize
;
265 static const char *getRegName(MCRegister Reg
) {
266 return X86ATTInstPrinter::getRegisterName(Reg
);
269 /// Wraps the destination register name with AVX512 mask/maskz filtering.
270 static void printMasking(raw_ostream
&OS
, const MCInst
*MI
,
271 const MCInstrInfo
&MCII
) {
272 const MCInstrDesc
&Desc
= MCII
.get(MI
->getOpcode());
273 uint64_t TSFlags
= Desc
.TSFlags
;
275 if (!(TSFlags
& X86II::EVEX_K
))
278 bool MaskWithZero
= (TSFlags
& X86II::EVEX_Z
);
279 unsigned MaskOp
= Desc
.getNumDefs();
281 if (Desc
.getOperandConstraint(MaskOp
, MCOI::TIED_TO
) != -1)
284 const char *MaskRegName
= getRegName(MI
->getOperand(MaskOp
).getReg());
287 OS
<< " {%" << MaskRegName
<< "}";
289 // MASKZ: zmmX {%kY} {z}
294 static bool printFMAComments(const MCInst
*MI
, raw_ostream
&OS
,
295 const MCInstrInfo
&MCII
) {
296 const char *Mul1Name
= nullptr, *Mul2Name
= nullptr, *AccName
= nullptr;
297 unsigned NumOperands
= MI
->getNumOperands();
298 bool RegForm
= false;
300 StringRef AccStr
= "+";
302 // The operands for FMA3 instructions without rounding fall into two forms:
303 // dest, src1, src2, src3
304 // dest, src1, mask, src2, src3
305 // Where src3 is either a register or 5 memory address operands. So to find
306 // dest and src1 we can index from the front. To find src2 and src3 we can
307 // index from the end by taking into account memory vs register form when
310 // The operands for FMA4 instructions:
311 // dest, src1, src2, src3
312 // Where src2 OR src3 are either a register or 5 memory address operands. So
313 // to find dest and src1 we can index from the front, src2 (reg/mem) follows
314 // and then src3 (reg) will be at the end.
316 switch (MI
->getOpcode()) {
320 CASE_FMA4_PACKED_RR(FMADD
)
321 CASE_FMA4_SCALAR_RR(FMADD
)
322 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
324 CASE_FMA4_PACKED_RM(FMADD
)
325 CASE_FMA4_SCALAR_RM(FMADD
)
326 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
327 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
329 CASE_FMA4_PACKED_MR(FMADD
)
330 CASE_FMA4_SCALAR_MR(FMADD
)
331 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
332 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
335 CASE_FMA4_PACKED_RR(FMSUB
)
336 CASE_FMA4_SCALAR_RR(FMSUB
)
337 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
339 CASE_FMA4_PACKED_RM(FMSUB
)
340 CASE_FMA4_SCALAR_RM(FMSUB
)
341 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
342 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
345 CASE_FMA4_PACKED_MR(FMSUB
)
346 CASE_FMA4_SCALAR_MR(FMSUB
)
347 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
348 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
352 CASE_FMA4_PACKED_RR(FNMADD
)
353 CASE_FMA4_SCALAR_RR(FNMADD
)
354 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
356 CASE_FMA4_PACKED_RM(FNMADD
)
357 CASE_FMA4_SCALAR_RM(FNMADD
)
358 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
359 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
362 CASE_FMA4_PACKED_MR(FNMADD
)
363 CASE_FMA4_SCALAR_MR(FNMADD
)
364 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
365 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
369 CASE_FMA4_PACKED_RR(FNMSUB
)
370 CASE_FMA4_SCALAR_RR(FNMSUB
)
371 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
373 CASE_FMA4_PACKED_RM(FNMSUB
)
374 CASE_FMA4_SCALAR_RM(FNMSUB
)
375 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
376 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
380 CASE_FMA4_PACKED_MR(FNMSUB
)
381 CASE_FMA4_SCALAR_MR(FNMSUB
)
382 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
383 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
388 CASE_FMA4_PACKED_RR(FMADDSUB
)
389 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
391 CASE_FMA4_PACKED_RM(FMADDSUB
)
392 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
393 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
396 CASE_FMA4_PACKED_MR(FMADDSUB
)
397 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
398 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
402 CASE_FMA4_PACKED_RR(FMSUBADD
)
403 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
405 CASE_FMA4_PACKED_RM(FMSUBADD
)
406 Mul2Name
= getRegName(MI
->getOperand(2).getReg());
407 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
410 CASE_FMA4_PACKED_MR(FMSUBADD
)
411 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
412 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
416 CASE_FMA_PACKED_REG(FMADD132
)
417 CASE_FMA_SCALAR_REG(FMADD132
)
418 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
421 CASE_FMA_PACKED_MEM(FMADD132
)
422 CASE_FMA_SCALAR_MEM(FMADD132
)
423 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
424 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
427 CASE_FMA_PACKED_REG(FMADD213
)
428 CASE_FMA_SCALAR_REG(FMADD213
)
429 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
432 CASE_FMA_PACKED_MEM(FMADD213
)
433 CASE_FMA_SCALAR_MEM(FMADD213
)
434 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
435 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
438 CASE_FMA_PACKED_REG(FMADD231
)
439 CASE_FMA_SCALAR_REG(FMADD231
)
440 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
443 CASE_FMA_PACKED_MEM(FMADD231
)
444 CASE_FMA_SCALAR_MEM(FMADD231
)
445 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
446 AccName
= getRegName(MI
->getOperand(1).getReg());
449 CASE_FMA_PACKED_REG(FMSUB132
)
450 CASE_FMA_SCALAR_REG(FMSUB132
)
451 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
454 CASE_FMA_PACKED_MEM(FMSUB132
)
455 CASE_FMA_SCALAR_MEM(FMSUB132
)
456 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
457 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
461 CASE_FMA_PACKED_REG(FMSUB213
)
462 CASE_FMA_SCALAR_REG(FMSUB213
)
463 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
466 CASE_FMA_PACKED_MEM(FMSUB213
)
467 CASE_FMA_SCALAR_MEM(FMSUB213
)
468 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
469 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
473 CASE_FMA_PACKED_REG(FMSUB231
)
474 CASE_FMA_SCALAR_REG(FMSUB231
)
475 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
478 CASE_FMA_PACKED_MEM(FMSUB231
)
479 CASE_FMA_SCALAR_MEM(FMSUB231
)
480 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
481 AccName
= getRegName(MI
->getOperand(1).getReg());
485 CASE_FMA_PACKED_REG(FNMADD132
)
486 CASE_FMA_SCALAR_REG(FNMADD132
)
487 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
490 CASE_FMA_PACKED_MEM(FNMADD132
)
491 CASE_FMA_SCALAR_MEM(FNMADD132
)
492 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
493 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
497 CASE_FMA_PACKED_REG(FNMADD213
)
498 CASE_FMA_SCALAR_REG(FNMADD213
)
499 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
502 CASE_FMA_PACKED_MEM(FNMADD213
)
503 CASE_FMA_SCALAR_MEM(FNMADD213
)
504 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
505 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
509 CASE_FMA_PACKED_REG(FNMADD231
)
510 CASE_FMA_SCALAR_REG(FNMADD231
)
511 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
514 CASE_FMA_PACKED_MEM(FNMADD231
)
515 CASE_FMA_SCALAR_MEM(FNMADD231
)
516 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
517 AccName
= getRegName(MI
->getOperand(1).getReg());
521 CASE_FMA_PACKED_REG(FNMSUB132
)
522 CASE_FMA_SCALAR_REG(FNMSUB132
)
523 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
526 CASE_FMA_PACKED_MEM(FNMSUB132
)
527 CASE_FMA_SCALAR_MEM(FNMSUB132
)
528 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
529 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
534 CASE_FMA_PACKED_REG(FNMSUB213
)
535 CASE_FMA_SCALAR_REG(FNMSUB213
)
536 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
539 CASE_FMA_PACKED_MEM(FNMSUB213
)
540 CASE_FMA_SCALAR_MEM(FNMSUB213
)
541 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
542 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
547 CASE_FMA_PACKED_REG(FNMSUB231
)
548 CASE_FMA_SCALAR_REG(FNMSUB231
)
549 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
552 CASE_FMA_PACKED_MEM(FNMSUB231
)
553 CASE_FMA_SCALAR_MEM(FNMSUB231
)
554 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
555 AccName
= getRegName(MI
->getOperand(1).getReg());
560 CASE_FMA_PACKED_REG(FMADDSUB132
)
561 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
564 CASE_FMA_PACKED_MEM(FMADDSUB132
)
565 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
566 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
570 CASE_FMA_PACKED_REG(FMADDSUB213
)
571 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
574 CASE_FMA_PACKED_MEM(FMADDSUB213
)
575 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
576 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
580 CASE_FMA_PACKED_REG(FMADDSUB231
)
581 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
584 CASE_FMA_PACKED_MEM(FMADDSUB231
)
585 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
586 AccName
= getRegName(MI
->getOperand(1).getReg());
590 CASE_FMA_PACKED_REG(FMSUBADD132
)
591 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
594 CASE_FMA_PACKED_MEM(FMSUBADD132
)
595 AccName
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
596 Mul1Name
= getRegName(MI
->getOperand(1).getReg());
600 CASE_FMA_PACKED_REG(FMSUBADD213
)
601 AccName
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
604 CASE_FMA_PACKED_MEM(FMSUBADD213
)
605 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
606 Mul2Name
= getRegName(MI
->getOperand(1).getReg());
610 CASE_FMA_PACKED_REG(FMSUBADD231
)
611 Mul2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
614 CASE_FMA_PACKED_MEM(FMSUBADD231
)
615 Mul1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
616 AccName
= getRegName(MI
->getOperand(1).getReg());
621 const char *DestName
= getRegName(MI
->getOperand(0).getReg());
623 if (!Mul1Name
) Mul1Name
= "mem";
624 if (!Mul2Name
) Mul2Name
= "mem";
625 if (!AccName
) AccName
= "mem";
628 printMasking(OS
, MI
, MCII
);
634 OS
<< '(' << Mul1Name
<< " * " << Mul2Name
<< ") " << AccStr
<< ' '
640 // This table is indexed by the imm8 binary function specified in a
641 // vpternlog{d,q} instruction. The symbols {a,b,c} correspond to the three
642 // inputs to the binary function. This table was taken from
643 // https://gist.github.com/dougallj/81a80cd381988466c4e1c4889ecac95b#file-2-x86-base-txt
644 // with slight massaging.
645 constexpr StringLiteral TernlogFunctions
[] = {
668 "a ^ ((a & b) | (b ^ c))",
669 "(a & (b ^ c)) ^ ~(b & c)",
671 "~((a & b) | (b ^ c))",
673 "(a & c) ^ (c | ~b)",
675 "(a & b) ^ (b | ~c)",
683 "~((a & b) | (a ^ c))",
685 "(b & c) ^ (c | ~a)",
687 "(a | b) ^ ((a & b) | ~c)",
689 "(c & (a ^ b)) | ~(a | b)",
699 "(a & b) ^ (a | ~c)",
707 "~(a | c) | (a ^ b)",
708 "(c & ~a) | (a ^ b)",
713 "~((a & c) | (a ^ b))",
717 "(b & c) ^ (b | ~a)",
719 "(a | c) ^ ((a & c) | ~b)",
723 "(b & (a ^ c)) | ~(a | c)",
729 "(a & c) ^ (a | ~b)",
737 "~(a | b) | (a ^ c)",
740 "(b & ~a) | (a ^ c)",
743 "~(b ^ c) ^ (a | (b & c))",
749 "~(a | b) | (b ^ c)",
750 "(a | b) & (c ^ (a & b))",
753 "~(a | b) | (c ^ (a & b))",
755 "~(a | c) | (b ^ (a & c))",
756 "(b & ~a) | (b ^ c)",
759 "(a & (b ^ c)) | ~(b | c)",
764 "(a & ~b) | (b ^ c)",
767 "~(b | c) | (a ^ (b & c))",
768 "(a & ~b) | (a ^ c)",
770 "(a & ~c) | (a ^ b)",
775 "~((a ^ b) | (a ^ c))",
777 "~(a ^ b) & (c | ~a)",
779 "~(a ^ c) & (b | ~a)",
780 "(b | c) & (a ^ b ^ c)",
783 "~(b ^ c) & (b | ~a)",
785 "~((b & c) ^ (a | b))",
787 "~((b & c) ^ (a | c))",
788 "a ^ ((a ^ b) | (a ^ c))",
791 "~(b ^ c) & (a | ~b)",
792 "(a | c) & (a ^ b ^ c)",
794 "(a | b) & (a ^ b ^ c)",
797 "~(a | b) | (a ^ b ^ c)",
798 "~(b ^ c) & (a | b)",
801 "~((a | b) & (b ^ c))",
803 "~((a | c) & (b ^ c))",
804 "(b & c) | (a ^ (b | c))",
807 "~(a ^ c) & (a | ~b)",
809 "~((a & c) ^ (a | b))",
810 "~(a ^ c) & (a | b)",
813 "~((a | b) & (a ^ c))",
819 "(b & c) | ~(a ^ c)",
823 "~((a & c) ^ (b | c))",
824 "a ^ ((a ^ c) & (b ^ c))",
827 "~((b | c) & (a ^ c))",
828 "(a & c) | (a ^ b ^ c)",
831 "(a & c) | ~(b ^ c)",
835 "~((a ^ c) & (b ^ c))",
839 "~(a ^ b) & (a | ~c)",
840 "~(a ^ b) & (a | c)",
843 "~((a & b) ^ (a | c))",
845 "~((a | c) & (a ^ b))",
849 "(b & c) | ~(a ^ b)",
855 "~((a & b) ^ (b | c))",
857 "~((b | c) & (a ^ b))",
858 "a ^ ((a ^ b) & (b ^ c))",
860 "(a & b) | (a ^ b ^ c)",
863 "(a & b) | ~(b ^ c)",
865 "~((a ^ b) & (b ^ c))",
873 "(a & c) | ~(a ^ b)",
875 "(a & b) | ~(a ^ c)",
877 "~((a ^ b) & (a ^ c))",
878 "(a | b) & ((a & b) | c)",
879 "(a & b) | (b ^ c ^ ~a)",
904 static bool printPTERNLOGComments(const MCInst
*MI
, raw_ostream
&OS
,
905 const MCInstrInfo
&MCII
) {
906 unsigned NumOperands
= MI
->getNumOperands();
910 switch (MI
->getOpcode()) {
911 // dest, src1, src2, src3, tbl
912 // dest, src1, mask, src2, src3, tbl
913 CASE_PTERNLOG(PTERNLOGD
, r
)
914 CASE_PTERNLOG(PTERNLOGQ
, r
)
915 Src2Idx
= NumOperands
- 3;
916 Src3Idx
= NumOperands
- 2;
919 // dest, src1, src2, memory, tbl
920 // dest, src1, mask, src2, memory, tbl
921 CASE_PTERNLOG(PTERNLOGD
, m
)
922 CASE_PTERNLOG(PTERNLOGQ
, m
)
923 CASE_PTERNLOG(PTERNLOGD
, mb
)
924 CASE_PTERNLOG(PTERNLOGQ
, mb
)
925 Src2Idx
= NumOperands
- 7;
932 StringRef DestName
= getRegName(MI
->getOperand(0).getReg());
933 StringRef Src1Name
= getRegName(MI
->getOperand(1).getReg());
934 StringRef Src2Name
= getRegName(MI
->getOperand(Src2Idx
).getReg());
936 Src3Idx
!= -1 ? getRegName(MI
->getOperand(Src3Idx
).getReg()) : "mem";
937 uint8_t TruthTable
= MI
->getOperand(NumOperands
- 1).getImm();
939 StringRef SrcNames
[] = {Src1Name
, Src2Name
, Src3Name
};
942 printMasking(OS
, MI
, MCII
);
945 static_assert(std::size(TernlogFunctions
) == 256);
946 std::string_view BooleanFunction
= TernlogFunctions
[TruthTable
];
948 while (!BooleanFunction
.empty()) {
949 // Print the expression up to the next symbol.
950 size_t SymbolOffset
= BooleanFunction
.find_first_of("abc");
951 OS
<< BooleanFunction
.substr(0, SymbolOffset
);
952 if (SymbolOffset
== std::string_view::npos
) {
953 // No more symbols, that means we just printed everything.
956 // Let's replace {a,b,c} with Src{1,2,3}Name.
957 char Symbol
= BooleanFunction
[SymbolOffset
];
958 OS
<< SrcNames
[Symbol
- 'a'];
959 // Consume the part of the expression we handled.
960 BooleanFunction
.remove_prefix(SymbolOffset
+ 1);
966 static bool printFPCLASSComments(const MCInst
*MI
, raw_ostream
&OS
,
967 const MCInstrInfo
&MCII
) {
968 unsigned NumOperands
= MI
->getNumOperands();
970 switch (MI
->getOpcode()) {
971 CASE_FPCLASS_PACKED(FPCLASSPBF16
, r
)
972 CASE_FPCLASS_PACKED(FPCLASSPH
, r
)
973 CASE_FPCLASS_PACKED(FPCLASSPS
, r
)
974 CASE_FPCLASS_PACKED(FPCLASSPD
, r
)
975 CASE_FPCLASS_SCALAR(FPCLASSSH
, r
)
976 CASE_FPCLASS_SCALAR(FPCLASSSS
, r
)
977 CASE_FPCLASS_SCALAR(FPCLASSSD
, r
) {
978 SrcIdx
= NumOperands
- 2;
981 CASE_FPCLASS_PACKED_MEM(FPCLASSPBF16
)
982 CASE_FPCLASS_PACKED_MEM(FPCLASSPH
)
983 CASE_FPCLASS_PACKED_MEM(FPCLASSPS
)
984 CASE_FPCLASS_PACKED_MEM(FPCLASSPD
)
985 CASE_FPCLASS_SCALAR(FPCLASSSH
, m
)
986 CASE_FPCLASS_SCALAR(FPCLASSSS
, m
)
987 CASE_FPCLASS_SCALAR(FPCLASSSD
, m
) {
994 StringRef DestName
= getRegName(MI
->getOperand(0).getReg());
996 SrcIdx
!= -1 ? getRegName(MI
->getOperand(SrcIdx
).getReg()) : "mem";
999 printMasking(OS
, MI
, MCII
);
1002 uint8_t Categories
= MI
->getOperand(NumOperands
- 1).getImm();
1003 if (Categories
== 0) {
1006 static constexpr StringLiteral CategoryNames
[] = {
1016 bool Conjoin
= false;
1017 for (size_t I
= 0, E
= std::size(CategoryNames
); I
!= E
; ++I
) {
1018 if (Categories
& (1 << I
)) {
1022 OS
<< "is" << CategoryNames
[I
] << '(' << SrcName
<< ')';
1030 //===----------------------------------------------------------------------===//
1031 // Top Level Entrypoint
1032 //===----------------------------------------------------------------------===//
1034 /// EmitAnyX86InstComments - This function decodes x86 instructions and prints
1035 /// newline terminated strings to the specified string if desired. This
1036 /// information is shown in disassembly dumps when verbose assembly is enabled.
1037 bool llvm::EmitAnyX86InstComments(const MCInst
*MI
, raw_ostream
&OS
,
1038 const MCInstrInfo
&MCII
) {
1039 // If this is a shuffle operation, the switch should fill in this state.
1040 SmallVector
<int, 8> ShuffleMask
;
1041 const char *DestName
= nullptr, *Src1Name
= nullptr, *Src2Name
= nullptr;
1042 unsigned NumOperands
= MI
->getNumOperands();
1043 bool RegForm
= false;
1045 if (printFMAComments(MI
, OS
, MCII
))
1048 if (printPTERNLOGComments(MI
, OS
, MCII
))
1051 if (printFPCLASSComments(MI
, OS
, MCII
))
1054 switch (MI
->getOpcode()) {
1056 // Not an instruction for which we can decode comments.
1059 case X86::BLENDPDrri
:
1060 case X86::VBLENDPDrri
:
1061 case X86::VBLENDPDYrri
:
1062 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1064 case X86::BLENDPDrmi
:
1065 case X86::VBLENDPDrmi
:
1066 case X86::VBLENDPDYrmi
:
1067 if (MI
->getOperand(NumOperands
- 1).isImm())
1068 DecodeBLENDMask(getRegOperandNumElts(MI
, 64, 0),
1069 MI
->getOperand(NumOperands
- 1).getImm(),
1071 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1072 DestName
= getRegName(MI
->getOperand(0).getReg());
1075 case X86::BLENDPSrri
:
1076 case X86::VBLENDPSrri
:
1077 case X86::VBLENDPSYrri
:
1078 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1080 case X86::BLENDPSrmi
:
1081 case X86::VBLENDPSrmi
:
1082 case X86::VBLENDPSYrmi
:
1083 if (MI
->getOperand(NumOperands
- 1).isImm())
1084 DecodeBLENDMask(getRegOperandNumElts(MI
, 32, 0),
1085 MI
->getOperand(NumOperands
- 1).getImm(),
1087 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1088 DestName
= getRegName(MI
->getOperand(0).getReg());
1091 case X86::PBLENDWrri
:
1092 case X86::VPBLENDWrri
:
1093 case X86::VPBLENDWYrri
:
1094 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1096 case X86::PBLENDWrmi
:
1097 case X86::VPBLENDWrmi
:
1098 case X86::VPBLENDWYrmi
:
1099 if (MI
->getOperand(NumOperands
- 1).isImm())
1100 DecodeBLENDMask(getRegOperandNumElts(MI
, 16, 0),
1101 MI
->getOperand(NumOperands
- 1).getImm(),
1103 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1104 DestName
= getRegName(MI
->getOperand(0).getReg());
1107 case X86::VPBLENDDrri
:
1108 case X86::VPBLENDDYrri
:
1109 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1111 case X86::VPBLENDDrmi
:
1112 case X86::VPBLENDDYrmi
:
1113 if (MI
->getOperand(NumOperands
- 1).isImm())
1114 DecodeBLENDMask(getRegOperandNumElts(MI
, 32, 0),
1115 MI
->getOperand(NumOperands
- 1).getImm(),
1117 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1118 DestName
= getRegName(MI
->getOperand(0).getReg());
1121 case X86::INSERTPSrri
:
1122 case X86::VINSERTPSrri
:
1123 case X86::VINSERTPSZrri
:
1124 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1125 DestName
= getRegName(MI
->getOperand(0).getReg());
1126 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1127 if (MI
->getOperand(NumOperands
- 1).isImm())
1128 DecodeINSERTPSMask(MI
->getOperand(NumOperands
- 1).getImm(), ShuffleMask
,
1129 /*SrcIsMem=*/false);
1132 case X86::INSERTPSrmi
:
1133 case X86::VINSERTPSrmi
:
1134 case X86::VINSERTPSZrmi
:
1135 DestName
= getRegName(MI
->getOperand(0).getReg());
1136 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1137 if (MI
->getOperand(NumOperands
- 1).isImm())
1138 DecodeINSERTPSMask(MI
->getOperand(NumOperands
- 1).getImm(), ShuffleMask
,
1142 case X86::MOVLHPSrr
:
1143 case X86::VMOVLHPSrr
:
1144 case X86::VMOVLHPSZrr
:
1145 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1146 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1147 DestName
= getRegName(MI
->getOperand(0).getReg());
1148 DecodeMOVLHPSMask(2, ShuffleMask
);
1151 case X86::MOVHLPSrr
:
1152 case X86::VMOVHLPSrr
:
1153 case X86::VMOVHLPSZrr
:
1154 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1155 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1156 DestName
= getRegName(MI
->getOperand(0).getReg());
1157 DecodeMOVHLPSMask(2, ShuffleMask
);
1161 case X86::VMOVHPDrm
:
1162 case X86::VMOVHPDZ128rm
:
1163 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1164 DestName
= getRegName(MI
->getOperand(0).getReg());
1165 DecodeInsertElementMask(2, 1, 1, ShuffleMask
);
1169 case X86::VMOVHPSrm
:
1170 case X86::VMOVHPSZ128rm
:
1171 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1172 DestName
= getRegName(MI
->getOperand(0).getReg());
1173 DecodeInsertElementMask(4, 2, 2, ShuffleMask
);
1177 case X86::VMOVLPDrm
:
1178 case X86::VMOVLPDZ128rm
:
1179 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1180 DestName
= getRegName(MI
->getOperand(0).getReg());
1181 DecodeInsertElementMask(2, 0, 1, ShuffleMask
);
1185 case X86::VMOVLPSrm
:
1186 case X86::VMOVLPSZ128rm
:
1187 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1188 DestName
= getRegName(MI
->getOperand(0).getReg());
1189 DecodeInsertElementMask(4, 0, 2, ShuffleMask
);
1192 CASE_MOVDUP(MOVSLDUP
, r
)
1193 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1196 CASE_MOVDUP(MOVSLDUP
, m
)
1197 DestName
= getRegName(MI
->getOperand(0).getReg());
1198 DecodeMOVSLDUPMask(getRegOperandNumElts(MI
, 32, 0), ShuffleMask
);
1201 CASE_MOVDUP(MOVSHDUP
, r
)
1202 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1205 CASE_MOVDUP(MOVSHDUP
, m
)
1206 DestName
= getRegName(MI
->getOperand(0).getReg());
1207 DecodeMOVSHDUPMask(getRegOperandNumElts(MI
, 32, 0), ShuffleMask
);
1210 CASE_MOVDUP(MOVDDUP
, r
)
1211 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1214 CASE_MOVDUP(MOVDDUP
, m
)
1215 DestName
= getRegName(MI
->getOperand(0).getReg());
1216 DecodeMOVDDUPMask(getRegOperandNumElts(MI
, 64, 0), ShuffleMask
);
1220 case X86::VPSLLDQri
:
1221 case X86::VPSLLDQYri
:
1222 case X86::VPSLLDQZ128ri
:
1223 case X86::VPSLLDQZ256ri
:
1224 case X86::VPSLLDQZri
:
1225 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1227 case X86::VPSLLDQZ128mi
:
1228 case X86::VPSLLDQZ256mi
:
1229 case X86::VPSLLDQZmi
:
1230 DestName
= getRegName(MI
->getOperand(0).getReg());
1231 if (MI
->getOperand(NumOperands
- 1).isImm())
1232 DecodePSLLDQMask(getRegOperandNumElts(MI
, 8, 0),
1233 MI
->getOperand(NumOperands
- 1).getImm(),
1238 case X86::VPSRLDQri
:
1239 case X86::VPSRLDQYri
:
1240 case X86::VPSRLDQZ128ri
:
1241 case X86::VPSRLDQZ256ri
:
1242 case X86::VPSRLDQZri
:
1243 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1245 case X86::VPSRLDQZ128mi
:
1246 case X86::VPSRLDQZ256mi
:
1247 case X86::VPSRLDQZmi
:
1248 DestName
= getRegName(MI
->getOperand(0).getReg());
1249 if (MI
->getOperand(NumOperands
- 1).isImm())
1250 DecodePSRLDQMask(getRegOperandNumElts(MI
, 8, 0),
1251 MI
->getOperand(NumOperands
- 1).getImm(),
1255 CASE_SHUF(PALIGNR
, rri
)
1256 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1260 CASE_SHUF(PALIGNR
, rmi
)
1261 Src2Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1262 DestName
= getRegName(MI
->getOperand(0).getReg());
1263 if (MI
->getOperand(NumOperands
- 1).isImm())
1264 DecodePALIGNRMask(getRegOperandNumElts(MI
, 8, 0),
1265 MI
->getOperand(NumOperands
- 1).getImm(),
1269 CASE_AVX512_INS_COMMON(ALIGNQ
, Z
, rri
)
1270 CASE_AVX512_INS_COMMON(ALIGNQ
, Z256
, rri
)
1271 CASE_AVX512_INS_COMMON(ALIGNQ
, Z128
, rri
)
1272 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1276 CASE_AVX512_INS_COMMON(ALIGNQ
, Z
, rmi
)
1277 CASE_AVX512_INS_COMMON(ALIGNQ
, Z256
, rmi
)
1278 CASE_AVX512_INS_COMMON(ALIGNQ
, Z128
, rmi
)
1279 Src2Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1280 DestName
= getRegName(MI
->getOperand(0).getReg());
1281 if (MI
->getOperand(NumOperands
- 1).isImm())
1282 DecodeVALIGNMask(getRegOperandNumElts(MI
, 64, 0),
1283 MI
->getOperand(NumOperands
- 1).getImm(),
1287 CASE_AVX512_INS_COMMON(ALIGND
, Z
, rri
)
1288 CASE_AVX512_INS_COMMON(ALIGND
, Z256
, rri
)
1289 CASE_AVX512_INS_COMMON(ALIGND
, Z128
, rri
)
1290 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1294 CASE_AVX512_INS_COMMON(ALIGND
, Z
, rmi
)
1295 CASE_AVX512_INS_COMMON(ALIGND
, Z256
, rmi
)
1296 CASE_AVX512_INS_COMMON(ALIGND
, Z128
, rmi
)
1297 Src2Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1298 DestName
= getRegName(MI
->getOperand(0).getReg());
1299 if (MI
->getOperand(NumOperands
- 1).isImm())
1300 DecodeVALIGNMask(getRegOperandNumElts(MI
, 32, 0),
1301 MI
->getOperand(NumOperands
- 1).getImm(),
1305 CASE_SHUF(PSHUFD
, ri
)
1306 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1309 CASE_SHUF(PSHUFD
, mi
)
1310 DestName
= getRegName(MI
->getOperand(0).getReg());
1311 if (MI
->getOperand(NumOperands
- 1).isImm())
1312 DecodePSHUFMask(getRegOperandNumElts(MI
, 32, 0), 32,
1313 MI
->getOperand(NumOperands
- 1).getImm(),
1317 CASE_SHUF(PSHUFHW
, ri
)
1318 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1321 CASE_SHUF(PSHUFHW
, mi
)
1322 DestName
= getRegName(MI
->getOperand(0).getReg());
1323 if (MI
->getOperand(NumOperands
- 1).isImm())
1324 DecodePSHUFHWMask(getRegOperandNumElts(MI
, 16, 0),
1325 MI
->getOperand(NumOperands
- 1).getImm(),
1329 CASE_SHUF(PSHUFLW
, ri
)
1330 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1333 CASE_SHUF(PSHUFLW
, mi
)
1334 DestName
= getRegName(MI
->getOperand(0).getReg());
1335 if (MI
->getOperand(NumOperands
- 1).isImm())
1336 DecodePSHUFLWMask(getRegOperandNumElts(MI
, 16, 0),
1337 MI
->getOperand(NumOperands
- 1).getImm(),
1341 case X86::MMX_PSHUFWri
:
1342 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1345 case X86::MMX_PSHUFWmi
:
1346 DestName
= getRegName(MI
->getOperand(0).getReg());
1347 if (MI
->getOperand(NumOperands
- 1).isImm())
1348 DecodePSHUFMask(4, 16, MI
->getOperand(NumOperands
- 1).getImm(),
1353 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1357 DestName
= getRegName(MI
->getOperand(0).getReg());
1358 DecodePSWAPMask(2, ShuffleMask
);
1361 CASE_UNPCK(PUNPCKHBW
, r
)
1362 case X86::MMX_PUNPCKHBWrr
:
1363 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1367 CASE_UNPCK(PUNPCKHBW
, m
)
1368 case X86::MMX_PUNPCKHBWrm
:
1369 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1370 DestName
= getRegName(MI
->getOperand(0).getReg());
1371 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 8, 0), 8, ShuffleMask
);
1374 CASE_UNPCK(PUNPCKHWD
, r
)
1375 case X86::MMX_PUNPCKHWDrr
:
1376 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1380 CASE_UNPCK(PUNPCKHWD
, m
)
1381 case X86::MMX_PUNPCKHWDrm
:
1382 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1383 DestName
= getRegName(MI
->getOperand(0).getReg());
1384 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 16, 0), 16, ShuffleMask
);
1387 CASE_UNPCK(PUNPCKHDQ
, r
)
1388 case X86::MMX_PUNPCKHDQrr
:
1389 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1393 CASE_UNPCK(PUNPCKHDQ
, m
)
1394 case X86::MMX_PUNPCKHDQrm
:
1395 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1396 DestName
= getRegName(MI
->getOperand(0).getReg());
1397 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 32, 0), 32, ShuffleMask
);
1400 CASE_UNPCK(PUNPCKHQDQ
, r
)
1401 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1405 CASE_UNPCK(PUNPCKHQDQ
, m
)
1406 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1407 DestName
= getRegName(MI
->getOperand(0).getReg());
1408 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 64, 0), 64, ShuffleMask
);
1411 CASE_UNPCK(PUNPCKLBW
, r
)
1412 case X86::MMX_PUNPCKLBWrr
:
1413 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1417 CASE_UNPCK(PUNPCKLBW
, m
)
1418 case X86::MMX_PUNPCKLBWrm
:
1419 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1420 DestName
= getRegName(MI
->getOperand(0).getReg());
1421 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 8, 0), 8, ShuffleMask
);
1424 CASE_UNPCK(PUNPCKLWD
, r
)
1425 case X86::MMX_PUNPCKLWDrr
:
1426 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1430 CASE_UNPCK(PUNPCKLWD
, m
)
1431 case X86::MMX_PUNPCKLWDrm
:
1432 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1433 DestName
= getRegName(MI
->getOperand(0).getReg());
1434 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 16, 0), 16, ShuffleMask
);
1437 CASE_UNPCK(PUNPCKLDQ
, r
)
1438 case X86::MMX_PUNPCKLDQrr
:
1439 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1443 CASE_UNPCK(PUNPCKLDQ
, m
)
1444 case X86::MMX_PUNPCKLDQrm
:
1445 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1446 DestName
= getRegName(MI
->getOperand(0).getReg());
1447 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 32, 0), 32, ShuffleMask
);
1450 CASE_UNPCK(PUNPCKLQDQ
, r
)
1451 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1455 CASE_UNPCK(PUNPCKLQDQ
, m
)
1456 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1457 DestName
= getRegName(MI
->getOperand(0).getReg());
1458 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 64, 0), 64, ShuffleMask
);
1461 CASE_SHUF(SHUFPD
, rri
)
1462 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1466 CASE_SHUF(SHUFPD
, rmi
)
1467 if (MI
->getOperand(NumOperands
- 1).isImm())
1468 DecodeSHUFPMask(getRegOperandNumElts(MI
, 64, 0), 64,
1469 MI
->getOperand(NumOperands
- 1).getImm(), ShuffleMask
);
1470 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1471 DestName
= getRegName(MI
->getOperand(0).getReg());
1474 CASE_SHUF(SHUFPS
, rri
)
1475 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1479 CASE_SHUF(SHUFPS
, rmi
)
1480 if (MI
->getOperand(NumOperands
- 1).isImm())
1481 DecodeSHUFPMask(getRegOperandNumElts(MI
, 32, 0), 32,
1482 MI
->getOperand(NumOperands
- 1).getImm(),
1484 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1485 DestName
= getRegName(MI
->getOperand(0).getReg());
1489 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1494 decodeVSHUF64x2FamilyMask(getRegOperandNumElts(MI
, 64, 0), 64,
1495 MI
->getOperand(NumOperands
- 1).getImm(),
1497 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1498 DestName
= getRegName(MI
->getOperand(0).getReg());
1502 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1507 decodeVSHUF64x2FamilyMask(getRegOperandNumElts(MI
, 32, 0), 32,
1508 MI
->getOperand(NumOperands
- 1).getImm(),
1510 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?3:7)).getReg());
1511 DestName
= getRegName(MI
->getOperand(0).getReg());
1514 CASE_UNPCK(UNPCKLPD
, r
)
1515 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1519 CASE_UNPCK(UNPCKLPD
, m
)
1520 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 64, 0), 64, ShuffleMask
);
1521 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1522 DestName
= getRegName(MI
->getOperand(0).getReg());
1525 CASE_UNPCK(UNPCKLPS
, r
)
1526 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1530 CASE_UNPCK(UNPCKLPS
, m
)
1531 DecodeUNPCKLMask(getRegOperandNumElts(MI
, 32, 0), 32, ShuffleMask
);
1532 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1533 DestName
= getRegName(MI
->getOperand(0).getReg());
1536 CASE_UNPCK(UNPCKHPD
, r
)
1537 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1541 CASE_UNPCK(UNPCKHPD
, m
)
1542 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 64, 0), 64, ShuffleMask
);
1543 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1544 DestName
= getRegName(MI
->getOperand(0).getReg());
1547 CASE_UNPCK(UNPCKHPS
, r
)
1548 Src2Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1552 CASE_UNPCK(UNPCKHPS
, m
)
1553 DecodeUNPCKHMask(getRegOperandNumElts(MI
, 32, 0), 32, ShuffleMask
);
1554 Src1Name
= getRegName(MI
->getOperand(NumOperands
-(RegForm
?2:6)).getReg());
1555 DestName
= getRegName(MI
->getOperand(0).getReg());
1558 CASE_VPERMILPI(PERMILPS
, r
)
1559 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1562 CASE_VPERMILPI(PERMILPS
, m
)
1563 if (MI
->getOperand(NumOperands
- 1).isImm())
1564 DecodePSHUFMask(getRegOperandNumElts(MI
, 32, 0), 32,
1565 MI
->getOperand(NumOperands
- 1).getImm(),
1567 DestName
= getRegName(MI
->getOperand(0).getReg());
1570 CASE_VPERMILPI(PERMILPD
, r
)
1571 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1574 CASE_VPERMILPI(PERMILPD
, m
)
1575 if (MI
->getOperand(NumOperands
- 1).isImm())
1576 DecodePSHUFMask(getRegOperandNumElts(MI
, 64, 0), 64,
1577 MI
->getOperand(NumOperands
- 1).getImm(),
1579 DestName
= getRegName(MI
->getOperand(0).getReg());
1582 case X86::VPERM2F128rri
:
1583 case X86::VPERM2I128rri
:
1584 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1587 case X86::VPERM2F128rmi
:
1588 case X86::VPERM2I128rmi
:
1589 // For instruction comments purpose, assume the 256-bit vector is v4i64.
1590 if (MI
->getOperand(NumOperands
- 1).isImm())
1591 DecodeVPERM2X128Mask(4, MI
->getOperand(NumOperands
- 1).getImm(),
1593 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1594 DestName
= getRegName(MI
->getOperand(0).getReg());
1597 CASE_VPERM(PERMPD
, r
)
1598 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1601 CASE_VPERM(PERMPD
, m
)
1602 if (MI
->getOperand(NumOperands
- 1).isImm())
1603 DecodeVPERMMask(getRegOperandNumElts(MI
, 64, 0),
1604 MI
->getOperand(NumOperands
- 1).getImm(),
1606 DestName
= getRegName(MI
->getOperand(0).getReg());
1609 CASE_VPERM(PERMQ
, r
)
1610 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 2).getReg());
1613 CASE_VPERM(PERMQ
, m
)
1614 if (MI
->getOperand(NumOperands
- 1).isImm())
1615 DecodeVPERMMask(getRegOperandNumElts(MI
, 64, 0),
1616 MI
->getOperand(NumOperands
- 1).getImm(),
1618 DestName
= getRegName(MI
->getOperand(0).getReg());
1623 case X86::VMOVSDZrr
:
1624 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1625 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1626 DecodeScalarMoveMask(2, false, ShuffleMask
);
1627 DestName
= getRegName(MI
->getOperand(0).getReg());
1632 case X86::VMOVSSZrr
:
1633 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1634 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1635 DecodeScalarMoveMask(4, false, ShuffleMask
);
1636 DestName
= getRegName(MI
->getOperand(0).getReg());
1639 case X86::MOVPQI2QIrr
:
1640 case X86::MOVZPQILo2PQIrr
:
1641 case X86::VMOVPQI2QIrr
:
1642 case X86::VMOVPQI2QIZrr
:
1643 case X86::VMOVZPQILo2PQIrr
:
1644 case X86::VMOVZPQILo2PQIZrr
:
1645 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1646 DecodeZeroMoveLowMask(2, ShuffleMask
);
1647 DestName
= getRegName(MI
->getOperand(0).getReg());
1651 if (MI
->getOperand(2).isImm() &&
1652 MI
->getOperand(3).isImm())
1653 DecodeEXTRQIMask(16, 8, MI
->getOperand(2).getImm(),
1654 MI
->getOperand(3).getImm(), ShuffleMask
);
1656 DestName
= getRegName(MI
->getOperand(0).getReg());
1657 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1661 if (MI
->getOperand(3).isImm() &&
1662 MI
->getOperand(4).isImm())
1663 DecodeINSERTQIMask(16, 8, MI
->getOperand(3).getImm(),
1664 MI
->getOperand(4).getImm(), ShuffleMask
);
1666 DestName
= getRegName(MI
->getOperand(0).getReg());
1667 Src1Name
= getRegName(MI
->getOperand(1).getReg());
1668 Src2Name
= getRegName(MI
->getOperand(2).getReg());
1671 case X86::VBROADCASTF128rm
:
1672 case X86::VBROADCASTI128rm
:
1673 CASE_AVX512_INS_COMMON(BROADCASTF64X2
, Z256
, rm
)
1674 CASE_AVX512_INS_COMMON(BROADCASTI64X2
, Z256
, rm
)
1675 DecodeSubVectorBroadcast(4, 2, ShuffleMask
);
1676 DestName
= getRegName(MI
->getOperand(0).getReg());
1678 CASE_AVX512_INS_COMMON(BROADCASTF64X2
, Z
, rm
)
1679 CASE_AVX512_INS_COMMON(BROADCASTI64X2
, Z
, rm
)
1680 DecodeSubVectorBroadcast(8, 2, ShuffleMask
);
1681 DestName
= getRegName(MI
->getOperand(0).getReg());
1683 CASE_AVX512_INS_COMMON(BROADCASTF64X4
, Z
, rm
)
1684 CASE_AVX512_INS_COMMON(BROADCASTI64X4
, Z
, rm
)
1685 DecodeSubVectorBroadcast(8, 4, ShuffleMask
);
1686 DestName
= getRegName(MI
->getOperand(0).getReg());
1688 CASE_AVX512_INS_COMMON(BROADCASTF32X4
, Z256
, rm
)
1689 CASE_AVX512_INS_COMMON(BROADCASTI32X4
, Z256
, rm
)
1690 DecodeSubVectorBroadcast(8, 4, ShuffleMask
);
1691 DestName
= getRegName(MI
->getOperand(0).getReg());
1693 CASE_AVX512_INS_COMMON(BROADCASTF32X4
, Z
, rm
)
1694 CASE_AVX512_INS_COMMON(BROADCASTI32X4
, Z
, rm
)
1695 DecodeSubVectorBroadcast(16, 4, ShuffleMask
);
1696 DestName
= getRegName(MI
->getOperand(0).getReg());
1698 CASE_AVX512_INS_COMMON(BROADCASTF32X8
, Z
, rm
)
1699 CASE_AVX512_INS_COMMON(BROADCASTI32X8
, Z
, rm
)
1700 DecodeSubVectorBroadcast(16, 8, ShuffleMask
);
1701 DestName
= getRegName(MI
->getOperand(0).getReg());
1703 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z128
, rr
)
1704 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1706 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z128
, rm
)
1707 DecodeSubVectorBroadcast(4, 2, ShuffleMask
);
1708 DestName
= getRegName(MI
->getOperand(0).getReg());
1710 CASE_AVX512_INS_COMMON(BROADCASTF32X2
, Z256
, rr
)
1711 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z256
, rr
)
1712 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1714 CASE_AVX512_INS_COMMON(BROADCASTF32X2
, Z256
, rm
)
1715 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z256
, rm
)
1716 DecodeSubVectorBroadcast(8, 2, ShuffleMask
);
1717 DestName
= getRegName(MI
->getOperand(0).getReg());
1719 CASE_AVX512_INS_COMMON(BROADCASTF32X2
, Z
, rr
)
1720 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z
, rr
)
1721 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1723 CASE_AVX512_INS_COMMON(BROADCASTF32X2
, Z
, rm
)
1724 CASE_AVX512_INS_COMMON(BROADCASTI32X2
, Z
, rm
)
1725 DecodeSubVectorBroadcast(16, 2, ShuffleMask
);
1726 DestName
= getRegName(MI
->getOperand(0).getReg());
1729 CASE_PMOVZX(PMOVZXBW
, r
)
1730 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1731 DecodeZeroExtendMask(8, 16, getRegOperandNumElts(MI
, 16, 0), false,
1733 DestName
= getRegName(MI
->getOperand(0).getReg());
1736 CASE_PMOVZX(PMOVZXBD
, r
)
1737 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1738 DecodeZeroExtendMask(8, 32, getRegOperandNumElts(MI
, 32, 0), false,
1740 DestName
= getRegName(MI
->getOperand(0).getReg());
1743 CASE_PMOVZX(PMOVZXBQ
, r
)
1744 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1745 DecodeZeroExtendMask(8, 64, getRegOperandNumElts(MI
, 64, 0), false,
1747 DestName
= getRegName(MI
->getOperand(0).getReg());
1750 CASE_PMOVZX(PMOVZXWD
, r
)
1751 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1752 DecodeZeroExtendMask(16, 32, getRegOperandNumElts(MI
, 32, 0), false,
1754 DestName
= getRegName(MI
->getOperand(0).getReg());
1757 CASE_PMOVZX(PMOVZXWQ
, r
)
1758 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1759 DecodeZeroExtendMask(16, 64, getRegOperandNumElts(MI
, 64, 0), false,
1761 DestName
= getRegName(MI
->getOperand(0).getReg());
1764 CASE_PMOVZX(PMOVZXDQ
, r
)
1765 Src1Name
= getRegName(MI
->getOperand(NumOperands
- 1).getReg());
1766 DecodeZeroExtendMask(32, 64, getRegOperandNumElts(MI
, 64, 0), false,
1768 DestName
= getRegName(MI
->getOperand(0).getReg());
1772 // The only comments we decode are shuffles, so give up if we were unable to
1773 // decode a shuffle mask.
1774 if (ShuffleMask
.empty())
1777 if (!DestName
) DestName
= Src1Name
;
1780 printMasking(OS
, MI
, MCII
);
1786 // If the two sources are the same, canonicalize the input elements to be
1787 // from the first src so that we get larger element spans.
1788 if (Src1Name
== Src2Name
) {
1789 for (unsigned i
= 0, e
= ShuffleMask
.size(); i
!= e
; ++i
) {
1790 if ((int)ShuffleMask
[i
] >= 0 && // Not sentinel.
1791 ShuffleMask
[i
] >= (int)e
) // From second mask.
1792 ShuffleMask
[i
] -= e
;
1796 // The shuffle mask specifies which elements of the src1/src2 fill in the
1797 // destination, with a few sentinel values. Loop through and print them
1799 for (unsigned i
= 0, e
= ShuffleMask
.size(); i
!= e
; ++i
) {
1802 if (ShuffleMask
[i
] == SM_SentinelZero
) {
1807 // Otherwise, it must come from src1 or src2. Print the span of elements
1808 // that comes from this src.
1809 bool isSrc1
= ShuffleMask
[i
] < (int)ShuffleMask
.size();
1810 const char *SrcName
= isSrc1
? Src1Name
: Src2Name
;
1811 OS
<< (SrcName
? SrcName
: "mem") << '[';
1812 bool IsFirst
= true;
1813 while (i
!= e
&& (int)ShuffleMask
[i
] != SM_SentinelZero
&&
1814 (ShuffleMask
[i
] < (int)ShuffleMask
.size()) == isSrc1
) {
1819 if (ShuffleMask
[i
] == SM_SentinelUndef
)
1822 OS
<< ShuffleMask
[i
] % ShuffleMask
.size();
1826 --i
; // For loop increments element #.
1830 // We successfully added a comment to this instruction.