LLVM 24.0.0git
X86InstrInfo.h
Go to the documentation of this file.
1//===-- X86InstrInfo.h - X86 Instruction Information ------------*- 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 the X86 implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_X86_X86INSTRINFO_H
14#define LLVM_LIB_TARGET_X86_X86INSTRINFO_H
15
17#include "X86InstrFMA3Info.h"
18#include "X86RegisterInfo.h"
21#include <vector>
22
23#define GET_INSTRINFO_HEADER
24#include "X86GenInstrInfo.inc"
25
26namespace llvm {
27class X86Subtarget;
28
29// X86 MachineCombiner patterns
34
35namespace X86 {
36
38 // For instr that was compressed from EVEX to LEGACY.
40 // For instr that was compressed from EVEX to VEX.
42 // For instr that was compressed from EVEX to EVEX.
44};
45
46/// Return a pair of condition code for the given predicate and whether
47/// the instruction operands should be swaped to match the condition code.
48std::pair<CondCode, bool> getX86ConditionCode(CmpInst::Predicate Predicate);
49
50/// Return a cmov opcode for the given register size in bytes, and operand type.
51unsigned getCMovOpcode(unsigned RegBytes, bool HasMemoryOperand = false,
52 bool HasNDD = false);
53
54/// Return a MOVri opcode for materializing \p Imm into a 32- or 64-bit GPR.
55unsigned getMOVriOpcode(bool Use64BitReg, int64_t Imm);
56
57/// Return the source operand # for condition code by \p MCID. If the
58/// instruction doesn't have a condition code, return -1.
60
61/// Return the condition code of the instruction. If the instruction doesn't
62/// have a condition code, return X86::COND_INVALID.
63CondCode getCondFromMI(const MachineInstr &MI);
64
65// Turn JCC instruction into condition code.
66CondCode getCondFromBranch(const MachineInstr &MI);
67
68// Turn SETCC instruction into condition code.
69CondCode getCondFromSETCC(const MachineInstr &MI);
70
71// Turn CMOV instruction into condition code.
72CondCode getCondFromCMov(const MachineInstr &MI);
73
74// Turn condition code into condition flags for CCMP/CTEST.
76
77// Get the opcode of corresponding NF variant.
78unsigned getNFVariant(unsigned Opc);
79
80// If \p MI clobbers EFLAGS and that clobber can be removed by rewriting the
81// instruction to its NF (no-flags) variant, return that NF opcode; otherwise
82// return 0. The clobber is removable only if the EFLAGS def is dead, an NF
83// variant exists, and (for linker backward-compat) it is not an ADDrm/ADDmr
84// with relocation.
85unsigned
87 const TargetRegisterInfo *TRI = nullptr);
88
89// Get the opcode of corresponding NonND variant.
90unsigned getNonNDVariant(unsigned Opc);
91
92/// GetOppositeBranchCondition - Return the inverse of the specified cond,
93/// e.g. turning COND_E to COND_NE.
94CondCode GetOppositeBranchCondition(CondCode CC);
95
96/// Get the VPCMP immediate for the given condition.
98
99/// Get the VPCMP immediate if the opcodes are swapped.
100unsigned getSwappedVPCMPImm(unsigned Imm);
101
102/// Get the VPCOM immediate if the opcodes are swapped.
103unsigned getSwappedVPCOMImm(unsigned Imm);
104
105/// Get the VCMP immediate if the opcodes are swapped.
106unsigned getSwappedVCMPImm(unsigned Imm);
107
108/// Get the width of the vector register operand.
109unsigned getVectorRegisterWidth(const MCOperandInfo &Info);
110
111/// Check if the instruction is X87 instruction.
113
114/// Return the index of the instruction's first address operand, if it has a
115/// memory reference, or -1 if it has none. Unlike X86II::getMemoryOperandNo(),
116/// this also works for both pseudo instructions (e.g., TCRETURNmi) as well as
117/// real instructions (e.g., JMP64m).
119
120/// Find any constant pool entry associated with a specific instruction operand.
121const Constant *getConstantFromPool(const MachineInstr &MI, unsigned OpNo);
122
123} // namespace X86
124
125/// isGlobalStubReference - Return true if the specified TargetFlag operand is
126/// a reference to a stub for a global, not the global itself.
127inline static bool isGlobalStubReference(unsigned char TargetFlag) {
128 switch (TargetFlag) {
129 case X86II::MO_DLLIMPORT: // dllimport stub.
130 case X86II::MO_GOTPCREL: // rip-relative GOT reference.
131 case X86II::MO_GOTPCREL_NORELAX: // rip-relative GOT reference.
132 case X86II::MO_GOT: // normal GOT reference.
133 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Normal $non_lazy_ptr ref.
134 case X86II::MO_DARWIN_NONLAZY: // Normal $non_lazy_ptr ref.
135 case X86II::MO_COFFSTUB: // COFF .refptr stub.
136 return true;
137 default:
138 return false;
139 }
140}
141
142/// isGlobalRelativeToPICBase - Return true if the specified global value
143/// reference is relative to a 32-bit PIC base (X86ISD::GlobalBaseReg). If this
144/// is true, the addressing mode has the PIC base register added in (e.g. EBX).
145inline static bool isGlobalRelativeToPICBase(unsigned char TargetFlag) {
146 switch (TargetFlag) {
147 case X86II::MO_GOTOFF: // isPICStyleGOT: local global.
148 case X86II::MO_GOT: // isPICStyleGOT: other global.
149 case X86II::MO_PIC_BASE_OFFSET: // Darwin local global.
150 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Darwin/32 external global.
151 case X86II::MO_TLVP: // ??? Pretty sure..
152 return true;
153 default:
154 return false;
155 }
156}
157
158inline static bool isScale(const MachineOperand &MO) {
159 return MO.isImm() && (MO.getImm() == 1 || MO.getImm() == 2 ||
160 MO.getImm() == 4 || MO.getImm() == 8);
161}
162
163inline static bool isLeaMem(const MachineInstr &MI, unsigned Op) {
164 if (MI.getOperand(Op).isFI())
165 return true;
166 return Op + X86::AddrSegmentReg <= MI.getNumOperands() &&
167 MI.getOperand(Op + X86::AddrBaseReg).isReg() &&
168 isScale(MI.getOperand(Op + X86::AddrScaleAmt)) &&
169 MI.getOperand(Op + X86::AddrIndexReg).isReg() &&
170 (MI.getOperand(Op + X86::AddrDisp).isImm() ||
171 MI.getOperand(Op + X86::AddrDisp).isGlobal() ||
172 MI.getOperand(Op + X86::AddrDisp).isCPI() ||
173 MI.getOperand(Op + X86::AddrDisp).isJTI());
174}
175
176inline static bool isMem(const MachineInstr &MI, unsigned Op) {
177 if (MI.getOperand(Op).isFI())
178 return true;
179 return Op + X86::AddrNumOperands <= MI.getNumOperands() &&
180 MI.getOperand(Op + X86::AddrSegmentReg).isReg() && isLeaMem(MI, Op);
181}
182
183inline static bool isAddMemInstrWithRelocation(const MachineInstr &MI) {
184 unsigned Op = MI.getOpcode();
185 if (Op == X86::ADD64rm || Op == X86::ADD64mr_ND || Op == X86::ADD64rm_ND) {
186 int MemOpNo = X86II::getMemoryOperandIdx(MI.getDesc());
187 assert(MemOpNo >= 0 && "Expected a memory operand");
188 const MachineOperand &MO = MI.getOperand(X86::AddrDisp + MemOpNo);
190 return true;
191 }
192
193 return false;
194}
195
196inline static bool isMemInstrWithGOTPCREL(const MachineInstr &MI) {
197 unsigned Op = MI.getOpcode();
198 switch (Op) {
199 case X86::TEST32mr:
200 case X86::TEST64mr:
201 case X86::CMP32rm:
202 case X86::CMP64rm:
203 case X86::MOV32rm:
204 case X86::MOV64rm:
205 case X86::ADC32rm:
206 case X86::ADD32rm:
207 case X86::AND32rm:
208 case X86::OR32rm:
209 case X86::SBB32rm:
210 case X86::SUB32rm:
211 case X86::XOR32rm:
212 case X86::ADC64rm:
213 case X86::ADD64rm:
214 case X86::AND64rm:
215 case X86::OR64rm:
216 case X86::SBB64rm:
217 case X86::SUB64rm:
218 case X86::XOR64rm: {
219 int MemOpNo = X86II::getMemoryOperandIdx(MI.getDesc());
220 assert(MemOpNo >= 0 && "Expected a memory operand");
221 const MachineOperand &MO = MI.getOperand(X86::AddrDisp + MemOpNo);
223 return true;
224 break;
225 }
226 }
227 return false;
228}
229
230class X86InstrInfo final : public X86GenInstrInfo {
231 const X86Subtarget &Subtarget;
232 const X86RegisterInfo RI;
233
235
236 bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
237 MachineBasicBlock *&FBB,
240 bool AllowModify) const;
241
242 bool foldImmediateImpl(MachineInstr &UseMI, MachineInstr *DefMI, Register Reg,
243 int64_t ImmVal, MachineRegisterInfo *MRI,
244 bool MakeChange) const;
245
246public:
247 explicit X86InstrInfo(const X86Subtarget &STI);
248
249 /// Given a machine instruction descriptor, returns the register
250 /// class constraint for OpNum, or NULL. Returned register class
251 /// may be different from the definition in the TD file, e.g.
252 /// GR*RegClass (definition in TD file)
253 /// ->
254 /// GR*_NOREX2RegClass (Returned register class)
256 unsigned OpNum) const override;
257
258 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
259 /// such, whenever a client has an instance of instruction info, it should
260 /// always be able to get register info as well (through this method).
261 ///
262 const X86RegisterInfo &getRegisterInfo() const { return RI; }
263
264 const TargetRegisterClass *
266
267 /// Returns the stack pointer adjustment that happens inside the frame
268 /// setup..destroy sequence (e.g. by pushes, or inside the callee).
269 int64_t getFrameAdjustment(const MachineInstr &I) const {
270 assert(isFrameInstr(I));
271 if (isFrameSetup(I))
272 return I.getOperand(2).getImm();
273 return I.getOperand(1).getImm();
274 }
275
276 /// Sets the stack pointer adjustment made inside the frame made up by this
277 /// instruction.
278 void setFrameAdjustment(MachineInstr &I, int64_t V) const {
279 assert(isFrameInstr(I));
280 if (isFrameSetup(I))
281 I.getOperand(2).setImm(V);
282 else
283 I.getOperand(1).setImm(V);
284 }
285
286 /// getSPAdjust - This returns the stack pointer adjustment made by
287 /// this instruction. For x86, we need to handle more complex call
288 /// sequences involving PUSHes.
289 int getSPAdjust(const MachineInstr &MI) const override;
290
291 /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
292 /// extension instruction. That is, it's like a copy where it's legal for the
293 /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
294 /// true, then it's expected the pre-extension value is available as a subreg
295 /// of the result register. This also returns the sub-register index in
296 /// SubIdx.
297 bool isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg,
298 Register &DstReg, unsigned &SubIdx) const override;
299
300 /// Returns true if the instruction has no behavior (specified or otherwise)
301 /// that is based on the value of any of its register operands
302 ///
303 /// Instructions are considered data invariant even if they set EFLAGS.
304 ///
305 /// A classical example of something that is inherently not data invariant is
306 /// an indirect jump -- the destination is loaded into icache based on the
307 /// bits set in the jump destination register.
308 ///
309 /// FIXME: This should become part of our instruction tables.
310 static bool isDataInvariant(MachineInstr &MI);
311
312 /// Returns true if the instruction has no behavior (specified or otherwise)
313 /// that is based on the value loaded from memory or the value of any
314 /// non-address register operands.
315 ///
316 /// For example, if the latency of the instruction is dependent on the
317 /// particular bits set in any of the registers *or* any of the bits loaded
318 /// from memory.
319 ///
320 /// Instructions are considered data invariant even if they set EFLAGS.
321 ///
322 /// A classical example of something that is inherently not data invariant is
323 /// an indirect jump -- the destination is loaded into icache based on the
324 /// bits set in the jump destination register.
325 ///
326 /// FIXME: This should become part of our instruction tables.
327 static bool isDataInvariantLoad(MachineInstr &MI);
328
330 int &FrameIndex) const override;
332 int &FrameIndex,
333 TypeSize &MemBytes) const override;
334 /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
335 /// stack locations as well. This uses a heuristic so it isn't
336 /// reliable for correctness.
338 int &FrameIndex) const override;
339
341 int &FrameIndex) const override;
343 int &FrameIndex,
344 TypeSize &MemBytes) const override;
345 /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
346 /// stack locations as well. This uses a heuristic so it isn't
347 /// reliable for correctness.
349 int &FrameIndex) const override;
350
351 bool isReMaterializableImpl(const MachineInstr &MI) const override;
352 void
354 Register DestReg, unsigned SubIdx, const MachineInstr &Orig,
355 LaneBitmask UsedLanes = LaneBitmask::getAll()) const override;
356
357 /// Given an operand within a MachineInstr, insert preceding code to put it
358 /// into the right format for a particular kind of LEA instruction. This may
359 /// involve using an appropriate super-register instead (with an implicit use
360 /// of the original) or creating a new virtual register and inserting COPY
361 /// instructions to get the data into the right class.
362 ///
363 /// Reference parameters are set to indicate how caller should add this
364 /// operand to the LEA instruction.
366 unsigned LEAOpcode, bool AllowSP, Register &NewSrc,
367 unsigned &NewSrcSubReg, bool &isKill,
368 MachineOperand &ImplicitOp, LiveIntervals *LIS) const;
369
370 /// convertToThreeAddress - This method must be implemented by targets that
371 /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
372 /// may be able to convert a two-address instruction into a true
373 /// three-address instruction on demand. This allows the X86 target (for
374 /// example) to convert ADD and SHL instructions into LEA instructions if they
375 /// would require register copies due to two-addressness.
376 ///
377 /// This method returns a null pointer if the transformation cannot be
378 /// performed, otherwise it returns the new instruction.
379 ///
381 LiveIntervals *LIS) const override;
382
383 /// Returns true iff the routine could find two commutable operands in the
384 /// given machine instruction.
385 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
386 /// input values can be re-defined in this method only if the input values
387 /// are not pre-defined, which is designated by the special value
388 /// 'CommuteAnyOperandIndex' assigned to it.
389 /// If both of indices are pre-defined and refer to some operands, then the
390 /// method simply returns true if the corresponding operands are commutable
391 /// and returns false otherwise.
392 ///
393 /// For example, calling this method this way:
394 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
395 /// findCommutedOpIndices(MI, Op1, Op2);
396 /// can be interpreted as a query asking to find an operand that would be
397 /// commutable with the operand#1.
398 bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1,
399 unsigned &SrcOpIdx2) const override;
400
401 /// Returns true if we have preference on the operands order in MI, the
402 /// commute decision is returned in Commute.
403 bool hasCommutePreference(MachineInstr &MI, bool &Commute) const override;
404
405 /// Returns an adjusted FMA opcode that must be used in FMA instruction that
406 /// performs the same computations as the given \p MI but which has the
407 /// operands \p SrcOpIdx1 and \p SrcOpIdx2 commuted.
408 /// It may return 0 if it is unsafe to commute the operands.
409 /// Note that a machine instruction (instead of its opcode) is passed as the
410 /// first parameter to make it possible to analyze the instruction's uses and
411 /// commute the first operand of FMA even when it seems unsafe when you look
412 /// at the opcode. For example, it is Ok to commute the first operand of
413 /// VFMADD*SD_Int, if ONLY the lowest 64-bit element of the result is used.
414 ///
415 /// The returned FMA opcode may differ from the opcode in the given \p MI.
416 /// For example, commuting the operands #1 and #3 in the following FMA
417 /// FMA213 #1, #2, #3
418 /// results into instruction with adjusted opcode:
419 /// FMA231 #3, #2, #1
420 unsigned
421 getFMA3OpcodeToCommuteOperands(const MachineInstr &MI, unsigned SrcOpIdx1,
422 unsigned SrcOpIdx2,
423 const X86InstrFMA3Group &FMA3Group) const;
424
425 // Branch analysis.
426 bool isUnconditionalTailCall(const MachineInstr &MI) const override;
428 const MachineInstr &TailCall) const override;
431 const MachineInstr &TailCall) const override;
432
434 MachineBasicBlock *&FBB,
436 bool AllowModify) const override;
437
438 int getJumpTableIndex(const MachineInstr &MI) const override;
439
440 std::optional<ExtAddrMode>
441 getAddrModeFromMemoryOp(const MachineInstr &MemI) const override;
442
444 int64_t &ImmVal) const override;
445
447 const Register NullValueReg) const override;
448
450 const MachineInstr &LdSt,
452 bool &OffsetIsScalable, LocationSize &Width) const override;
455 bool AllowModify = false) const override;
456
458 int *BytesRemoved = nullptr) const override;
461 const DebugLoc &DL,
462 int *BytesAdded = nullptr) const override;
465 SelectExpansion &) const override;
467 const DebugLoc &DL, Register DstReg,
469 Register FalseReg) const override;
471 const DebugLoc &DL, Register DestReg, Register SrcReg,
472 bool KillSrc, bool RenamableDest = false,
473 bool RenamableSrc = false) const override;
476 bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg,
477 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
478
481 int FrameIndex, const TargetRegisterClass *RC, Register VReg,
482 unsigned SubReg = 0,
483 MachineInstr::MIFlag Flags = MachineInstr::NoFlags) const override;
484
486 unsigned Opc, Register Reg, int FrameIdx,
487 bool isKill = false) const;
488
489 bool expandPostRAPseudo(MachineInstr &MI) const override;
490
491 /// Check whether the target can fold a load that feeds a subreg operand
492 /// (or a subreg operand that feeds a store).
493 bool isSubregFoldable() const override { return true; }
494
495 /// Fold a load or store of the specified stack slot into the specified
496 /// machine instruction for the specified operand(s). If folding happens, it
497 /// is likely that the referenced instruction has been changed.
498 ///
499 /// \returns true on success.
501 ArrayRef<unsigned> Ops, int FrameIndex,
502 MachineInstr *&CopyMI,
503 LiveIntervals *LIS = nullptr,
504 VirtRegMap *VRM = nullptr) const override;
505
506 /// Same as the previous version except it allows folding of any load and
507 /// store from / to any address, not just from a specific stack slot.
510 MachineInstr &LoadMI,
511 MachineInstr *&CopyMI,
512 LiveIntervals *LIS = nullptr,
513 VirtRegMap *VRM = nullptr) const override;
514
515 bool
517 bool UnfoldLoad, bool UnfoldStore,
518 SmallVectorImpl<MachineInstr *> &NewMIs) const override;
519
521 SmallVectorImpl<SDNode *> &NewNodes) const override;
522
523 unsigned
524 getOpcodeAfterMemoryUnfold(unsigned Opc, bool UnfoldLoad, bool UnfoldStore,
525 unsigned *LoadRegIndex = nullptr) const override;
526
527 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1,
528 int64_t &Offset2) const override;
529
530 /// Overrides the isSchedulingBoundary from Codegen/TargetInstrInfo.cpp to
531 /// make it capable of identifying ENDBR instructions and prevent it from
532 /// being re-scheduled.
534 const MachineBasicBlock *MBB,
535 const MachineFunction &MF) const override;
536
537 /// This is a used by the pre-regalloc scheduler to determine (in conjunction
538 /// with areLoadsFromSameBasePtr) if two loads should be scheduled togther. On
539 /// some targets if two loads are loading from addresses in the same cache
540 /// line, it's better if they are scheduled together. This function takes two
541 /// integers that represent the load offsets from the common base address. It
542 /// returns true if it decides it's desirable to schedule the two loads
543 /// together. "NumLoads" is the number of loads that have already been
544 /// scheduled after Load1.
545 bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2, int64_t Offset1,
546 int64_t Offset2,
547 unsigned NumLoads) const override;
548
550 MachineBasicBlock::iterator MI) const override;
551
552 MCInst getNop() const override;
553
554 bool
556
557 bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const override;
558
559 /// True if MI has a condition code def, e.g. EFLAGS, that is
560 /// not marked dead.
562
563 /// getGlobalBaseReg - Return a virtual register initialized with the
564 /// the global base register value. Output instructions required to
565 /// initialize the register in the function entry block, if necessary.
566 ///
568
569 std::pair<uint16_t, uint16_t>
570 getExecutionDomain(const MachineInstr &MI) const override;
571
573
574 void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override;
575
576 bool setExecutionDomainCustom(MachineInstr &MI, unsigned Domain) const;
577
579 unsigned OpNum) const override;
580 unsigned getUndefRegClearance(const MachineInstr &MI,
581 unsigned OpNum) const override;
583 unsigned OpNum) const override;
584
586 unsigned OpNum,
589 unsigned Size, Align Alignment,
590 bool AllowCommute, MachineInstr *&CopyMI,
591 VirtRegMap *VRM = nullptr) const;
592
593 bool isHighLatencyDef(int opc) const override;
594
595 bool hasHighOperandLatency(const TargetSchedModel &SchedModel,
597 const MachineInstr &DefMI, unsigned DefIdx,
598 const MachineInstr &UseMI,
599 unsigned UseIdx) const override;
600
601 bool useMachineCombiner() const override { return true; }
602
604 bool Invert) const override;
605
606 bool hasReassociableOperands(const MachineInstr &Inst,
607 const MachineBasicBlock *MBB) const override;
608
609 void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2,
610 MachineInstr &NewMI1,
611 MachineInstr &NewMI2) const override;
612
613 bool analyzeCompare(const MachineInstr &MI, Register &SrcReg,
614 Register &SrcReg2, int64_t &CmpMask,
615 int64_t &CmpValue) const override;
616
617 /// Check if there exists an earlier instruction that operates on the same
618 /// source operands and sets eflags in the same way as CMP and remove CMP if
619 /// possible.
620 bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
621 Register SrcReg2, int64_t CmpMask, int64_t CmpValue,
622 const MachineRegisterInfo *MRI) const override;
623
625 MachineRegisterInfo *MRI) const override;
626
627 std::pair<unsigned, unsigned>
628 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
629
632
633 std::optional<std::unique_ptr<outliner::OutlinedFunction>>
635 const MachineModuleInfo &MMI,
636 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
637 unsigned MinRepeats) const override;
638
640 bool OutlineFromLinkOnceODRs) const override;
641
644 unsigned Flags) const override;
645
647 const outliner::OutlinedFunction &OF) const override;
648
652 outliner::Candidate &C) const override;
653
656 bool AllowSideEffects = true) const override;
657
659 StringRef &ErrInfo) const override;
660#define GET_INSTRINFO_HELPER_DECLS
661#include "X86GenInstrInfo.inc"
662
663 static bool hasLockPrefix(const MachineInstr &MI) {
664 return MI.getDesc().TSFlags & X86II::LOCK;
665 }
666
667 std::optional<ParamLoadedValue>
668 describeLoadedValue(const MachineInstr &MI, Register Reg) const override;
669
670protected:
672 unsigned CommuteOpIdx1,
673 unsigned CommuteOpIdx2) const override;
674
675 std::optional<DestSourcePair>
676 isCopyInstrImpl(const MachineInstr &MI) const override;
677
680 bool DoRegPressureReduce) const override;
681
682 /// When getMachineCombinerPatterns() finds potential patterns,
683 /// this function generates the instructions that could replace the
684 /// original code sequence.
686 MachineInstr &Root, unsigned Pattern,
689 DenseMap<Register, unsigned> &InstrIdxForVirtReg) const override;
690
691 /// When calculate the latency of the root instruction, accumulate the
692 /// latency of the sequence to the root latency.
693 /// \param Root - Instruction that could be combined with one of its operands
694 /// For X86 instruction (vpmaddwd + vpmaddwd) -> vpdpwssd, the vpmaddwd
695 /// is not in the critical path, so the root latency only include vpmaddwd.
697 return false;
698 }
699
701 int FI) const override;
702
703private:
704 /// This is a helper for convertToThreeAddress for 8 and 16-bit instructions.
705 /// We use 32-bit LEA to form 3-address code by promoting to a 32-bit
706 /// super-register and then truncating back down to a 8/16-bit sub-register.
707 MachineInstr *convertToThreeAddressWithLEA(unsigned MIOpc, MachineInstr &MI,
708 LiveIntervals *LIS,
709 bool Is8BitOp) const;
710
711 /// Handles memory folding for special case instructions, for instance those
712 /// requiring custom manipulation of the address.
713 MachineInstr *foldMemoryOperandCustom(MachineFunction &MF, MachineInstr &MI,
714 unsigned OpNum,
717 unsigned Size, Align Alignment) const;
718
719 MachineInstr *foldMemoryBroadcast(MachineFunction &MF, MachineInstr &MI,
720 unsigned OpNum,
723 unsigned BitsSize, bool AllowCommute) const;
724
725 /// isFrameOperand - Return true and the FrameIndex if the specified
726 /// operand and follow operands form a reference to the stack frame.
727 bool isFrameOperand(const MachineInstr &MI, unsigned int Op,
728 int &FrameIndex) const;
729
730 /// Returns true iff the routine could find two commutable operands in the
731 /// given machine instruction with 3 vector inputs.
732 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
733 /// input values can be re-defined in this method only if the input values
734 /// are not pre-defined, which is designated by the special value
735 /// 'CommuteAnyOperandIndex' assigned to it.
736 /// If both of indices are pre-defined and refer to some operands, then the
737 /// method simply returns true if the corresponding operands are commutable
738 /// and returns false otherwise.
739 ///
740 /// For example, calling this method this way:
741 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
742 /// findThreeSrcCommutedOpIndices(MI, Op1, Op2);
743 /// can be interpreted as a query asking to find an operand that would be
744 /// commutable with the operand#1.
745 ///
746 /// If IsIntrinsic is set, operand 1 will be ignored for commuting.
747 bool findThreeSrcCommutedOpIndices(const MachineInstr &MI,
748 unsigned &SrcOpIdx1,
749 unsigned &SrcOpIdx2,
750 bool IsIntrinsic = false) const;
751
752 /// Returns true when instruction \p FlagI produces the same flags as \p OI.
753 /// The caller should pass in the results of calling analyzeCompare on \p OI:
754 /// \p SrcReg, \p SrcReg2, \p ImmMask, \p ImmValue.
755 /// If the flags match \p OI as if it had the input operands swapped then the
756 /// function succeeds and sets \p IsSwapped to true.
757 ///
758 /// Examples of OI, FlagI pairs returning true:
759 /// CMP %1, 42 and CMP %1, 42
760 /// CMP %1, %2 and %3 = SUB %1, %2
761 /// TEST %1, %1 and %2 = SUB %1, 0
762 /// CMP %1, %2 and %3 = SUB %2, %1 ; IsSwapped=true
763 bool isRedundantFlagInstr(const MachineInstr &FlagI, Register SrcReg,
764 Register SrcReg2, int64_t ImmMask, int64_t ImmValue,
765 const MachineInstr &OI, bool *IsSwapped,
766 int64_t *ImmDelta) const;
767
768 /// Used by optimizeCompareInstr when the backward search for an equivalent
769 /// flag producer reaches a block (\p MultiPredMBB) with multiple
770 /// predecessors. Searches the dominator tree for an instruction that produces
771 /// the same flags as the compare \p CmpInstr and dominates it, such that on
772 /// every path from that producer to \p CmpInstr all EFLAGS clobbers can be
773 /// converted to their NF (no-flags) variants. Those clobbers are appended to
774 /// \p InstsToUpdate as (instruction, NF opcode) pairs for the caller to
775 /// rewrite. Restricted to producers that yield identical flags: it succeeds
776 /// only when isRedundantFlagInstr reports no operand swap and no immediate
777 /// delta, so on success \p IsSwapped is false and \p ImmDelta is 0. Returns
778 /// the flag producer on success, or nullptr otherwise. Requires the NF
779 /// feature (APX).
780 MachineInstr *findDominatingRedundantFlagInstr(
781 MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2,
782 int64_t CmpMask, int64_t CmpValue, MachineBasicBlock *MultiPredMBB,
783 bool &IsSwapped, int64_t &ImmDelta,
784 SmallVectorImpl<std::pair<MachineInstr *, unsigned>> &InstsToUpdate)
785 const;
786
787 /// Commute operands of \p MI for memory fold.
788 ///
789 /// \param Idx1 the index of operand to be commuted.
790 ///
791 /// \returns the index of operand that is commuted with \p Idx1. If the method
792 /// fails to commute the operands, it will return \p Idx1.
793 unsigned commuteOperandsForFold(MachineInstr &MI, unsigned Idx1) const;
794
796 insertCodePrefetchInstr(MachineBasicBlock &MBB,
797 MachineBasicBlock::iterator InsertBefore,
798 const GlobalValue *GV) const override;
799};
800} // namespace llvm
801
802#endif
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
static bool isRedundantFlagInstr(const MachineInstr *CmpI, Register SrcReg, Register SrcReg2, int64_t ImmValue, const MachineInstr *OI, bool &IsThumb1)
isRedundantFlagInstr - check whether the first instruction, whose only purpose is to update flags,...
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION()
\macro LLVM_VIRTUAL_ANCHOR_FUNCTION This macro is used to adhere to LLVM's policy that each class wit...
Definition Compiler.h:801
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
SmallVector< MachineOperand, 4 > Cond
RISCVCC::CondCode CC
MachineRegisterInfo & MRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
This is an important base class in LLVM.
Definition Constant.h:44
A debug info location.
Definition DebugLoc.h:127
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Describe properties that are true of each instruction in the target description file.
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:88
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
This class contains meta information specific to a module.
MachineOperand class - Representation of each machine instruction operand.
int64_t getImm() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned getTargetFlags() const
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Represents one node in the SelectionDAG.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
bool accumulateInstrSeqToRootLatency(MachineInstr &Root) const override
When calculate the latency of the root instruction, accumulate the latency of the sequence to the roo...
void getFrameIndexOperands(SmallVectorImpl< MachineOperand > &Ops, int FI) const override
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2, int64_t CmpMask, int64_t CmpValue, const MachineRegisterInfo *MRI) const override
Check if there exists an earlier instruction that operates on the same source operands and sets eflag...
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
Overrides the isSchedulingBoundary from Codegen/TargetInstrInfo.cpp to make it capable of identifying...
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI) const override
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, outliner::Candidate &C) const override
void replaceBranchWithTailCall(MachineBasicBlock &MBB, SmallVectorImpl< MachineOperand > &Cond, const MachineInstr &TailCall) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
unsigned getOpcodeAfterMemoryUnfold(unsigned Opc, bool UnfoldLoad, bool UnfoldStore, unsigned *LoadRegIndex=nullptr) const override
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
Returns true iff the routine could find two commutable operands in the given machine instruction.
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
X86InstrInfo(const X86Subtarget &STI)
static bool isDataInvariantLoad(MachineInstr &MI)
Returns true if the instruction has no behavior (specified or otherwise) that is based on the value l...
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned CommuteOpIdx1, unsigned CommuteOpIdx2) const override
bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override
const X86RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
bool hasCommutePreference(MachineInstr &MI, bool &Commute) const override
Returns true if we have preference on the operands order in MI, the commute decision is returned in C...
bool hasLiveCondCodeDef(MachineInstr &MI) const
True if MI has a condition code def, e.g.
std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const override
bool canMakeTailCallConditional(SmallVectorImpl< MachineOperand > &Cond, const MachineInstr &TailCall) const override
bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr &MI, Register Reg, bool UnfoldLoad, bool UnfoldStore, SmallVectorImpl< MachineInstr * > &NewMIs) const override
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
bool preservesZeroValueInReg(const MachineInstr *MI, const Register NullValueReg) const override
static bool hasLockPrefix(const MachineInstr &MI)
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
MCInst getNop() const override
Return the noop instruction to use for a noop.
outliner::InstrType getOutliningTypeImpl(const MachineModuleInfo &MMI, MachineBasicBlock::iterator &MIT, unsigned Flags) const override
const TargetRegisterClass * getInlineAsmMemoryOperandRegClass(InlineAsm::ConstraintCode C) const override
bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2, int64_t Offset1, int64_t Offset2, unsigned NumLoads) const override
This is a used by the pre-regalloc scheduler to determine (in conjunction with areLoadsFromSameBasePt...
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &CmpMask, int64_t &CmpValue) const override
bool getConstValDefinedInReg(const MachineInstr &MI, const Register Reg, int64_t &ImmVal) const override
Register isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlotPostFE - Check for post-frame ptr elimination stack locations as well.
const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum) const override
Given a machine instruction descriptor, returns the register class constraint for OpNum,...
bool isUnconditionalTailCall(const MachineInstr &MI) const override
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, unsigned SubIdx, const MachineInstr &Orig, LaneBitmask UsedLanes=LaneBitmask::getAll()) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
std::optional< std::unique_ptr< outliner::OutlinedFunction > > getOutliningCandidateInfo(const MachineModuleInfo &MMI, std::vector< outliner::Candidate > &RepeatedSequenceLocs, unsigned MinRepeats) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &LdSt, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) const override
Register isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlotPostFE - Check for post-frame ptr elimination stack locations as well.
void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override
bool useMachineCombiner() const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool setExecutionDomainCustom(MachineInstr &MI, unsigned Domain) const
unsigned getPartialRegUpdateClearance(const MachineInstr &MI, unsigned OpNum) const override
Inform the BreakFalseDeps pass how many idle instructions we would like before a partial register upd...
int getSPAdjust(const MachineInstr &MI) const override
getSPAdjust - This returns the stack pointer adjustment made by this instruction.
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, SelectExpansion &) const override
bool isReMaterializableImpl(const MachineInstr &MI) const override
Register getGlobalBaseReg(MachineFunction *MF) const
getGlobalBaseReg - Return a virtual register initialized with the the global base register value.
int getJumpTableIndex(const MachineInstr &MI) const override
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2, MachineInstr &NewMI1, MachineInstr &NewMI2) const override
This is an architecture-specific helper function of reassociateOps.
void setFrameAdjustment(MachineInstr &I, int64_t V) const
Sets the stack pointer adjustment made inside the frame made up by this instruction.
std::pair< uint16_t, uint16_t > getExecutionDomain(const MachineInstr &MI) const override
bool isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg, Register &DstReg, unsigned &SubIdx) const override
isCoalescableExtInstr - Return true if the instruction is a "coalescable" extension instruction.
void loadStoreTileReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Opc, Register Reg, int FrameIdx, bool isKill=false) const
void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds potential patterns, this function generates the instructions ...
bool hasReassociableOperands(const MachineInstr &Inst, const MachineBasicBlock *MBB) const override
bool analyzeBranchPredicate(MachineBasicBlock &MBB, TargetInstrInfo::MachineBranchPredicate &MBP, bool AllowModify=false) const override
static bool isDataInvariant(MachineInstr &MI)
Returns true if the instruction has no behavior (specified or otherwise) that is based on the value o...
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
Fold a load or store of the specified stack slot into the specified machine instruction for the speci...
void buildClearRegister(Register Reg, MachineBasicBlock &MBB, MachineBasicBlock::iterator Iter, DebugLoc &DL, bool AllowSideEffects=true) const override
unsigned getUndefRegClearance(const MachineInstr &MI, unsigned OpNum) const override
Inform the BreakFalseDeps pass how many idle instructions we would like before certain undef register...
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
int64_t getFrameAdjustment(const MachineInstr &I) const
Returns the stack pointer adjustment that happens inside the frame setup..destroy sequence (e....
void breakPartialRegDependency(MachineInstr &MI, unsigned OpNum) const override
bool hasHighOperandLatency(const TargetSchedModel &SchedModel, const MachineRegisterInfo *MRI, const MachineInstr &DefMI, unsigned DefIdx, const MachineInstr &UseMI, unsigned UseIdx) const override
bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const override
bool isSubregFoldable() const override
Check whether the target can fold a load that feeds a subreg operand (or a subreg operand that feeds ...
bool classifyLEAReg(MachineInstr &MI, const MachineOperand &Src, unsigned LEAOpcode, bool AllowSP, Register &NewSrc, unsigned &NewSrcSubReg, bool &isKill, MachineOperand &ImplicitOp, LiveIntervals *LIS) const
Given an operand within a MachineInstr, insert preceding code to put it into the right format for a p...
uint16_t getExecutionDomainCustom(const MachineInstr &MI) const
bool isHighLatencyDef(int opc) const override
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const override
bool foldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg, MachineRegisterInfo *MRI) const override
foldImmediate - 'Reg' is known to be defined by a move immediate instruction, try to fold the immedia...
MachineInstr * convertToThreeAddress(MachineInstr &MI, LiveIntervals *LIS) const override
convertToThreeAddress - This method must be implemented by targets that set the M_CONVERTIBLE_TO_3_AD...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
unsigned getFMA3OpcodeToCommuteOperands(const MachineInstr &MI, unsigned SrcOpIdx1, unsigned SrcOpIdx2, const X86InstrFMA3Group &FMA3Group) const
Returns an adjusted FMA opcode that must be used in FMA instruction that performs the same computatio...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
@ MO_GOTPCREL_NORELAX
MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...
@ MO_GOTOFF
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
@ MO_DARWIN_NONLAZY_PIC_BASE
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
@ MO_DARWIN_NONLAZY
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
@ MO_GOT
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
@ MO_TLVP
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
@ MO_GOTTPOFF
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
@ MO_PIC_BASE_OFFSET
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
@ MO_GOTPCREL
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
int getMemoryOperandIdx(const MCInstrDesc &Desc)
CondCode getCondFromBranch(const MachineInstr &MI)
CondCode getCondFromMI(const MachineInstr &MI)
Return the condition code of the instruction.
int getFirstAddrOperandIdx(const MachineInstr &MI)
Return the index of the instruction's first address operand, if it has a memory reference,...
@ AddrNumOperands
Definition X86BaseInfo.h:37
unsigned getSwappedVCMPImm(unsigned Imm)
Get the VCMP immediate if the opcodes are swapped.
CondCode GetOppositeBranchCondition(CondCode CC)
GetOppositeBranchCondition - Return the inverse of the specified cond, e.g.
unsigned getSwappedVPCOMImm(unsigned Imm)
Get the VPCOM immediate if the opcodes are swapped.
bool isX87Instruction(MachineInstr &MI)
Check if the instruction is X87 instruction.
unsigned getNonNDVariant(unsigned Opc)
unsigned getVPCMPImmForCond(ISD::CondCode CC)
Get the VPCMP immediate for the given condition.
std::pair< CondCode, bool > getX86ConditionCode(CmpInst::Predicate Predicate)
Return a pair of condition code for the given predicate and whether the instruction operands should b...
CondCode getCondFromSETCC(const MachineInstr &MI)
unsigned getSwappedVPCMPImm(unsigned Imm)
Get the VPCMP immediate if the opcodes are swapped.
int getCCMPCondFlagsFromCondCode(CondCode CC)
int getCondSrcNoFromDesc(const MCInstrDesc &MCID)
Return the source operand # for condition code by MCID.
const Constant * getConstantFromPool(const MachineInstr &MI, unsigned OpNo)
Find any constant pool entry associated with a specific instruction operand.
unsigned getNFVariantIfClobberRemovable(const MachineInstr &MI, const TargetRegisterInfo *TRI=nullptr)
unsigned getMOVriOpcode(bool Use64BitReg, int64_t Imm)
Return a MOVri opcode for materializing Imm into a 32- or 64-bit GPR.
unsigned getCMovOpcode(unsigned RegBytes, bool HasMemoryOperand=false, bool HasNDD=false)
Return a cmov opcode for the given register size in bytes, and operand type.
unsigned getNFVariant(unsigned Opc)
unsigned getVectorRegisterWidth(const MCOperandInfo &Info)
Get the width of the vector register operand.
CondCode getCondFromCMov(const MachineInstr &MI)
InstrType
Represents how an instruction should be mapped by the outliner.
This is an optimization pass for GlobalISel generic memory operations.
static bool isGlobalStubReference(unsigned char TargetFlag)
isGlobalStubReference - Return true if the specified TargetFlag operand is a reference to a stub for ...
@ Offset
Definition DWP.cpp:577
static bool isGlobalRelativeToPICBase(unsigned char TargetFlag)
isGlobalRelativeToPICBase - Return true if the specified global value reference is relative to a 32-b...
static bool isAddMemInstrWithRelocation(const MachineInstr &MI)
static bool isMem(const MachineInstr &MI, unsigned Op)
static bool isScale(const MachineOperand &MO)
static bool isMemInstrWithGOTPCREL(const MachineInstr &MI)
static bool isLeaMem(const MachineInstr &MI, unsigned Op)
DWARFExpression::Operation Op
X86MachineCombinerPattern
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
static constexpr LaneBitmask getAll()
Definition LaneBitmask.h:82
Represents a predicate at the MachineFunction level.
This class is used to group {132, 213, 231} forms of FMA opcodes together.
An individual sequence of instructions to be replaced with a call to an outlined function.
The information necessary to create an outlined function for some class of candidate.