LLVM 20.0.0git
X86BaseInfo.h
Go to the documentation of this file.
1//===-- X86BaseInfo.h - Top level definitions for X86 -------- --*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains small standalone helper functions and enum definitions for
10// the X86 target useful for the compiler back-end and the MC libraries.
11// As such, it deliberately does not include references to LLVM core
12// code gen types, passes, etc..
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86BASEINFO_H
17#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86BASEINFO_H
18
19#include "X86MCTargetDesc.h"
20#include "llvm/MC/MCInstrDesc.h"
23
24namespace llvm {
25namespace X86 {
26// Enums for memory operand decoding. Each memory operand is represented with
27// a 5 operand sequence in the form: [Base, Scale, Index, Disp, Segment]
28enum {
33 // The operand # of the segment in the memory operand.
35 // Total number of operands in a memory reference.
37};
38
39/// AVX512 static rounding constants. These need to match the values in
40/// avx512fintrin.h.
47 NO_EXC = 8
48};
49
50/// The constants to describe instr prefixes if there are
53 IP_HAS_OP_SIZE = 1U << 0,
54 IP_HAS_AD_SIZE = 1U << 1,
56 IP_HAS_REPEAT = 1U << 3,
57 IP_HAS_LOCK = 1U << 4,
58 IP_HAS_NOTRACK = 1U << 5,
59 IP_USE_REX = 1U << 6,
60 IP_USE_REX2 = 1U << 7,
61 IP_USE_VEX = 1U << 8,
62 IP_USE_VEX2 = 1U << 9,
63 IP_USE_VEX3 = 1U << 10,
64 IP_USE_EVEX = 1U << 11,
65 IP_USE_DISP8 = 1U << 12,
66 IP_USE_DISP32 = 1U << 13,
67};
68
69enum OperandType : unsigned {
70 // AVX512 embedded rounding control. This should only have values 0-3.
73};
74
75// X86 specific condition code. These correspond to X86_*_COND in
76// X86InstrInfo.td. They must be kept in synch.
78 COND_O = 0,
80 COND_B = 2,
82 COND_E = 4,
85 COND_A = 7,
86 COND_S = 8,
88 COND_P = 10,
89 COND_NP = 11,
90 COND_L = 12,
91 COND_GE = 13,
92 COND_LE = 14,
93 COND_G = 15,
95 // Artificial condition codes. These are used by analyzeBranch
96 // to indicate a block terminated with two conditional branches that together
97 // form a compound condition. They occur in code using FCMP_OEQ or FCMP_UNE,
98 // which can't be represented on x86 with a single condition. These
99 // are never used in MachineInstrs and are inverses of one another.
104
105// The classification for the first instruction in macro fusion.
106// FIXME: Zen 3 support branch fusion for OR/XOR.
108 Test, // TEST
109 Cmp, // CMP
110 And, // AND
111 AddSub, // ADD, SUB
112 IncDec, // INC, DEC
113 Invalid // Not valid as a first macro fusion instruction
114};
115
117 AB, // JA, JB and variants
118 ELG, // JE, JL, JG and variants
119 SPO, // JS, JP, JO and variants
120 Invalid, // Not a fusible jump.
121};
122
123/// \returns the type of the first instruction in macro-fusion.
124// FIXME: Zen 3 support branch fusion for OR/XOR.
127 switch (Opcode) {
128 default:
130 // TEST
131 case X86::TEST16i16:
132 case X86::TEST16mr:
133 case X86::TEST16ri:
134 case X86::TEST16rr:
135 case X86::TEST32i32:
136 case X86::TEST32mr:
137 case X86::TEST32ri:
138 case X86::TEST32rr:
139 case X86::TEST64i32:
140 case X86::TEST64mr:
141 case X86::TEST64ri32:
142 case X86::TEST64rr:
143 case X86::TEST8i8:
144 case X86::TEST8mr:
145 case X86::TEST8ri:
146 case X86::TEST8rr:
148 case X86::AND16i16:
149 case X86::AND16ri:
150 case X86::AND16ri8:
151 case X86::AND16rm:
152 case X86::AND16rr:
153 case X86::AND32i32:
154 case X86::AND32ri:
155 case X86::AND32ri8:
156 case X86::AND32rm:
157 case X86::AND32rr:
158 case X86::AND64i32:
159 case X86::AND64ri32:
160 case X86::AND64ri8:
161 case X86::AND64rm:
162 case X86::AND64rr:
163 case X86::AND8i8:
164 case X86::AND8ri:
165 case X86::AND8ri8:
166 case X86::AND8rm:
167 case X86::AND8rr:
169 // CMP
170 case X86::CMP16i16:
171 case X86::CMP16mr:
172 case X86::CMP16ri:
173 case X86::CMP16ri8:
174 case X86::CMP16rm:
175 case X86::CMP16rr:
176 case X86::CMP32i32:
177 case X86::CMP32mr:
178 case X86::CMP32ri:
179 case X86::CMP32ri8:
180 case X86::CMP32rm:
181 case X86::CMP32rr:
182 case X86::CMP64i32:
183 case X86::CMP64mr:
184 case X86::CMP64ri32:
185 case X86::CMP64ri8:
186 case X86::CMP64rm:
187 case X86::CMP64rr:
188 case X86::CMP8i8:
189 case X86::CMP8mr:
190 case X86::CMP8ri:
191 case X86::CMP8ri8:
192 case X86::CMP8rm:
193 case X86::CMP8rr:
195 // ADD
196 case X86::ADD16i16:
197 case X86::ADD16ri:
198 case X86::ADD16ri8:
199 case X86::ADD16rm:
200 case X86::ADD16rr:
201 case X86::ADD32i32:
202 case X86::ADD32ri:
203 case X86::ADD32ri8:
204 case X86::ADD32rm:
205 case X86::ADD32rr:
206 case X86::ADD64i32:
207 case X86::ADD64ri32:
208 case X86::ADD64ri8:
209 case X86::ADD64rm:
210 case X86::ADD64rr:
211 case X86::ADD8i8:
212 case X86::ADD8ri:
213 case X86::ADD8ri8:
214 case X86::ADD8rm:
215 case X86::ADD8rr:
216 // SUB
217 case X86::SUB16i16:
218 case X86::SUB16ri:
219 case X86::SUB16ri8:
220 case X86::SUB16rm:
221 case X86::SUB16rr:
222 case X86::SUB32i32:
223 case X86::SUB32ri:
224 case X86::SUB32ri8:
225 case X86::SUB32rm:
226 case X86::SUB32rr:
227 case X86::SUB64i32:
228 case X86::SUB64ri32:
229 case X86::SUB64ri8:
230 case X86::SUB64rm:
231 case X86::SUB64rr:
232 case X86::SUB8i8:
233 case X86::SUB8ri:
234 case X86::SUB8ri8:
235 case X86::SUB8rm:
236 case X86::SUB8rr:
238 // INC
239 case X86::INC16r:
240 case X86::INC16r_alt:
241 case X86::INC32r:
242 case X86::INC32r_alt:
243 case X86::INC64r:
244 case X86::INC8r:
245 // DEC
246 case X86::DEC16r:
247 case X86::DEC16r_alt:
248 case X86::DEC32r:
249 case X86::DEC32r_alt:
250 case X86::DEC64r:
251 case X86::DEC8r:
253 }
254}
255
256/// \returns the type of the second instruction in macro-fusion.
259 if (CC == X86::COND_INVALID)
261 switch (CC) {
262 default:
264 case X86::COND_E: // JE,JZ
265 case X86::COND_NE: // JNE,JNZ
266 case X86::COND_L: // JL,JNGE
267 case X86::COND_LE: // JLE,JNG
268 case X86::COND_G: // JG,JNLE
269 case X86::COND_GE: // JGE,JNL
271 case X86::COND_B: // JB,JC
272 case X86::COND_BE: // JNA,JBE
273 case X86::COND_A: // JA,JNBE
274 case X86::COND_AE: // JAE,JNC,JNB
276 case X86::COND_S: // JS
277 case X86::COND_NS: // JNS
278 case X86::COND_P: // JP,JPE
279 case X86::COND_NP: // JNP,JPO
280 case X86::COND_O: // JO
281 case X86::COND_NO: // JNO
283 }
284}
285
286/// \param FirstKind kind of the first instruction in macro fusion.
287/// \param SecondKind kind of the second instruction in macro fusion.
288///
289/// \returns true if the two instruction can be macro fused.
291 SecondMacroFusionInstKind SecondKind) {
292 switch (FirstKind) {
295 return true;
298 return SecondKind == X86::SecondMacroFusionInstKind::AB ||
301 return SecondKind == X86::SecondMacroFusionInstKind::ELG;
303 return false;
304 }
305 llvm_unreachable("unknown fusion type");
306}
307
308/// Defines the possible values of the branch boundary alignment mask.
312 AlignBranchJcc = 1U << 1,
313 AlignBranchJmp = 1U << 2,
315 AlignBranchRet = 1U << 4,
316 AlignBranchIndirect = 1U << 5
318
319/// Defines the encoding values for segment override prefix.
326 SS_Encoding = 0x36
328
329/// Given a segment register, return the encoding of the segment override
330/// prefix for it.
333 switch (Reg) {
334 default:
335 llvm_unreachable("Unknown segment register!");
336 case X86::CS:
337 return CS_Encoding;
338 case X86::DS:
339 return DS_Encoding;
340 case X86::ES:
341 return ES_Encoding;
342 case X86::FS:
343 return FS_Encoding;
344 case X86::GS:
345 return GS_Encoding;
346 case X86::SS:
347 return SS_Encoding;
348 }
349}
350
351} // namespace X86
352
353/// X86II - This namespace holds all of the target specific flags that
354/// instruction info tracks.
355///
356namespace X86II {
357/// Target Operand Flag enum.
358enum TOF {
359 //===------------------------------------------------------------------===//
360 // X86 Specific MachineOperand flags.
361 //
362 /// MO_NO_FLAG - No flag for the operand
364 /// MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a
365 /// relocation of:
366 /// SYMBOL_LABEL + [. - PICBASELABEL]
368 /// MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the
369 /// immediate should get the value of the symbol minus the PIC base label:
370 /// SYMBOL_LABEL - PICBASELABEL
372 /// MO_GOT - On a symbol operand this indicates that the immediate is the
373 /// offset to the GOT entry for the symbol name from the base of the GOT.
374 /// See the X86-64 ELF ABI supplement for more details.
375 /// SYMBOL_LABEL @GOT
377 /// MO_GOTOFF - On a symbol operand this indicates that the immediate is
378 /// the offset to the location of the symbol name from the base of the GOT.
379 /// See the X86-64 ELF ABI supplement for more details.
380 /// SYMBOL_LABEL @GOTOFF
382 /// MO_GOTPCREL - On a symbol operand this indicates that the immediate is
383 /// offset to the GOT entry for the symbol name from the current code
384 /// location.
385 /// See the X86-64 ELF ABI supplement for more details.
386 /// SYMBOL_LABEL @GOTPCREL
388 /// MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL
389 /// relocations are guaranteed to be emitted by the integrated assembler
390 /// instead of the relaxable R_X86_64[_REX]_GOTPCRELX relocations.
392 /// MO_PLT - On a symbol operand this indicates that the immediate is
393 /// offset to the PLT entry of symbol name from the current code location.
394 /// See the X86-64 ELF ABI supplement for more details.
395 /// SYMBOL_LABEL @PLT
397 /// MO_TLSGD - On a symbol operand this indicates that the immediate is
398 /// the offset of the GOT entry with the TLS index structure that contains
399 /// the module number and variable offset for the symbol. Used in the
400 /// general dynamic TLS access model.
401 /// See 'ELF Handling for Thread-Local Storage' for more details.
402 /// SYMBOL_LABEL @TLSGD
404 /// MO_TLSLD - On a symbol operand this indicates that the immediate is
405 /// the offset of the GOT entry with the TLS index for the module that
406 /// contains the symbol. When this index is passed to a call to
407 /// __tls_get_addr, the function will return the base address of the TLS
408 /// block for the symbol. Used in the x86-64 local dynamic TLS access model.
409 /// See 'ELF Handling for Thread-Local Storage' for more details.
410 /// SYMBOL_LABEL @TLSLD
412 /// MO_TLSLDM - On a symbol operand this indicates that the immediate is
413 /// the offset of the GOT entry with the TLS index for the module that
414 /// contains the symbol. When this index is passed to a call to
415 /// ___tls_get_addr, the function will return the base address of the TLS
416 /// block for the symbol. Used in the IA32 local dynamic TLS access model.
417 /// See 'ELF Handling for Thread-Local Storage' for more details.
418 /// SYMBOL_LABEL @TLSLDM
420 /// MO_GOTTPOFF - On a symbol operand this indicates that the immediate is
421 /// the offset of the GOT entry with the thread-pointer offset for the
422 /// symbol. Used in the x86-64 initial exec TLS access model.
423 /// See 'ELF Handling for Thread-Local Storage' for more details.
424 /// SYMBOL_LABEL @GOTTPOFF
426 /// MO_INDNTPOFF - On a symbol operand this indicates that the immediate is
427 /// the absolute address of the GOT entry with the negative thread-pointer
428 /// offset for the symbol. Used in the non-PIC IA32 initial exec TLS access
429 /// model.
430 /// See 'ELF Handling for Thread-Local Storage' for more details.
431 /// SYMBOL_LABEL @INDNTPOFF
433 /// MO_TPOFF - On a symbol operand this indicates that the immediate is
434 /// the thread-pointer offset for the symbol. Used in the x86-64 local
435 /// exec TLS access model.
436 /// See 'ELF Handling for Thread-Local Storage' for more details.
437 /// SYMBOL_LABEL @TPOFF
439 /// MO_DTPOFF - On a symbol operand this indicates that the immediate is
440 /// the offset of the GOT entry with the TLS offset of the symbol. Used
441 /// in the local dynamic TLS access model.
442 /// See 'ELF Handling for Thread-Local Storage' for more details.
443 /// SYMBOL_LABEL @DTPOFF
445 /// MO_NTPOFF - On a symbol operand this indicates that the immediate is
446 /// the negative thread-pointer offset for the symbol. Used in the IA32
447 /// local exec TLS access model.
448 /// See 'ELF Handling for Thread-Local Storage' for more details.
449 /// SYMBOL_LABEL @NTPOFF
451 /// MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is
452 /// the offset of the GOT entry with the negative thread-pointer offset for
453 /// the symbol. Used in the PIC IA32 initial exec TLS access model.
454 /// See 'ELF Handling for Thread-Local Storage' for more details.
455 /// SYMBOL_LABEL @GOTNTPOFF
457 /// MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the
458 /// reference is actually to the "__imp_FOO" symbol. This is used for
459 /// dllimport linkage on windows.
461 /// MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the
462 /// reference is actually to the "FOO$non_lazy_ptr" symbol, which is a
463 /// non-PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
465 /// MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates
466 /// that the reference is actually to "FOO$non_lazy_ptr - PICBASE", which is
467 /// a PIC-base-relative reference to a non-hidden dyld lazy pointer stub.
469 /// MO_TLVP - On a symbol operand this indicates that the immediate is
470 /// some TLS offset.
471 /// This is the TLS offset for the Darwin TLS mechanism.
473 /// MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate
474 /// is some TLS offset from the picbase.
475 /// This is the 32-bit TLS offset for Darwin TLS in PIC mode.
477 /// MO_SECREL - On a symbol operand this indicates that the immediate is
478 /// the offset from beginning of section.
479 /// This is the TLS offset for the COFF/Windows TLS mechanism.
481 /// MO_ABS8 - On a symbol operand this indicates that the symbol is known
482 /// to be an absolute symbol in range [0,128), so we can use the @ABS8
483 /// symbol modifier.
485 /// MO_COFFSTUB - On a symbol operand "FOO", this indicates that the
486 /// reference is actually to the ".refptr.FOO" symbol. This is used for
487 /// stub symbols on windows.
489};
490
491enum : uint64_t {
492 //===------------------------------------------------------------------===//
493 // Instruction encodings. These are the standard/most common forms for X86
494 // instructions.
495 //
496 /// PseudoFrm - This represents an instruction that is a pseudo instruction
497 /// or one that has not been implemented yet. It is illegal to code generate
498 /// it, but tolerated for intermediate implementation stages.
500 /// Raw - This form is for instructions that don't have any operands, so
501 /// they are just a fixed opcode value, like 'leave'.
503 /// AddRegFrm - This form is used for instructions like 'push r32' that have
504 /// their one register operand added to their opcode.
506 /// RawFrmMemOffs - This form is for instructions that store an absolute
507 /// memory offset as an immediate with a possible segment override.
509 /// RawFrmSrc - This form is for instructions that use the source index
510 /// register SI/ESI/RSI with a possible segment override.
512 /// RawFrmDst - This form is for instructions that use the destination index
513 /// register DI/EDI/RDI.
515 /// RawFrmDstSrc - This form is for instructions that use the source index
516 /// register SI/ESI/RSI with a possible segment override, and also the
517 /// destination index register DI/EDI/RDI.
519 /// RawFrmImm8 - This is used for the ENTER instruction, which has two
520 /// immediates, the first of which is a 16-bit immediate (specified by
521 /// the imm encoding) and the second is a 8-bit fixed value.
523 /// RawFrmImm16 - This is used for CALL FAR instructions, which have two
524 /// immediates, the first of which is a 16 or 32-bit immediate (specified by
525 /// the imm encoding) and the second is a 16-bit fixed value. In the AMD
526 /// manual, this operand is described as pntr16:32 and pntr16:16
528 /// AddCCFrm - This form is used for Jcc that encode the condition code
529 /// in the lower 4 bits of the opcode.
531 /// PrefixByte - This form is used for instructions that represent a prefix
532 /// byte like data16 or rep.
534 /// MRMDestRegCC - This form is used for the cfcmov instructions, which use
535 /// the Mod/RM byte to specify the operands reg(r/m) and reg(reg) and also
536 /// encodes a condition code.
538 /// MRMDestMemCC - This form is used for the cfcmov instructions, which use
539 /// the Mod/RM byte to specify the operands mem(r/m) and reg(reg) and also
540 /// encodes a condition code.
542 /// MRMDestMem4VOp3CC - This form is used for instructions that use the Mod/RM
543 /// byte to specify a destination which in this case is memory and operand 3
544 /// with VEX.VVVV, and also encodes a condition code.
546 /// Instructions operate on a register Reg/Opcode operand not the r/m field.
547 MRMr0 = 21,
548 /// MRMSrcMem - But force to use the SIB field.
550 /// MRMDestMem - But force to use the SIB field.
552 /// MRMDestMem - This form is used for instructions that use the Mod/RM byte
553 /// to specify a destination, which in this case is memory.
555 /// MRMSrcMem - This form is used for instructions that use the Mod/RM byte
556 /// to specify a source, which in this case is memory.
558 /// MRMSrcMem4VOp3 - This form is used for instructions that encode
559 /// operand 3 with VEX.VVVV and load from memory.
561 /// MRMSrcMemOp4 - This form is used for instructions that use the Mod/RM
562 /// byte to specify the fourth source, which in this case is memory.
564 /// MRMSrcMemCC - This form is used for instructions that use the Mod/RM
565 /// byte to specify the operands and also encodes a condition code.
567 /// MRMXm - This form is used for instructions that use the Mod/RM byte
568 /// to specify a memory source, but doesn't use the middle field. And has
569 /// a condition code.
571 /// MRMXm - This form is used for instructions that use the Mod/RM byte
572 /// to specify a memory source, but doesn't use the middle field.
573 MRMXm = 31,
574 /// MRM0m-MRM7m - Instructions that operate on a memory r/m operand and use
575 /// reg field to hold extended opcode, which is represented as /0, /1, ...
576 MRM0m = 32, // Format /0
577 MRM1m = 33, // Format /1
578 MRM2m = 34, // Format /2
579 MRM3m = 35, // Format /3
580 MRM4m = 36, // Format /4
581 MRM5m = 37, // Format /5
582 MRM6m = 38, // Format /6
583 MRM7m = 39, // Format /7
584 /// MRMDestReg - This form is used for instructions that use the Mod/RM byte
585 /// to specify a destination, which in this case is a register.
587 /// MRMSrcReg - This form is used for instructions that use the Mod/RM byte
588 /// to specify a source, which in this case is a register.
590 /// MRMSrcReg4VOp3 - This form is used for instructions that encode
591 /// operand 3 with VEX.VVVV and do not load from memory.
593 /// MRMSrcRegOp4 - This form is used for instructions that use the Mod/RM
594 /// byte to specify the fourth source, which in this case is a register.
596 /// MRMSrcRegCC - This form is used for instructions that use the Mod/RM
597 /// byte to specify the operands and also encodes a condition code
599 /// MRMXCCr - This form is used for instructions that use the Mod/RM byte
600 /// to specify a register source, but doesn't use the middle field. And has
601 /// a condition code.
603 /// MRMXr - This form is used for instructions that use the Mod/RM byte
604 /// to specify a register source, but doesn't use the middle field.
605 MRMXr = 47,
606 /// MRM0r-MRM7r - Instructions that operate on a register r/m operand and use
607 /// reg field to hold extended opcode, which is represented as /0, /1, ...
608 MRM0r = 48, // Format /0
609 MRM1r = 49, // Format /1
610 MRM2r = 50, // Format /2
611 MRM3r = 51, // Format /3
612 MRM4r = 52, // Format /4
613 MRM5r = 53, // Format /5
614 MRM6r = 54, // Format /6
615 MRM7r = 55, // Format /7
616 /// MRM0X-MRM7X - Instructions that operate that have mod=11 and an opcode but
617 /// ignore r/m.
618 MRM0X = 56, // Format /0
619 MRM1X = 57, // Format /1
620 MRM2X = 58, // Format /2
621 MRM3X = 59, // Format /3
622 MRM4X = 60, // Format /4
623 MRM5X = 61, // Format /5
624 MRM6X = 62, // Format /6
625 MRM7X = 63, // Format /7
626 /// MRM_XX (XX: C0-FF)- A mod/rm byte of exactly 0xXX.
627 MRM_C0 = 64,
628 MRM_C1 = 65,
629 MRM_C2 = 66,
630 MRM_C3 = 67,
631 MRM_C4 = 68,
632 MRM_C5 = 69,
633 MRM_C6 = 70,
634 MRM_C7 = 71,
635 MRM_C8 = 72,
636 MRM_C9 = 73,
637 MRM_CA = 74,
638 MRM_CB = 75,
639 MRM_CC = 76,
640 MRM_CD = 77,
641 MRM_CE = 78,
642 MRM_CF = 79,
643 MRM_D0 = 80,
644 MRM_D1 = 81,
645 MRM_D2 = 82,
646 MRM_D3 = 83,
647 MRM_D4 = 84,
648 MRM_D5 = 85,
649 MRM_D6 = 86,
650 MRM_D7 = 87,
651 MRM_D8 = 88,
652 MRM_D9 = 89,
653 MRM_DA = 90,
654 MRM_DB = 91,
655 MRM_DC = 92,
656 MRM_DD = 93,
657 MRM_DE = 94,
658 MRM_DF = 95,
659 MRM_E0 = 96,
660 MRM_E1 = 97,
661 MRM_E2 = 98,
662 MRM_E3 = 99,
663 MRM_E4 = 100,
664 MRM_E5 = 101,
665 MRM_E6 = 102,
666 MRM_E7 = 103,
667 MRM_E8 = 104,
668 MRM_E9 = 105,
669 MRM_EA = 106,
670 MRM_EB = 107,
671 MRM_EC = 108,
672 MRM_ED = 109,
673 MRM_EE = 110,
674 MRM_EF = 111,
675 MRM_F0 = 112,
676 MRM_F1 = 113,
677 MRM_F2 = 114,
678 MRM_F3 = 115,
679 MRM_F4 = 116,
680 MRM_F5 = 117,
681 MRM_F6 = 118,
682 MRM_F7 = 119,
683 MRM_F8 = 120,
684 MRM_F9 = 121,
685 MRM_FA = 122,
686 MRM_FB = 123,
687 MRM_FC = 124,
688 MRM_FD = 125,
689 MRM_FE = 126,
690 MRM_FF = 127,
691 FormMask = 127,
692 //===------------------------------------------------------------------===//
693 // Actual flags...
694 /// OpSize - OpSizeFixed implies instruction never needs a 0x66 prefix.
695 /// OpSize16 means this is a 16-bit instruction and needs 0x66 prefix in
696 /// 32-bit mode. OpSize32 means this is a 32-bit instruction needs a 0x66
697 /// prefix in 16-bit mode.
703 /// AsSize - AdSizeX implies this instruction determines its need of 0x67
704 /// prefix from a normal ModRM memory operand. The other types indicate that
705 /// an operand is encoded with a specific width and a prefix is needed if
706 /// it differs from the current mode.
713 //===------------------------------------------------------------------===//
714 /// OpPrefix - There are several prefix bytes that are used as opcode
715 /// extensions. These are 0x66, 0xF3, and 0xF2. If this field is 0 there is
716 /// no prefix.
719 /// PD - Prefix code for packed double precision vector floating point
720 /// operations performed in the SSE registers.
722 /// XS, XD - These prefix codes are for single and double precision scalar
723 /// floating point operations performed in the SSE registers.
726 //===------------------------------------------------------------------===//
727 /// OpMap - This field determines which opcode map this instruction
728 /// belongs to. i.e. one-byte, two-byte, 0x0f 0x38, 0x0f 0x3a, etc.
731 /// OB - OneByte - Set if this instruction has a one byte opcode.
733 /// TB - TwoByte - Set if this instruction has a two byte opcode, which
734 /// starts with a 0x0F byte before the real opcode.
736 /// T8, TA - Prefix after the 0x0F prefix.
739 /// XOP8 - Prefix to include use of imm byte.
741 /// XOP9 - Prefix to exclude use of imm byte.
743 /// XOPA - Prefix to encode 0xA in VEX.MMMM of XOP instructions.
745 /// ThreeDNow - This indicates that the instruction uses the
746 /// wacky 0x0F 0x0F prefix for 3DNow! instructions. The manual documents
747 /// this as having a 0x0F prefix with a 0x0F opcode, and each instruction
748 /// storing a classifier in the imm8 field. To simplify our implementation,
749 /// we handle this by storeing the classifier in the opcode field and using
750 /// this flag to indicate that the encoder should do the wacky 3DNow! thing.
752 /// MAP4, MAP5, MAP6, MAP7 - Prefix after the 0x0F prefix.
757 //===------------------------------------------------------------------===//
758 /// REX_W - REX prefixes are instruction prefixes used in 64-bit mode.
759 /// They are used to specify GPRs and SSE registers, 64-bit operand size,
760 /// etc. We only cares about REX.W and REX.R bits and only the former is
761 /// statically determined.
764 //===------------------------------------------------------------------===//
765 // This 4-bit field describes the size of an immediate operand. Zero is
766 // unused so that we can tell if we forgot to set a value.
778 //===------------------------------------------------------------------===//
779 /// FP Instruction Classification... Zero is non-fp instruction.
780 /// FPTypeMask - Mask for all of the FP types...
783 /// NotFP - The default, set for instructions that do not use FP registers.
785 /// ZeroArgFP - 0 arg FP instruction which implicitly pushes ST(0), f.e. fld0
787 /// OneArgFP - 1 arg FP instructions which implicitly read ST(0), such as fst
789 /// OneArgFPRW - 1 arg FP instruction which implicitly read ST(0) and write a
790 /// result back to ST(0). For example, fcos, fsqrt, etc.
792 /// TwoArgFP - 2 arg FP instructions which implicitly read ST(0), and an
793 /// explicit argument, storing the result to either ST(0) or the implicit
794 /// argument. For example: fadd, fsub, fmul, etc...
796 /// CompareFP - 2 arg FP instructions which implicitly read ST(0) and an
797 /// explicit argument, but have no destination. Example: fucom, fucomi, ...
799 /// CondMovFP - "2 operand" floating point conditional move instructions.
801 /// SpecialFP - Special instruction forms. Dispatch by opcode explicitly.
803 /// Lock prefix
806 /// REP prefix
808 REP = 1 << REPShift,
809 /// Execution domain for SSE instructions.
810 /// 0 means normal, non-SSE instruction.
812 /// Encoding
815 /// LEGACY - encoding using REX/REX2 or w/o opcode prefix.
817 /// VEX - encoding using 0xC4/0xC5
819 /// XOP - Opcode prefix used by XOP instructions.
821 /// EVEX - Specifies that this instruction use EVEX form which provides
822 /// syntax support up to 32 512-bit register operands and up to 7 16-bit
823 /// mask operands as well as source operand data swizzling/memory operand
824 /// conversion, eviction hint, and rounding mode.
826 /// Opcode
828 /// VEX_4V - Used to specify an additional AVX/SSE register. Several 2
829 /// address instructions in SSE are represented as 3 address ones in AVX
830 /// and the additional register is encoded in VEX_VVVV prefix.
833 /// VEX_L - Stands for a bit in the VEX opcode prefix meaning the current
834 /// instruction uses 256-bit wide registers. This is usually auto detected
835 /// if a VR256 register is used, but some AVX instructions also have this
836 /// field marked when using a f256 memory references.
838 VEX_L = 1ULL << VEX_LShift,
839 /// EVEX_K - Set if this instruction requires masking
842 /// EVEX_Z - Set if this instruction has EVEX.Z field set.
845 /// EVEX_L2 - Set if this instruction has EVEX.L' field set.
848 /// EVEX_B - Set if this instruction has EVEX.B field set.
851 /// The scaling factor for the AVX512's 8-bit compressed displacement.
854 /// Explicitly specified rounding control
857 /// NOTRACK prefix
860 /// Force REX2/VEX/EVEX encoding
862 /// For instructions that require REX2 prefix even if EGPR is not used.
864 /// For instructions that use VEX encoding only when {vex}, {vex2} or {vex3}
865 /// is present.
867 /// For instructions that are promoted to EVEX space for EGPR.
870 /// EVEX_NF - Set if this instruction has EVEX.NF field set.
873 // TwoConditionalOps - Set if this instruction has two conditional operands
876 // EVEX_U - Set if this instruction has EVEX.U field set.
878 EVEX_U = 1ULL << EVEX_UShift
880
881/// \returns true if the instruction with given opcode is a prefix.
882inline bool isPrefix(uint64_t TSFlags) {
883 return (TSFlags & X86II::FormMask) == PrefixByte;
884}
885
886/// \returns true if the instruction with given opcode is a pseudo.
887inline bool isPseudo(uint64_t TSFlags) {
888 return (TSFlags & X86II::FormMask) == Pseudo;
889}
890
891/// \returns the "base" X86 opcode for the specified machine
892/// instruction.
893inline uint8_t getBaseOpcodeFor(uint64_t TSFlags) {
894 return TSFlags >> X86II::OpcodeShift;
895}
896
897inline bool hasImm(uint64_t TSFlags) { return (TSFlags & X86II::ImmMask) != 0; }
898
899/// Decode the "size of immediate" field from the TSFlags field of the
900/// specified instruction.
901inline unsigned getSizeOfImm(uint64_t TSFlags) {
902 switch (TSFlags & X86II::ImmMask) {
903 default:
904 llvm_unreachable("Unknown immediate size");
905 case X86II::Imm8:
906 case X86II::Imm8PCRel:
907 case X86II::Imm8Reg:
908 return 1;
909 case X86II::Imm16:
911 return 2;
912 case X86II::Imm32:
913 case X86II::Imm32S:
915 return 4;
916 case X86II::Imm64:
917 return 8;
918 }
919}
920
921/// \returns true if the immediate of the specified instruction's TSFlags
922/// indicates that it is pc relative.
923inline bool isImmPCRel(uint64_t TSFlags) {
924 switch (TSFlags & X86II::ImmMask) {
925 default:
926 llvm_unreachable("Unknown immediate size");
927 case X86II::Imm8PCRel:
930 return true;
931 case X86II::Imm8:
932 case X86II::Imm8Reg:
933 case X86II::Imm16:
934 case X86II::Imm32:
935 case X86II::Imm32S:
936 case X86II::Imm64:
937 return false;
938 }
939}
940
941/// \returns true if the immediate of the specified instruction's
942/// TSFlags indicates that it is signed.
943inline bool isImmSigned(uint64_t TSFlags) {
944 switch (TSFlags & X86II::ImmMask) {
945 default:
946 llvm_unreachable("Unknown immediate signedness");
947 case X86II::Imm32S:
948 return true;
949 case X86II::Imm8:
950 case X86II::Imm8PCRel:
951 case X86II::Imm8Reg:
952 case X86II::Imm16:
954 case X86II::Imm32:
956 case X86II::Imm64:
957 return false;
958 }
959}
960
961/// Compute whether all of the def operands are repeated in the uses and
962/// therefore should be skipped.
963/// This determines the start of the unique operand list. We need to determine
964/// if all of the defs have a corresponding tied operand in the uses.
965/// Unfortunately, the tied operand information is encoded in the uses not
966/// the defs so we have to use some heuristics to find which operands to
967/// query.
968inline unsigned getOperandBias(const MCInstrDesc &Desc) {
969 unsigned NumDefs = Desc.getNumDefs();
970 unsigned NumOps = Desc.getNumOperands();
971 switch (NumDefs) {
972 default:
973 llvm_unreachable("Unexpected number of defs");
974 case 0:
975 return 0;
976 case 1:
977 // Common two addr case.
978 if (NumOps > 1 && Desc.getOperandConstraint(1, MCOI::TIED_TO) == 0)
979 return 1;
980 // Check for AVX-512 scatter which has a TIED_TO in the second to last
981 // operand.
982 if (NumOps == 8 && Desc.getOperandConstraint(6, MCOI::TIED_TO) == 0)
983 return 1;
984 return 0;
985 case 2:
986 // XCHG/XADD have two destinations and two sources.
987 if (NumOps >= 4 && Desc.getOperandConstraint(2, MCOI::TIED_TO) == 0 &&
988 Desc.getOperandConstraint(3, MCOI::TIED_TO) == 1)
989 return 2;
990 // Check for gather. AVX-512 has the second tied operand early. AVX2
991 // has it as the last op.
992 if (NumOps == 9 && Desc.getOperandConstraint(2, MCOI::TIED_TO) == 0 &&
993 (Desc.getOperandConstraint(3, MCOI::TIED_TO) == 1 ||
994 Desc.getOperandConstraint(8, MCOI::TIED_TO) == 1))
995 return 2;
996 return 0;
997 }
998}
999
1000/// \returns true if the instruction has a NDD (new data destination).
1001inline bool hasNewDataDest(uint64_t TSFlags) {
1002 return (TSFlags & X86II::OpMapMask) == X86II::T_MAP4 &&
1003 (TSFlags & X86II::EVEX_B) && (TSFlags & X86II::VEX_4V);
1004}
1005
1006/// \returns operand # for the first field of the memory operand or -1 if no
1007/// memory operands.
1008/// NOTE: This ignores tied operands. If there is a tied register which is
1009/// duplicated in the MCInst (e.g. "EAX = addl EAX, [mem]") it is only counted
1010/// as one operand.
1011inline int getMemoryOperandNo(uint64_t TSFlags) {
1012 bool HasVEX_4V = TSFlags & X86II::VEX_4V;
1013 bool HasEVEX_K = TSFlags & X86II::EVEX_K;
1014
1015 switch (TSFlags & X86II::FormMask) {
1016 default:
1017 llvm_unreachable("Unknown FormMask value in getMemoryOperandNo!");
1018 case X86II::Pseudo:
1019 case X86II::RawFrm:
1020 case X86II::AddRegFrm:
1021 case X86II::RawFrmImm8:
1022 case X86II::RawFrmImm16:
1024 case X86II::RawFrmSrc:
1025 case X86II::RawFrmDst:
1027 case X86II::AddCCFrm:
1028 case X86II::PrefixByte:
1029 return -1;
1030 case X86II::MRMDestMem:
1033 return hasNewDataDest(TSFlags);
1034 case X86II::MRMSrcMem:
1036 // Start from 1, skip any registers encoded in VEX_VVVV or I8IMM, or a
1037 // mask register.
1038 return 1 + HasVEX_4V + HasEVEX_K;
1040 // Skip registers encoded in reg.
1041 return 1 + HasEVEX_K;
1043 // Skip registers encoded in reg, VEX_VVVV, and I8IMM.
1044 return 3;
1045 case X86II::MRMSrcMemCC:
1046 return 1 + hasNewDataDest(TSFlags);
1048 // Start from 1, skip any registers encoded in VEX_VVVV or I8IMM, or a
1049 // mask register.
1050 return 1;
1051 case X86II::MRMDestReg:
1053 case X86II::MRMSrcReg:
1056 case X86II::MRMSrcRegCC:
1057 case X86II::MRMXrCC:
1058 case X86II::MRMr0:
1059 case X86II::MRMXr:
1060 case X86II::MRM0r:
1061 case X86II::MRM1r:
1062 case X86II::MRM2r:
1063 case X86II::MRM3r:
1064 case X86II::MRM4r:
1065 case X86II::MRM5r:
1066 case X86II::MRM6r:
1067 case X86II::MRM7r:
1068 return -1;
1069 case X86II::MRM0X:
1070 case X86II::MRM1X:
1071 case X86II::MRM2X:
1072 case X86II::MRM3X:
1073 case X86II::MRM4X:
1074 case X86II::MRM5X:
1075 case X86II::MRM6X:
1076 case X86II::MRM7X:
1077 return -1;
1078 case X86II::MRMXmCC:
1079 case X86II::MRMXm:
1080 case X86II::MRM0m:
1081 case X86II::MRM1m:
1082 case X86II::MRM2m:
1083 case X86II::MRM3m:
1084 case X86II::MRM4m:
1085 case X86II::MRM5m:
1086 case X86II::MRM6m:
1087 case X86II::MRM7m:
1088 // Start from 0, skip registers encoded in VEX_VVVV or a mask register.
1089 return 0 + HasVEX_4V + HasEVEX_K;
1090 case X86II::MRM_C0:
1091 case X86II::MRM_C1:
1092 case X86II::MRM_C2:
1093 case X86II::MRM_C3:
1094 case X86II::MRM_C4:
1095 case X86II::MRM_C5:
1096 case X86II::MRM_C6:
1097 case X86II::MRM_C7:
1098 case X86II::MRM_C8:
1099 case X86II::MRM_C9:
1100 case X86II::MRM_CA:
1101 case X86II::MRM_CB:
1102 case X86II::MRM_CC:
1103 case X86II::MRM_CD:
1104 case X86II::MRM_CE:
1105 case X86II::MRM_CF:
1106 case X86II::MRM_D0:
1107 case X86II::MRM_D1:
1108 case X86II::MRM_D2:
1109 case X86II::MRM_D3:
1110 case X86II::MRM_D4:
1111 case X86II::MRM_D5:
1112 case X86II::MRM_D6:
1113 case X86II::MRM_D7:
1114 case X86II::MRM_D8:
1115 case X86II::MRM_D9:
1116 case X86II::MRM_DA:
1117 case X86II::MRM_DB:
1118 case X86II::MRM_DC:
1119 case X86II::MRM_DD:
1120 case X86II::MRM_DE:
1121 case X86II::MRM_DF:
1122 case X86II::MRM_E0:
1123 case X86II::MRM_E1:
1124 case X86II::MRM_E2:
1125 case X86II::MRM_E3:
1126 case X86II::MRM_E4:
1127 case X86II::MRM_E5:
1128 case X86II::MRM_E6:
1129 case X86II::MRM_E7:
1130 case X86II::MRM_E8:
1131 case X86II::MRM_E9:
1132 case X86II::MRM_EA:
1133 case X86II::MRM_EB:
1134 case X86II::MRM_EC:
1135 case X86II::MRM_ED:
1136 case X86II::MRM_EE:
1137 case X86II::MRM_EF:
1138 case X86II::MRM_F0:
1139 case X86II::MRM_F1:
1140 case X86II::MRM_F2:
1141 case X86II::MRM_F3:
1142 case X86II::MRM_F4:
1143 case X86II::MRM_F5:
1144 case X86II::MRM_F6:
1145 case X86II::MRM_F7:
1146 case X86II::MRM_F8:
1147 case X86II::MRM_F9:
1148 case X86II::MRM_FA:
1149 case X86II::MRM_FB:
1150 case X86II::MRM_FC:
1151 case X86II::MRM_FD:
1152 case X86II::MRM_FE:
1153 case X86II::MRM_FF:
1154 return -1;
1155 }
1156}
1157
1158/// \returns true if the register is a XMM.
1159inline bool isXMMReg(unsigned RegNo) {
1160 static_assert(X86::XMM15 - X86::XMM0 == 15,
1161 "XMM0-15 registers are not continuous");
1162 static_assert(X86::XMM31 - X86::XMM16 == 15,
1163 "XMM16-31 registers are not continuous");
1164 return (RegNo >= X86::XMM0 && RegNo <= X86::XMM15) ||
1165 (RegNo >= X86::XMM16 && RegNo <= X86::XMM31);
1166}
1167
1168/// \returns true if the register is a YMM.
1169inline bool isYMMReg(unsigned RegNo) {
1170 static_assert(X86::YMM15 - X86::YMM0 == 15,
1171 "YMM0-15 registers are not continuous");
1172 static_assert(X86::YMM31 - X86::YMM16 == 15,
1173 "YMM16-31 registers are not continuous");
1174 return (RegNo >= X86::YMM0 && RegNo <= X86::YMM15) ||
1175 (RegNo >= X86::YMM16 && RegNo <= X86::YMM31);
1176}
1177
1178/// \returns true if the register is a ZMM.
1179inline bool isZMMReg(unsigned RegNo) {
1180 static_assert(X86::ZMM31 - X86::ZMM0 == 31,
1181 "ZMM registers are not continuous");
1182 return RegNo >= X86::ZMM0 && RegNo <= X86::ZMM31;
1183}
1184
1185/// \returns true if \p RegNo is an apx extended register.
1186inline bool isApxExtendedReg(unsigned RegNo) {
1187 static_assert(X86::R31WH - X86::R16 == 95, "EGPRs are not continuous");
1188 return RegNo >= X86::R16 && RegNo <= X86::R31WH;
1189}
1190
1191/// \returns true if the MachineOperand is a x86-64 extended (r8 or
1192/// higher) register, e.g. r8, xmm8, xmm13, etc.
1193inline bool isX86_64ExtendedReg(unsigned RegNo) {
1194 if ((RegNo >= X86::XMM8 && RegNo <= X86::XMM15) ||
1195 (RegNo >= X86::XMM16 && RegNo <= X86::XMM31) ||
1196 (RegNo >= X86::YMM8 && RegNo <= X86::YMM15) ||
1197 (RegNo >= X86::YMM16 && RegNo <= X86::YMM31) ||
1198 (RegNo >= X86::ZMM8 && RegNo <= X86::ZMM31))
1199 return true;
1200
1201 if (isApxExtendedReg(RegNo))
1202 return true;
1203
1204 switch (RegNo) {
1205 default:
1206 break;
1207 case X86::R8:
1208 case X86::R9:
1209 case X86::R10:
1210 case X86::R11:
1211 case X86::R12:
1212 case X86::R13:
1213 case X86::R14:
1214 case X86::R15:
1215 case X86::R8D:
1216 case X86::R9D:
1217 case X86::R10D:
1218 case X86::R11D:
1219 case X86::R12D:
1220 case X86::R13D:
1221 case X86::R14D:
1222 case X86::R15D:
1223 case X86::R8W:
1224 case X86::R9W:
1225 case X86::R10W:
1226 case X86::R11W:
1227 case X86::R12W:
1228 case X86::R13W:
1229 case X86::R14W:
1230 case X86::R15W:
1231 case X86::R8B:
1232 case X86::R9B:
1233 case X86::R10B:
1234 case X86::R11B:
1235 case X86::R12B:
1236 case X86::R13B:
1237 case X86::R14B:
1238 case X86::R15B:
1239 case X86::CR8:
1240 case X86::CR9:
1241 case X86::CR10:
1242 case X86::CR11:
1243 case X86::CR12:
1244 case X86::CR13:
1245 case X86::CR14:
1246 case X86::CR15:
1247 case X86::DR8:
1248 case X86::DR9:
1249 case X86::DR10:
1250 case X86::DR11:
1251 case X86::DR12:
1252 case X86::DR13:
1253 case X86::DR14:
1254 case X86::DR15:
1255 return true;
1256 }
1257 return false;
1258}
1259
1261 uint64_t TSFlags = Desc.TSFlags;
1262 uint64_t Encoding = TSFlags & EncodingMask;
1263 // EVEX can always use egpr.
1264 if (Encoding == X86II::EVEX)
1265 return true;
1266
1267 unsigned Opcode = Desc.Opcode;
1268 // MOV32r0 is always expanded to XOR32rr
1269 if (Opcode == X86::MOV32r0)
1270 return true;
1271 // To be conservative, egpr is not used for all pseudo instructions
1272 // because we are not sure what instruction it will become.
1273 // FIXME: Could we improve it in X86ExpandPseudo?
1274 if (isPseudo(TSFlags))
1275 return false;
1276
1277 // MAP OB/TB in legacy encoding space can always use egpr except
1278 // XSAVE*/XRSTOR*.
1279 switch (Opcode) {
1280 default:
1281 break;
1282 case X86::XSAVE:
1283 case X86::XSAVE64:
1284 case X86::XSAVEOPT:
1285 case X86::XSAVEOPT64:
1286 case X86::XSAVEC:
1287 case X86::XSAVEC64:
1288 case X86::XSAVES:
1289 case X86::XSAVES64:
1290 case X86::XRSTOR:
1291 case X86::XRSTOR64:
1292 case X86::XRSTORS:
1293 case X86::XRSTORS64:
1294 return false;
1295 }
1296 uint64_t OpMap = TSFlags & X86II::OpMapMask;
1297 return !Encoding && (OpMap == X86II::OB || OpMap == X86II::TB);
1298}
1299
1300/// \returns true if the MemoryOperand is a 32 extended (zmm16 or higher)
1301/// registers, e.g. zmm21, etc.
1302static inline bool is32ExtendedReg(unsigned RegNo) {
1303 return ((RegNo >= X86::XMM16 && RegNo <= X86::XMM31) ||
1304 (RegNo >= X86::YMM16 && RegNo <= X86::YMM31) ||
1305 (RegNo >= X86::ZMM16 && RegNo <= X86::ZMM31));
1306}
1307
1308inline bool isX86_64NonExtLowByteReg(unsigned reg) {
1309 return (reg == X86::SPL || reg == X86::BPL || reg == X86::SIL ||
1310 reg == X86::DIL);
1311}
1312
1313/// \returns true if this is a masked instruction.
1314inline bool isKMasked(uint64_t TSFlags) {
1315 return (TSFlags & X86II::EVEX_K) != 0;
1316}
1317
1318/// \returns true if this is a merge masked instruction.
1319inline bool isKMergeMasked(uint64_t TSFlags) {
1320 return isKMasked(TSFlags) && (TSFlags & X86II::EVEX_Z) == 0;
1321}
1322
1323/// \returns true if the intruction needs a SIB.
1324inline bool needSIB(unsigned BaseReg, unsigned IndexReg, bool In64BitMode) {
1325 // The SIB byte must be used if there is an index register.
1326 if (IndexReg)
1327 return true;
1328
1329 // The SIB byte must be used if the base is ESP/RSP/R12/R20/R28, all of
1330 // which encode to an R/M value of 4, which indicates that a SIB byte is
1331 // present.
1332 switch (BaseReg) {
1333 default:
1334 // If there is no base register and we're in 64-bit mode, we need a SIB
1335 // byte to emit an addr that is just 'disp32' (the non-RIP relative form).
1336 return In64BitMode && !BaseReg;
1337 case X86::ESP:
1338 case X86::RSP:
1339 case X86::R12:
1340 case X86::R12D:
1341 case X86::R20:
1342 case X86::R20D:
1343 case X86::R28:
1344 case X86::R28D:
1345 return true;
1346 }
1347}
1348
1349} // namespace X86II
1350} // namespace llvm
1351#endif
unsigned Reg
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:198
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ OPERAND_FIRST_TARGET
Definition: MCInstrDesc.h:78
@ X86
Windows x64, Windows Itanium (IA-64)
bool isKMergeMasked(uint64_t TSFlags)
Definition: X86BaseInfo.h:1319
bool isXMMReg(unsigned RegNo)
Definition: X86BaseInfo.h:1159
bool isX86_64ExtendedReg(unsigned RegNo)
Definition: X86BaseInfo.h:1193
bool isPrefix(uint64_t TSFlags)
Definition: X86BaseInfo.h:882
bool hasImm(uint64_t TSFlags)
Definition: X86BaseInfo.h:897
bool hasNewDataDest(uint64_t TSFlags)
Definition: X86BaseInfo.h:1001
TOF
Target Operand Flag enum.
Definition: X86BaseInfo.h:358
@ MO_TLSLD
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:411
@ MO_GOTPCREL_NORELAX
MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...
Definition: X86BaseInfo.h:391
@ MO_GOTOFF
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
Definition: X86BaseInfo.h:381
@ MO_DARWIN_NONLAZY_PIC_BASE
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
Definition: X86BaseInfo.h:468
@ MO_GOT_ABSOLUTE_ADDRESS
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [.
Definition: X86BaseInfo.h:367
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
Definition: X86BaseInfo.h:488
@ MO_NTPOFF
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
Definition: X86BaseInfo.h:450
@ MO_DARWIN_NONLAZY
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
Definition: X86BaseInfo.h:464
@ MO_INDNTPOFF
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
Definition: X86BaseInfo.h:432
@ MO_GOTNTPOFF
MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...
Definition: X86BaseInfo.h:456
@ MO_TPOFF
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
Definition: X86BaseInfo.h:438
@ MO_TLVP_PIC_BASE
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
Definition: X86BaseInfo.h:476
@ MO_GOT
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
Definition: X86BaseInfo.h:376
@ MO_ABS8
MO_ABS8 - On a symbol operand this indicates that the symbol is known to be an absolute symbol in ran...
Definition: X86BaseInfo.h:484
@ MO_PLT
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
Definition: X86BaseInfo.h:396
@ MO_TLSGD
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:403
@ MO_NO_FLAG
MO_NO_FLAG - No flag for the operand.
Definition: X86BaseInfo.h:363
@ MO_TLVP
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
Definition: X86BaseInfo.h:472
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
Definition: X86BaseInfo.h:460
@ MO_GOTTPOFF
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
Definition: X86BaseInfo.h:425
@ MO_SECREL
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
Definition: X86BaseInfo.h:480
@ MO_DTPOFF
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:444
@ MO_PIC_BASE_OFFSET
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
Definition: X86BaseInfo.h:371
@ MO_TLSLDM
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:419
@ MO_GOTPCREL
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
Definition: X86BaseInfo.h:387
bool isZMMReg(unsigned RegNo)
Definition: X86BaseInfo.h:1179
bool isX86_64NonExtLowByteReg(unsigned reg)
Definition: X86BaseInfo.h:1308
bool isYMMReg(unsigned RegNo)
Definition: X86BaseInfo.h:1169
bool canUseApxExtendedReg(const MCInstrDesc &Desc)
Definition: X86BaseInfo.h:1260
bool needSIB(unsigned BaseReg, unsigned IndexReg, bool In64BitMode)
Definition: X86BaseInfo.h:1324
bool isPseudo(uint64_t TSFlags)
Definition: X86BaseInfo.h:887
bool isImmPCRel(uint64_t TSFlags)
Definition: X86BaseInfo.h:923
unsigned getSizeOfImm(uint64_t TSFlags)
Decode the "size of immediate" field from the TSFlags field of the specified instruction.
Definition: X86BaseInfo.h:901
uint8_t getBaseOpcodeFor(uint64_t TSFlags)
Definition: X86BaseInfo.h:893
bool isKMasked(uint64_t TSFlags)
Definition: X86BaseInfo.h:1314
bool isApxExtendedReg(unsigned RegNo)
Definition: X86BaseInfo.h:1186
int getMemoryOperandNo(uint64_t TSFlags)
Definition: X86BaseInfo.h:1011
unsigned getOperandBias(const MCInstrDesc &Desc)
Compute whether all of the def operands are repeated in the uses and therefore should be skipped.
Definition: X86BaseInfo.h:968
static bool is32ExtendedReg(unsigned RegNo)
Definition: X86BaseInfo.h:1302
@ ExplicitOpPrefixShift
Force REX2/VEX/EVEX encoding.
Definition: X86BaseInfo.h:861
@ MRM0X
MRM0X-MRM7X - Instructions that operate that have mod=11 and an opcode but ignore r/m.
Definition: X86BaseInfo.h:618
@ EVEX_ZShift
EVEX_Z - Set if this instruction has EVEX.Z field set.
Definition: X86BaseInfo.h:843
@ RawFrm
Raw - This form is for instructions that don't have any operands, so they are just a fixed opcode val...
Definition: X86BaseInfo.h:502
@ VEX_LShift
VEX_L - Stands for a bit in the VEX opcode prefix meaning the current instruction uses 256-bit wide r...
Definition: X86BaseInfo.h:837
@ SpecialFP
SpecialFP - Special instruction forms. Dispatch by opcode explicitly.
Definition: X86BaseInfo.h:802
@ RawFrmDstSrc
RawFrmDstSrc - This form is for instructions that use the source index register SI/ESI/RSI with a pos...
Definition: X86BaseInfo.h:518
@ EVEX_KShift
EVEX_K - Set if this instruction requires masking.
Definition: X86BaseInfo.h:840
@ EVEX
EVEX - Specifies that this instruction use EVEX form which provides syntax support up to 32 512-bit r...
Definition: X86BaseInfo.h:825
@ OpcodeShift
Opcode.
Definition: X86BaseInfo.h:827
@ ExplicitREX2Prefix
For instructions that require REX2 prefix even if EGPR is not used.
Definition: X86BaseInfo.h:863
@ EVEX_BShift
EVEX_B - Set if this instruction has EVEX.B field set.
Definition: X86BaseInfo.h:849
@ MRMSrcMemCC
MRMSrcMemCC - This form is used for instructions that use the Mod/RM byte to specify the operands and...
Definition: X86BaseInfo.h:566
@ NotFP
NotFP - The default, set for instructions that do not use FP registers.
Definition: X86BaseInfo.h:784
@ MRM_C0
MRM_XX (XX: C0-FF)- A mod/rm byte of exactly 0xXX.
Definition: X86BaseInfo.h:627
@ RawFrmDst
RawFrmDst - This form is for instructions that use the destination index register DI/EDI/RDI.
Definition: X86BaseInfo.h:514
@ OpPrefixShift
OpPrefix - There are several prefix bytes that are used as opcode extensions.
Definition: X86BaseInfo.h:717
@ MRMDestMem4VOp3CC
MRMDestMem4VOp3CC - This form is used for instructions that use the Mod/RM byte to specify a destinat...
Definition: X86BaseInfo.h:545
@ OB
OB - OneByte - Set if this instruction has a one byte opcode.
Definition: X86BaseInfo.h:732
@ AddCCFrm
AddCCFrm - This form is used for Jcc that encode the condition code in the lower 4 bits of the opcode...
Definition: X86BaseInfo.h:530
@ T_MAP4
MAP4, MAP5, MAP6, MAP7 - Prefix after the 0x0F prefix.
Definition: X86BaseInfo.h:753
@ PrefixByte
PrefixByte - This form is used for instructions that represent a prefix byte like data16 or rep.
Definition: X86BaseInfo.h:533
@ MRMr0
Instructions operate on a register Reg/Opcode operand not the r/m field.
Definition: X86BaseInfo.h:547
@ TwoConditionalOps_Shift
Definition: X86BaseInfo.h:874
@ MRMXm
MRMXm - This form is used for instructions that use the Mod/RM byte to specify a memory source,...
Definition: X86BaseInfo.h:573
@ OneArgFPRW
OneArgFPRW - 1 arg FP instruction which implicitly read ST(0) and write a result back to ST(0).
Definition: X86BaseInfo.h:791
@ MRM0r
MRM0r-MRM7r - Instructions that operate on a register r/m operand and use reg field to hold extended ...
Definition: X86BaseInfo.h:608
@ MRMDestMemFSIB
MRMDestMem - But force to use the SIB field.
Definition: X86BaseInfo.h:551
@ AddRegFrm
AddRegFrm - This form is used for instructions like 'push r32' that have their one register operand a...
Definition: X86BaseInfo.h:505
@ ExplicitEVEXPrefix
For instructions that are promoted to EVEX space for EGPR.
Definition: X86BaseInfo.h:868
@ VEX
VEX - encoding using 0xC4/0xC5.
Definition: X86BaseInfo.h:818
@ RawFrmImm8
RawFrmImm8 - This is used for the ENTER instruction, which has two immediates, the first of which is ...
Definition: X86BaseInfo.h:522
@ OpSizeShift
OpSize - OpSizeFixed implies instruction never needs a 0x66 prefix.
Definition: X86BaseInfo.h:698
@ TB
TB - TwoByte - Set if this instruction has a two byte opcode, which starts with a 0x0F byte before th...
Definition: X86BaseInfo.h:735
@ XOP
XOP - Opcode prefix used by XOP instructions.
Definition: X86BaseInfo.h:820
@ MRMXr
MRMXr - This form is used for instructions that use the Mod/RM byte to specify a register source,...
Definition: X86BaseInfo.h:605
@ LOCKShift
Lock prefix.
Definition: X86BaseInfo.h:804
@ MRMSrcMem4VOp3
MRMSrcMem4VOp3 - This form is used for instructions that encode operand 3 with VEX....
Definition: X86BaseInfo.h:560
@ EVEX_L2Shift
EVEX_L2 - Set if this instruction has EVEX.L' field set.
Definition: X86BaseInfo.h:846
@ XOP8
XOP8 - Prefix to include use of imm byte.
Definition: X86BaseInfo.h:740
@ ZeroArgFP
ZeroArgFP - 0 arg FP instruction which implicitly pushes ST(0), f.e. fld0.
Definition: X86BaseInfo.h:786
@ REXShift
REX_W - REX prefixes are instruction prefixes used in 64-bit mode.
Definition: X86BaseInfo.h:762
@ MRMDestRegCC
MRMDestRegCC - This form is used for the cfcmov instructions, which use the Mod/RM byte to specify th...
Definition: X86BaseInfo.h:537
@ AdSizeShift
AsSize - AdSizeX implies this instruction determines its need of 0x67 prefix from a normal ModRM memo...
Definition: X86BaseInfo.h:707
@ REPShift
REP prefix.
Definition: X86BaseInfo.h:807
@ PD
PD - Prefix code for packed double precision vector floating point operations performed in the SSE re...
Definition: X86BaseInfo.h:721
@ MRMDestMem
MRMDestMem - This form is used for instructions that use the Mod/RM byte to specify a destination,...
Definition: X86BaseInfo.h:554
@ EncodingShift
Encoding.
Definition: X86BaseInfo.h:813
@ OneArgFP
OneArgFP - 1 arg FP instructions which implicitly read ST(0), such as fst.
Definition: X86BaseInfo.h:788
@ MRMSrcMemFSIB
MRMSrcMem - But force to use the SIB field.
Definition: X86BaseInfo.h:549
@ CompareFP
CompareFP - 2 arg FP instructions which implicitly read ST(0) and an explicit argument,...
Definition: X86BaseInfo.h:798
@ NoTrackShift
NOTRACK prefix.
Definition: X86BaseInfo.h:858
@ ExplicitVEXPrefix
For instructions that use VEX encoding only when {vex}, {vex2} or {vex3} is present.
Definition: X86BaseInfo.h:866
@ EVEX_RCShift
Explicitly specified rounding control.
Definition: X86BaseInfo.h:855
@ MRMSrcRegOp4
MRMSrcRegOp4 - This form is used for instructions that use the Mod/RM byte to specify the fourth sour...
Definition: X86BaseInfo.h:595
@ MRMXrCC
MRMXCCr - This form is used for instructions that use the Mod/RM byte to specify a register source,...
Definition: X86BaseInfo.h:602
@ T8
T8, TA - Prefix after the 0x0F prefix.
Definition: X86BaseInfo.h:737
@ MRMDestMemCC
MRMDestMemCC - This form is used for the cfcmov instructions, which use the Mod/RM byte to specify th...
Definition: X86BaseInfo.h:541
@ XOP9
XOP9 - Prefix to exclude use of imm byte.
Definition: X86BaseInfo.h:742
@ MRMXmCC
MRMXm - This form is used for instructions that use the Mod/RM byte to specify a memory source,...
Definition: X86BaseInfo.h:570
@ RawFrmImm16
RawFrmImm16 - This is used for CALL FAR instructions, which have two immediates, the first of which i...
Definition: X86BaseInfo.h:527
@ MRMSrcReg
MRMSrcReg - This form is used for instructions that use the Mod/RM byte to specify a source,...
Definition: X86BaseInfo.h:589
@ RawFrmSrc
RawFrmSrc - This form is for instructions that use the source index register SI/ESI/RSI with a possib...
Definition: X86BaseInfo.h:511
@ MRMDestReg
MRMDestReg - This form is used for instructions that use the Mod/RM byte to specify a destination,...
Definition: X86BaseInfo.h:586
@ MRMSrcMem
MRMSrcMem - This form is used for instructions that use the Mod/RM byte to specify a source,...
Definition: X86BaseInfo.h:557
@ MRMSrcMemOp4
MRMSrcMemOp4 - This form is used for instructions that use the Mod/RM byte to specify the fourth sour...
Definition: X86BaseInfo.h:563
@ Pseudo
PseudoFrm - This represents an instruction that is a pseudo instruction or one that has not been impl...
Definition: X86BaseInfo.h:499
@ VEX_4VShift
VEX_4V - Used to specify an additional AVX/SSE register.
Definition: X86BaseInfo.h:831
@ CD8_Scale_Shift
The scaling factor for the AVX512's 8-bit compressed displacement.
Definition: X86BaseInfo.h:852
@ MRMSrcRegCC
MRMSrcRegCC - This form is used for instructions that use the Mod/RM byte to specify the operands and...
Definition: X86BaseInfo.h:598
@ SSEDomainShift
Execution domain for SSE instructions.
Definition: X86BaseInfo.h:811
@ CondMovFP
CondMovFP - "2 operand" floating point conditional move instructions.
Definition: X86BaseInfo.h:800
@ MRM0m
MRM0m-MRM7m - Instructions that operate on a memory r/m operand and use reg field to hold extended op...
Definition: X86BaseInfo.h:576
@ ThreeDNow
ThreeDNow - This indicates that the instruction uses the wacky 0x0F 0x0F prefix for 3DNow!...
Definition: X86BaseInfo.h:751
@ XS
XS, XD - These prefix codes are for single and double precision scalar floating point operations perf...
Definition: X86BaseInfo.h:724
@ ExplicitOpPrefixMask
Definition: X86BaseInfo.h:869
@ FPTypeShift
FP Instruction Classification... Zero is non-fp instruction.
Definition: X86BaseInfo.h:781
@ XOPA
XOPA - Prefix to encode 0xA in VEX.MMMM of XOP instructions.
Definition: X86BaseInfo.h:744
@ MRMSrcReg4VOp3
MRMSrcReg4VOp3 - This form is used for instructions that encode operand 3 with VEX....
Definition: X86BaseInfo.h:592
@ OpMapShift
OpMap - This field determines which opcode map this instruction belongs to.
Definition: X86BaseInfo.h:729
@ LEGACY
LEGACY - encoding using REX/REX2 or w/o opcode prefix.
Definition: X86BaseInfo.h:816
@ RawFrmMemOffs
RawFrmMemOffs - This form is for instructions that store an absolute memory offset as an immediate wi...
Definition: X86BaseInfo.h:508
@ TwoArgFP
TwoArgFP - 2 arg FP instructions which implicitly read ST(0), and an explicit argument,...
Definition: X86BaseInfo.h:795
@ EVEX_NFShift
EVEX_NF - Set if this instruction has EVEX.NF field set.
Definition: X86BaseInfo.h:871
bool isImmSigned(uint64_t TSFlags)
Definition: X86BaseInfo.h:943
FirstMacroFusionInstKind classifyFirstOpcodeInMacroFusion(unsigned Opcode)
Definition: X86BaseInfo.h:126
@ OPERAND_COND_CODE
Definition: X86BaseInfo.h:72
@ OPERAND_ROUNDING_CONTROL
Definition: X86BaseInfo.h:71
@ LAST_VALID_COND
Definition: X86BaseInfo.h:94
AlignBranchBoundaryKind
Defines the possible values of the branch boundary alignment mask.
Definition: X86BaseInfo.h:309
@ AlignBranchJmp
Definition: X86BaseInfo.h:313
@ AlignBranchIndirect
Definition: X86BaseInfo.h:316
@ AlignBranchJcc
Definition: X86BaseInfo.h:312
@ AlignBranchCall
Definition: X86BaseInfo.h:314
@ AlignBranchRet
Definition: X86BaseInfo.h:315
@ AlignBranchNone
Definition: X86BaseInfo.h:310
@ AlignBranchFused
Definition: X86BaseInfo.h:311
STATIC_ROUNDING
AVX512 static rounding constants.
Definition: X86BaseInfo.h:41
@ TO_NEAREST_INT
Definition: X86BaseInfo.h:42
@ CUR_DIRECTION
Definition: X86BaseInfo.h:46
EncodingOfSegmentOverridePrefix
Defines the encoding values for segment override prefix.
Definition: X86BaseInfo.h:320
SecondMacroFusionInstKind
Definition: X86BaseInfo.h:116
@ AddrScaleAmt
Definition: X86BaseInfo.h:30
@ AddrSegmentReg
Definition: X86BaseInfo.h:34
@ AddrIndexReg
Definition: X86BaseInfo.h:31
@ AddrNumOperands
Definition: X86BaseInfo.h:36
FirstMacroFusionInstKind
Definition: X86BaseInfo.h:107
IPREFIXES
The constants to describe instr prefixes if there are.
Definition: X86BaseInfo.h:51
@ IP_HAS_NOTRACK
Definition: X86BaseInfo.h:58
@ IP_USE_DISP8
Definition: X86BaseInfo.h:65
@ IP_HAS_AD_SIZE
Definition: X86BaseInfo.h:54
@ IP_HAS_REPEAT
Definition: X86BaseInfo.h:56
@ IP_USE_DISP32
Definition: X86BaseInfo.h:66
@ IP_HAS_OP_SIZE
Definition: X86BaseInfo.h:53
@ IP_NO_PREFIX
Definition: X86BaseInfo.h:52
@ IP_HAS_REPEAT_NE
Definition: X86BaseInfo.h:55
SecondMacroFusionInstKind classifySecondCondCodeInMacroFusion(X86::CondCode CC)
Definition: X86BaseInfo.h:258
EncodingOfSegmentOverridePrefix getSegmentOverridePrefixForReg(unsigned Reg)
Given a segment register, return the encoding of the segment override prefix for it.
Definition: X86BaseInfo.h:332
bool isMacroFused(FirstMacroFusionInstKind FirstKind, SecondMacroFusionInstKind SecondKind)
Definition: X86BaseInfo.h:290
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Description of the encoding of one expression Op.