LLVM  16.0.0git
TargetInstrInfo.cpp
Go to the documentation of this file.
1 //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===//
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 implements the TargetInstrInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/StringExtras.h"
24 #include "llvm/CodeGen/StackMaps.h"
29 #include "llvm/IR/DataLayout.h"
31 #include "llvm/MC/MCAsmInfo.h"
36 
37 using namespace llvm;
38 
40  "disable-sched-hazard", cl::Hidden, cl::init(false),
41  cl::desc("Disable hazard detection during preRA scheduling"));
42 
44 
46 TargetInstrInfo::getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
47  const TargetRegisterInfo *TRI,
48  const MachineFunction &MF) const {
49  if (OpNum >= MCID.getNumOperands())
50  return nullptr;
51 
52  short RegClass = MCID.OpInfo[OpNum].RegClass;
53  if (MCID.OpInfo[OpNum].isLookupPtrRegClass())
54  return TRI->getPointerRegClass(MF, RegClass);
55 
56  // Instructions like INSERT_SUBREG do not have fixed register classes.
57  if (RegClass < 0)
58  return nullptr;
59 
60  // Otherwise just look it up normally.
61  return TRI->getRegClass(RegClass);
62 }
63 
64 /// insertNoop - Insert a noop into the instruction stream at the specified
65 /// point.
68  llvm_unreachable("Target didn't implement insertNoop!");
69 }
70 
71 /// insertNoops - Insert noops into the instruction stream at the specified
72 /// point.
75  unsigned Quantity) const {
76  for (unsigned i = 0; i < Quantity; ++i)
77  insertNoop(MBB, MI);
78 }
79 
80 static bool isAsmComment(const char *Str, const MCAsmInfo &MAI) {
81  return strncmp(Str, MAI.getCommentString().data(),
82  MAI.getCommentString().size()) == 0;
83 }
84 
85 /// Measure the specified inline asm to determine an approximation of its
86 /// length.
87 /// Comments (which run till the next SeparatorString or newline) do not
88 /// count as an instruction.
89 /// Any other non-whitespace text is considered an instruction, with
90 /// multiple instructions separated by SeparatorString or newlines.
91 /// Variable-length instructions are not handled here; this function
92 /// may be overloaded in the target code to do that.
93 /// We implement a special case of the .space directive which takes only a
94 /// single integer argument in base 10 that is the size in bytes. This is a
95 /// restricted form of the GAS directive in that we only interpret
96 /// simple--i.e. not a logical or arithmetic expression--size values without
97 /// the optional fill value. This is primarily used for creating arbitrary
98 /// sized inline asm blocks for testing purposes.
100  const char *Str,
101  const MCAsmInfo &MAI, const TargetSubtargetInfo *STI) const {
102  // Count the number of instructions in the asm.
103  bool AtInsnStart = true;
104  unsigned Length = 0;
105  const unsigned MaxInstLength = MAI.getMaxInstLength(STI);
106  for (; *Str; ++Str) {
107  if (*Str == '\n' || strncmp(Str, MAI.getSeparatorString(),
108  strlen(MAI.getSeparatorString())) == 0) {
109  AtInsnStart = true;
110  } else if (isAsmComment(Str, MAI)) {
111  // Stop counting as an instruction after a comment until the next
112  // separator.
113  AtInsnStart = false;
114  }
115 
116  if (AtInsnStart && !isSpace(static_cast<unsigned char>(*Str))) {
117  unsigned AddLength = MaxInstLength;
118  if (strncmp(Str, ".space", 6) == 0) {
119  char *EStr;
120  int SpaceSize;
121  SpaceSize = strtol(Str + 6, &EStr, 10);
122  SpaceSize = SpaceSize < 0 ? 0 : SpaceSize;
123  while (*EStr != '\n' && isSpace(static_cast<unsigned char>(*EStr)))
124  ++EStr;
125  if (*EStr == '\0' || *EStr == '\n' ||
126  isAsmComment(EStr, MAI)) // Successfully parsed .space argument
127  AddLength = SpaceSize;
128  }
129  Length += AddLength;
130  AtInsnStart = false;
131  }
132  }
133 
134  return Length;
135 }
136 
137 /// ReplaceTailWithBranchTo - Delete the instruction OldInst and everything
138 /// after it, replacing it with an unconditional branch to NewDest.
139 void
141  MachineBasicBlock *NewDest) const {
142  MachineBasicBlock *MBB = Tail->getParent();
143 
144  // Remove all the old successors of MBB from the CFG.
145  while (!MBB->succ_empty())
147 
148  // Save off the debug loc before erasing the instruction.
149  DebugLoc DL = Tail->getDebugLoc();
150 
151  // Update call site info and remove all the dead instructions
152  // from the end of MBB.
153  while (Tail != MBB->end()) {
154  auto MI = Tail++;
155  if (MI->shouldUpdateCallSiteInfo())
157  MBB->erase(MI);
158  }
159 
160  // If MBB isn't immediately before MBB, insert a branch to it.
162  insertBranch(*MBB, NewDest, nullptr, SmallVector<MachineOperand, 0>(), DL);
163  MBB->addSuccessor(NewDest);
164 }
165 
167  bool NewMI, unsigned Idx1,
168  unsigned Idx2) const {
169  const MCInstrDesc &MCID = MI.getDesc();
170  bool HasDef = MCID.getNumDefs();
171  if (HasDef && !MI.getOperand(0).isReg())
172  // No idea how to commute this instruction. Target should implement its own.
173  return nullptr;
174 
175  unsigned CommutableOpIdx1 = Idx1; (void)CommutableOpIdx1;
176  unsigned CommutableOpIdx2 = Idx2; (void)CommutableOpIdx2;
177  assert(findCommutedOpIndices(MI, CommutableOpIdx1, CommutableOpIdx2) &&
178  CommutableOpIdx1 == Idx1 && CommutableOpIdx2 == Idx2 &&
179  "TargetInstrInfo::CommuteInstructionImpl(): not commutable operands.");
180  assert(MI.getOperand(Idx1).isReg() && MI.getOperand(Idx2).isReg() &&
181  "This only knows how to commute register operands so far");
182 
183  Register Reg0 = HasDef ? MI.getOperand(0).getReg() : Register();
184  Register Reg1 = MI.getOperand(Idx1).getReg();
185  Register Reg2 = MI.getOperand(Idx2).getReg();
186  unsigned SubReg0 = HasDef ? MI.getOperand(0).getSubReg() : 0;
187  unsigned SubReg1 = MI.getOperand(Idx1).getSubReg();
188  unsigned SubReg2 = MI.getOperand(Idx2).getSubReg();
189  bool Reg1IsKill = MI.getOperand(Idx1).isKill();
190  bool Reg2IsKill = MI.getOperand(Idx2).isKill();
191  bool Reg1IsUndef = MI.getOperand(Idx1).isUndef();
192  bool Reg2IsUndef = MI.getOperand(Idx2).isUndef();
193  bool Reg1IsInternal = MI.getOperand(Idx1).isInternalRead();
194  bool Reg2IsInternal = MI.getOperand(Idx2).isInternalRead();
195  // Avoid calling isRenamable for virtual registers since we assert that
196  // renamable property is only queried/set for physical registers.
197  bool Reg1IsRenamable = Register::isPhysicalRegister(Reg1)
198  ? MI.getOperand(Idx1).isRenamable()
199  : false;
200  bool Reg2IsRenamable = Register::isPhysicalRegister(Reg2)
201  ? MI.getOperand(Idx2).isRenamable()
202  : false;
203  // If destination is tied to either of the commuted source register, then
204  // it must be updated.
205  if (HasDef && Reg0 == Reg1 &&
206  MI.getDesc().getOperandConstraint(Idx1, MCOI::TIED_TO) == 0) {
207  Reg2IsKill = false;
208  Reg0 = Reg2;
209  SubReg0 = SubReg2;
210  } else if (HasDef && Reg0 == Reg2 &&
211  MI.getDesc().getOperandConstraint(Idx2, MCOI::TIED_TO) == 0) {
212  Reg1IsKill = false;
213  Reg0 = Reg1;
214  SubReg0 = SubReg1;
215  }
216 
217  MachineInstr *CommutedMI = nullptr;
218  if (NewMI) {
219  // Create a new instruction.
220  MachineFunction &MF = *MI.getMF();
221  CommutedMI = MF.CloneMachineInstr(&MI);
222  } else {
223  CommutedMI = &MI;
224  }
225 
226  if (HasDef) {
227  CommutedMI->getOperand(0).setReg(Reg0);
228  CommutedMI->getOperand(0).setSubReg(SubReg0);
229  }
230  CommutedMI->getOperand(Idx2).setReg(Reg1);
231  CommutedMI->getOperand(Idx1).setReg(Reg2);
232  CommutedMI->getOperand(Idx2).setSubReg(SubReg1);
233  CommutedMI->getOperand(Idx1).setSubReg(SubReg2);
234  CommutedMI->getOperand(Idx2).setIsKill(Reg1IsKill);
235  CommutedMI->getOperand(Idx1).setIsKill(Reg2IsKill);
236  CommutedMI->getOperand(Idx2).setIsUndef(Reg1IsUndef);
237  CommutedMI->getOperand(Idx1).setIsUndef(Reg2IsUndef);
238  CommutedMI->getOperand(Idx2).setIsInternalRead(Reg1IsInternal);
239  CommutedMI->getOperand(Idx1).setIsInternalRead(Reg2IsInternal);
240  // Avoid calling setIsRenamable for virtual registers since we assert that
241  // renamable property is only queried/set for physical registers.
243  CommutedMI->getOperand(Idx2).setIsRenamable(Reg1IsRenamable);
245  CommutedMI->getOperand(Idx1).setIsRenamable(Reg2IsRenamable);
246  return CommutedMI;
247 }
248 
250  unsigned OpIdx1,
251  unsigned OpIdx2) const {
252  // If OpIdx1 or OpIdx2 is not specified, then this method is free to choose
253  // any commutable operand, which is done in findCommutedOpIndices() method
254  // called below.
255  if ((OpIdx1 == CommuteAnyOperandIndex || OpIdx2 == CommuteAnyOperandIndex) &&
256  !findCommutedOpIndices(MI, OpIdx1, OpIdx2)) {
257  assert(MI.isCommutable() &&
258  "Precondition violation: MI must be commutable.");
259  return nullptr;
260  }
261  return commuteInstructionImpl(MI, NewMI, OpIdx1, OpIdx2);
262 }
263 
264 bool TargetInstrInfo::fixCommutedOpIndices(unsigned &ResultIdx1,
265  unsigned &ResultIdx2,
266  unsigned CommutableOpIdx1,
267  unsigned CommutableOpIdx2) {
268  if (ResultIdx1 == CommuteAnyOperandIndex &&
269  ResultIdx2 == CommuteAnyOperandIndex) {
270  ResultIdx1 = CommutableOpIdx1;
271  ResultIdx2 = CommutableOpIdx2;
272  } else if (ResultIdx1 == CommuteAnyOperandIndex) {
273  if (ResultIdx2 == CommutableOpIdx1)
274  ResultIdx1 = CommutableOpIdx2;
275  else if (ResultIdx2 == CommutableOpIdx2)
276  ResultIdx1 = CommutableOpIdx1;
277  else
278  return false;
279  } else if (ResultIdx2 == CommuteAnyOperandIndex) {
280  if (ResultIdx1 == CommutableOpIdx1)
281  ResultIdx2 = CommutableOpIdx2;
282  else if (ResultIdx1 == CommutableOpIdx2)
283  ResultIdx2 = CommutableOpIdx1;
284  else
285  return false;
286  } else
287  // Check that the result operand indices match the given commutable
288  // operand indices.
289  return (ResultIdx1 == CommutableOpIdx1 && ResultIdx2 == CommutableOpIdx2) ||
290  (ResultIdx1 == CommutableOpIdx2 && ResultIdx2 == CommutableOpIdx1);
291 
292  return true;
293 }
294 
296  unsigned &SrcOpIdx1,
297  unsigned &SrcOpIdx2) const {
298  assert(!MI.isBundle() &&
299  "TargetInstrInfo::findCommutedOpIndices() can't handle bundles");
300 
301  const MCInstrDesc &MCID = MI.getDesc();
302  if (!MCID.isCommutable())
303  return false;
304 
305  // This assumes v0 = op v1, v2 and commuting would swap v1 and v2. If this
306  // is not true, then the target must implement this.
307  unsigned CommutableOpIdx1 = MCID.getNumDefs();
308  unsigned CommutableOpIdx2 = CommutableOpIdx1 + 1;
309  if (!fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2,
310  CommutableOpIdx1, CommutableOpIdx2))
311  return false;
312 
313  if (!MI.getOperand(SrcOpIdx1).isReg() || !MI.getOperand(SrcOpIdx2).isReg())
314  // No idea.
315  return false;
316  return true;
317 }
318 
320  if (!MI.isTerminator()) return false;
321 
322  // Conditional branch is a special case.
323  if (MI.isBranch() && !MI.isBarrier())
324  return true;
325  if (!MI.isPredicable())
326  return true;
327  return !isPredicated(MI);
328 }
329 
332  bool MadeChange = false;
333 
334  assert(!MI.isBundle() &&
335  "TargetInstrInfo::PredicateInstruction() can't handle bundles");
336 
337  const MCInstrDesc &MCID = MI.getDesc();
338  if (!MI.isPredicable())
339  return false;
340 
341  for (unsigned j = 0, i = 0, e = MI.getNumOperands(); i != e; ++i) {
342  if (MCID.OpInfo[i].isPredicate()) {
343  MachineOperand &MO = MI.getOperand(i);
344  if (MO.isReg()) {
345  MO.setReg(Pred[j].getReg());
346  MadeChange = true;
347  } else if (MO.isImm()) {
348  MO.setImm(Pred[j].getImm());
349  MadeChange = true;
350  } else if (MO.isMBB()) {
351  MO.setMBB(Pred[j].getMBB());
352  MadeChange = true;
353  }
354  ++j;
355  }
356  }
357  return MadeChange;
358 }
359 
361  const MachineInstr &MI,
363  size_t StartSize = Accesses.size();
364  for (MachineInstr::mmo_iterator o = MI.memoperands_begin(),
365  oe = MI.memoperands_end();
366  o != oe; ++o) {
367  if ((*o)->isLoad() &&
368  isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
369  Accesses.push_back(*o);
370  }
371  return Accesses.size() != StartSize;
372 }
373 
375  const MachineInstr &MI,
377  size_t StartSize = Accesses.size();
378  for (MachineInstr::mmo_iterator o = MI.memoperands_begin(),
379  oe = MI.memoperands_end();
380  o != oe; ++o) {
381  if ((*o)->isStore() &&
382  isa_and_nonnull<FixedStackPseudoSourceValue>((*o)->getPseudoValue()))
383  Accesses.push_back(*o);
384  }
385  return Accesses.size() != StartSize;
386 }
387 
389  unsigned SubIdx, unsigned &Size,
390  unsigned &Offset,
391  const MachineFunction &MF) const {
393  if (!SubIdx) {
394  Size = TRI->getSpillSize(*RC);
395  Offset = 0;
396  return true;
397  }
398  unsigned BitSize = TRI->getSubRegIdxSize(SubIdx);
399  // Convert bit size to byte size.
400  if (BitSize % 8)
401  return false;
402 
403  int BitOffset = TRI->getSubRegIdxOffset(SubIdx);
404  if (BitOffset < 0 || BitOffset % 8)
405  return false;
406 
407  Size = BitSize / 8;
408  Offset = (unsigned)BitOffset / 8;
409 
410  assert(TRI->getSpillSize(*RC) >= (Offset + Size) && "bad subregister range");
411 
412  if (!MF.getDataLayout().isLittleEndian()) {
413  Offset = TRI->getSpillSize(*RC) - (Offset + Size);
414  }
415  return true;
416 }
417 
420  Register DestReg, unsigned SubIdx,
421  const MachineInstr &Orig,
422  const TargetRegisterInfo &TRI) const {
424  MI->substituteRegister(MI->getOperand(0).getReg(), DestReg, SubIdx, TRI);
425  MBB.insert(I, MI);
426 }
427 
429  const MachineInstr &MI1,
430  const MachineRegisterInfo *MRI) const {
432 }
433 
435  MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) const {
436  assert(!Orig.isNotDuplicable() && "Instruction cannot be duplicated");
437  MachineFunction &MF = *MBB.getParent();
438  return MF.cloneMachineInstrBundle(MBB, InsertBefore, Orig);
439 }
440 
441 // If the COPY instruction in MI can be folded to a stack operation, return
442 // the register class to use.
444  unsigned FoldIdx) {
445  assert(MI.isCopy() && "MI must be a COPY instruction");
446  if (MI.getNumOperands() != 2)
447  return nullptr;
448  assert(FoldIdx<2 && "FoldIdx refers no nonexistent operand");
449 
450  const MachineOperand &FoldOp = MI.getOperand(FoldIdx);
451  const MachineOperand &LiveOp = MI.getOperand(1 - FoldIdx);
452 
453  if (FoldOp.getSubReg() || LiveOp.getSubReg())
454  return nullptr;
455 
456  Register FoldReg = FoldOp.getReg();
457  Register LiveReg = LiveOp.getReg();
458 
459  assert(Register::isVirtualRegister(FoldReg) && "Cannot fold physregs");
460 
461  const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
462  const TargetRegisterClass *RC = MRI.getRegClass(FoldReg);
463 
464  if (Register::isPhysicalRegister(LiveOp.getReg()))
465  return RC->contains(LiveOp.getReg()) ? RC : nullptr;
466 
467  if (RC->hasSubClassEq(MRI.getRegClass(LiveReg)))
468  return RC;
469 
470  // FIXME: Allow folding when register classes are memory compatible.
471  return nullptr;
472 }
473 
474 MCInst TargetInstrInfo::getNop() const { llvm_unreachable("Not implemented"); }
475 
476 std::pair<unsigned, unsigned>
478  switch (MI.getOpcode()) {
480  // StackMapLiveValues are foldable
481  return std::make_pair(0, StackMapOpers(&MI).getVarIdx());
483  // For PatchPoint, the call args are not foldable (even if reported in the
484  // stackmap e.g. via anyregcc).
485  return std::make_pair(0, PatchPointOpers(&MI).getVarIdx());
486  case TargetOpcode::STATEPOINT:
487  // For statepoints, fold deopt and gc arguments, but not call arguments.
488  return std::make_pair(MI.getNumDefs(), StatepointOpers(&MI).getVarIdx());
489  default:
490  llvm_unreachable("unexpected stackmap opcode");
491  }
492 }
493 
496  const TargetInstrInfo &TII) {
497  unsigned StartIdx = 0;
498  unsigned NumDefs = 0;
499  // getPatchpointUnfoldableRange throws guarantee if MI is not a patchpoint.
500  std::tie(NumDefs, StartIdx) = TII.getPatchpointUnfoldableRange(MI);
501 
502  unsigned DefToFoldIdx = MI.getNumOperands();
503 
504  // Return false if any operands requested for folding are not foldable (not
505  // part of the stackmap's live values).
506  for (unsigned Op : Ops) {
507  if (Op < NumDefs) {
508  assert(DefToFoldIdx == MI.getNumOperands() && "Folding multiple defs");
509  DefToFoldIdx = Op;
510  } else if (Op < StartIdx) {
511  return nullptr;
512  }
513  if (MI.getOperand(Op).isTied())
514  return nullptr;
515  }
516 
517  MachineInstr *NewMI =
518  MF.CreateMachineInstr(TII.get(MI.getOpcode()), MI.getDebugLoc(), true);
519  MachineInstrBuilder MIB(MF, NewMI);
520 
521  // No need to fold return, the meta data, and function arguments
522  for (unsigned i = 0; i < StartIdx; ++i)
523  if (i != DefToFoldIdx)
524  MIB.add(MI.getOperand(i));
525 
526  for (unsigned i = StartIdx, e = MI.getNumOperands(); i < e; ++i) {
527  MachineOperand &MO = MI.getOperand(i);
528  unsigned TiedTo = e;
529  (void)MI.isRegTiedToDefOperand(i, &TiedTo);
530 
531  if (is_contained(Ops, i)) {
532  assert(TiedTo == e && "Cannot fold tied operands");
533  unsigned SpillSize;
534  unsigned SpillOffset;
535  // Compute the spill slot size and offset.
536  const TargetRegisterClass *RC =
537  MF.getRegInfo().getRegClass(MO.getReg());
538  bool Valid =
539  TII.getStackSlotRange(RC, MO.getSubReg(), SpillSize, SpillOffset, MF);
540  if (!Valid)
541  report_fatal_error("cannot spill patchpoint subregister operand");
542  MIB.addImm(StackMaps::IndirectMemRefOp);
543  MIB.addImm(SpillSize);
545  MIB.addImm(SpillOffset);
546  } else {
547  MIB.add(MO);
548  if (TiedTo < e) {
549  assert(TiedTo < NumDefs && "Bad tied operand");
550  if (TiedTo > DefToFoldIdx)
551  --TiedTo;
552  NewMI->tieOperands(TiedTo, NewMI->getNumOperands() - 1);
553  }
554  }
555  }
556  return NewMI;
557 }
558 
560  ArrayRef<unsigned> Ops, int FI,
561  LiveIntervals *LIS,
562  VirtRegMap *VRM) const {
563  auto Flags = MachineMemOperand::MONone;
564  for (unsigned OpIdx : Ops)
565  Flags |= MI.getOperand(OpIdx).isDef() ? MachineMemOperand::MOStore
567 
568  MachineBasicBlock *MBB = MI.getParent();
569  assert(MBB && "foldMemoryOperand needs an inserted instruction");
570  MachineFunction &MF = *MBB->getParent();
571 
572  // If we're not folding a load into a subreg, the size of the load is the
573  // size of the spill slot. But if we are, we need to figure out what the
574  // actual load size is.
575  int64_t MemSize = 0;
576  const MachineFrameInfo &MFI = MF.getFrameInfo();
578 
579  if (Flags & MachineMemOperand::MOStore) {
580  MemSize = MFI.getObjectSize(FI);
581  } else {
582  for (unsigned OpIdx : Ops) {
583  int64_t OpSize = MFI.getObjectSize(FI);
584 
585  if (auto SubReg = MI.getOperand(OpIdx).getSubReg()) {
586  unsigned SubRegSize = TRI->getSubRegIdxSize(SubReg);
587  if (SubRegSize > 0 && !(SubRegSize % 8))
588  OpSize = SubRegSize / 8;
589  }
590 
591  MemSize = std::max(MemSize, OpSize);
592  }
593  }
594 
595  assert(MemSize && "Did not expect a zero-sized stack slot");
596 
597  MachineInstr *NewMI = nullptr;
598 
599  if (MI.getOpcode() == TargetOpcode::STACKMAP ||
600  MI.getOpcode() == TargetOpcode::PATCHPOINT ||
601  MI.getOpcode() == TargetOpcode::STATEPOINT) {
602  // Fold stackmap/patchpoint.
603  NewMI = foldPatchpoint(MF, MI, Ops, FI, *this);
604  if (NewMI)
605  MBB->insert(MI, NewMI);
606  } else {
607  // Ask the target to do the actual folding.
608  NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, FI, LIS, VRM);
609  }
610 
611  if (NewMI) {
612  NewMI->setMemRefs(MF, MI.memoperands());
613  // Add a memory operand, foldMemoryOperandImpl doesn't do that.
614  assert((!(Flags & MachineMemOperand::MOStore) ||
615  NewMI->mayStore()) &&
616  "Folded a def to a non-store!");
617  assert((!(Flags & MachineMemOperand::MOLoad) ||
618  NewMI->mayLoad()) &&
619  "Folded a use to a non-load!");
620  assert(MFI.getObjectOffset(FI) != -1);
621  MachineMemOperand *MMO =
623  Flags, MemSize, MFI.getObjectAlign(FI));
624  NewMI->addMemOperand(MF, MMO);
625 
626  // The pass "x86 speculative load hardening" always attaches symbols to
627  // call instructions. We need copy it form old instruction.
628  NewMI->cloneInstrSymbols(MF, MI);
629 
630  return NewMI;
631  }
632 
633  // Straight COPY may fold as load/store.
634  if (!MI.isCopy() || Ops.size() != 1)
635  return nullptr;
636 
637  const TargetRegisterClass *RC = canFoldCopy(MI, Ops[0]);
638  if (!RC)
639  return nullptr;
640 
641  const MachineOperand &MO = MI.getOperand(1 - Ops[0]);
643 
644  if (Flags == MachineMemOperand::MOStore)
645  storeRegToStackSlot(*MBB, Pos, MO.getReg(), MO.isKill(), FI, RC, TRI);
646  else
647  loadRegFromStackSlot(*MBB, Pos, MO.getReg(), FI, RC, TRI);
648  return &*--Pos;
649 }
650 
652  ArrayRef<unsigned> Ops,
653  MachineInstr &LoadMI,
654  LiveIntervals *LIS) const {
655  assert(LoadMI.canFoldAsLoad() && "LoadMI isn't foldable!");
656 #ifndef NDEBUG
657  for (unsigned OpIdx : Ops)
658  assert(MI.getOperand(OpIdx).isUse() && "Folding load into def!");
659 #endif
660 
661  MachineBasicBlock &MBB = *MI.getParent();
662  MachineFunction &MF = *MBB.getParent();
663 
664  // Ask the target to do the actual folding.
665  MachineInstr *NewMI = nullptr;
666  int FrameIndex = 0;
667 
668  if ((MI.getOpcode() == TargetOpcode::STACKMAP ||
669  MI.getOpcode() == TargetOpcode::PATCHPOINT ||
670  MI.getOpcode() == TargetOpcode::STATEPOINT) &&
671  isLoadFromStackSlot(LoadMI, FrameIndex)) {
672  // Fold stackmap/patchpoint.
673  NewMI = foldPatchpoint(MF, MI, Ops, FrameIndex, *this);
674  if (NewMI)
675  NewMI = &*MBB.insert(MI, NewMI);
676  } else {
677  // Ask the target to do the actual folding.
678  NewMI = foldMemoryOperandImpl(MF, MI, Ops, MI, LoadMI, LIS);
679  }
680 
681  if (!NewMI)
682  return nullptr;
683 
684  // Copy the memoperands from the load to the folded instruction.
685  if (MI.memoperands_empty()) {
686  NewMI->setMemRefs(MF, LoadMI.memoperands());
687  } else {
688  // Handle the rare case of folding multiple loads.
689  NewMI->setMemRefs(MF, MI.memoperands());
691  E = LoadMI.memoperands_end();
692  I != E; ++I) {
693  NewMI->addMemOperand(MF, *I);
694  }
695  }
696  return NewMI;
697 }
698 
700  const MachineInstr &Inst, const MachineBasicBlock *MBB) const {
701  const MachineOperand &Op1 = Inst.getOperand(1);
702  const MachineOperand &Op2 = Inst.getOperand(2);
704 
705  // We need virtual register definitions for the operands that we will
706  // reassociate.
707  MachineInstr *MI1 = nullptr;
708  MachineInstr *MI2 = nullptr;
709  if (Op1.isReg() && Register::isVirtualRegister(Op1.getReg()))
710  MI1 = MRI.getUniqueVRegDef(Op1.getReg());
711  if (Op2.isReg() && Register::isVirtualRegister(Op2.getReg()))
712  MI2 = MRI.getUniqueVRegDef(Op2.getReg());
713 
714  // And they need to be in the trace (otherwise, they won't have a depth).
715  return MI1 && MI2 && MI1->getParent() == MBB && MI2->getParent() == MBB;
716 }
717 
719  bool &Commuted) const {
720  const MachineBasicBlock *MBB = Inst.getParent();
724  unsigned AssocOpcode = Inst.getOpcode();
725 
726  // If only one operand has the same opcode and it's the second source operand,
727  // the operands must be commuted.
728  Commuted = MI1->getOpcode() != AssocOpcode && MI2->getOpcode() == AssocOpcode;
729  if (Commuted)
730  std::swap(MI1, MI2);
731 
732  // 1. The previous instruction must be the same type as Inst.
733  // 2. The previous instruction must also be associative/commutative (this can
734  // be different even for instructions with the same opcode if traits like
735  // fast-math-flags are included).
736  // 3. The previous instruction must have virtual register definitions for its
737  // operands in the same basic block as Inst.
738  // 4. The previous instruction's result must only be used by Inst.
739  return MI1->getOpcode() == AssocOpcode && isAssociativeAndCommutative(*MI1) &&
740  hasReassociableOperands(*MI1, MBB) &&
742 }
743 
744 // 1. The operation must be associative and commutative.
745 // 2. The instruction must have virtual register definitions for its
746 // operands in the same basic block.
747 // 3. The instruction must have a reassociable sibling.
749  bool &Commuted) const {
750  return isAssociativeAndCommutative(Inst) &&
751  hasReassociableOperands(Inst, Inst.getParent()) &&
752  hasReassociableSibling(Inst, Commuted);
753 }
754 
755 // The concept of the reassociation pass is that these operations can benefit
756 // from this kind of transformation:
757 //
758 // A = ? op ?
759 // B = A op X (Prev)
760 // C = B op Y (Root)
761 // -->
762 // A = ? op ?
763 // B = X op Y
764 // C = A op B
765 //
766 // breaking the dependency between A and B, allowing them to be executed in
767 // parallel (or back-to-back in a pipeline) instead of depending on each other.
768 
769 // FIXME: This has the potential to be expensive (compile time) while not
770 // improving the code at all. Some ways to limit the overhead:
771 // 1. Track successful transforms; bail out if hit rate gets too low.
772 // 2. Only enable at -O3 or some other non-default optimization level.
773 // 3. Pre-screen pattern candidates here: if an operand of the previous
774 // instruction is known to not increase the critical path, then don't match
775 // that pattern.
778  bool DoRegPressureReduce) const {
779  bool Commute;
780  if (isReassociationCandidate(Root, Commute)) {
781  // We found a sequence of instructions that may be suitable for a
782  // reassociation of operands to increase ILP. Specify each commutation
783  // possibility for the Prev instruction in the sequence and let the
784  // machine combiner decide if changing the operands is worthwhile.
785  if (Commute) {
786  Patterns.push_back(MachineCombinerPattern::REASSOC_AX_YB);
787  Patterns.push_back(MachineCombinerPattern::REASSOC_XA_YB);
788  } else {
789  Patterns.push_back(MachineCombinerPattern::REASSOC_AX_BY);
790  Patterns.push_back(MachineCombinerPattern::REASSOC_XA_BY);
791  }
792  return true;
793  }
794 
795  return false;
796 }
797 
798 /// Return true when a code sequence can improve loop throughput.
799 bool
801  return false;
802 }
803 
804 /// Attempt the reassociation transformation to reduce critical path length.
805 /// See the above comments before getMachineCombinerPatterns().
807  MachineInstr &Root, MachineInstr &Prev,
811  DenseMap<unsigned, unsigned> &InstrIdxForVirtReg) const {
812  MachineFunction *MF = Root.getMF();
814  const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
816  const TargetRegisterClass *RC = Root.getRegClassConstraint(0, TII, TRI);
817 
818  // This array encodes the operand index for each parameter because the
819  // operands may be commuted. Each row corresponds to a pattern value,
820  // and each column specifies the index of A, B, X, Y.
821  unsigned OpIdx[4][4] = {
822  { 1, 1, 2, 2 },
823  { 1, 2, 2, 1 },
824  { 2, 1, 1, 2 },
825  { 2, 2, 1, 1 }
826  };
827 
828  int Row;
829  switch (Pattern) {
830  case MachineCombinerPattern::REASSOC_AX_BY: Row = 0; break;
831  case MachineCombinerPattern::REASSOC_AX_YB: Row = 1; break;
832  case MachineCombinerPattern::REASSOC_XA_BY: Row = 2; break;
833  case MachineCombinerPattern::REASSOC_XA_YB: Row = 3; break;
834  default: llvm_unreachable("unexpected MachineCombinerPattern");
835  }
836 
837  MachineOperand &OpA = Prev.getOperand(OpIdx[Row][0]);
838  MachineOperand &OpB = Root.getOperand(OpIdx[Row][1]);
839  MachineOperand &OpX = Prev.getOperand(OpIdx[Row][2]);
840  MachineOperand &OpY = Root.getOperand(OpIdx[Row][3]);
841  MachineOperand &OpC = Root.getOperand(0);
842 
843  Register RegA = OpA.getReg();
844  Register RegB = OpB.getReg();
845  Register RegX = OpX.getReg();
846  Register RegY = OpY.getReg();
847  Register RegC = OpC.getReg();
848 
849  if (Register::isVirtualRegister(RegA))
850  MRI.constrainRegClass(RegA, RC);
851  if (Register::isVirtualRegister(RegB))
852  MRI.constrainRegClass(RegB, RC);
853  if (Register::isVirtualRegister(RegX))
854  MRI.constrainRegClass(RegX, RC);
855  if (Register::isVirtualRegister(RegY))
856  MRI.constrainRegClass(RegY, RC);
857  if (Register::isVirtualRegister(RegC))
858  MRI.constrainRegClass(RegC, RC);
859 
860  // Create a new virtual register for the result of (X op Y) instead of
861  // recycling RegB because the MachineCombiner's computation of the critical
862  // path requires a new register definition rather than an existing one.
863  Register NewVR = MRI.createVirtualRegister(RC);
864  InstrIdxForVirtReg.insert(std::make_pair(NewVR, 0));
865 
866  unsigned Opcode = Root.getOpcode();
867  bool KillA = OpA.isKill();
868  bool KillX = OpX.isKill();
869  bool KillY = OpY.isKill();
870 
871  // Create new instructions for insertion.
872  MachineInstrBuilder MIB1 =
873  BuildMI(*MF, MIMetadata(Prev), TII->get(Opcode), NewVR)
874  .addReg(RegX, getKillRegState(KillX))
875  .addReg(RegY, getKillRegState(KillY))
876  .setMIFlags(Prev.getFlags());
877  MachineInstrBuilder MIB2 =
878  BuildMI(*MF, MIMetadata(Root), TII->get(Opcode), RegC)
879  .addReg(RegA, getKillRegState(KillA))
880  .addReg(NewVR, getKillRegState(true))
881  .setMIFlags(Root.getFlags());
882 
883  setSpecialOperandAttr(Root, Prev, *MIB1, *MIB2);
884 
885  // Record new instructions for insertion and old instructions for deletion.
886  InsInstrs.push_back(MIB1);
887  InsInstrs.push_back(MIB2);
888  DelInstrs.push_back(&Prev);
889  DelInstrs.push_back(&Root);
890 }
891 
896  DenseMap<unsigned, unsigned> &InstIdxForVirtReg) const {
898 
899  // Select the previous instruction in the sequence based on the input pattern.
900  MachineInstr *Prev = nullptr;
901  switch (Pattern) {
904  Prev = MRI.getUniqueVRegDef(Root.getOperand(1).getReg());
905  break;
908  Prev = MRI.getUniqueVRegDef(Root.getOperand(2).getReg());
909  break;
910  default:
911  break;
912  }
913 
914  assert(Prev && "Unknown pattern for machine combiner");
915 
916  reassociateOps(Root, *Prev, Pattern, InsInstrs, DelInstrs, InstIdxForVirtReg);
917 }
918 
919 bool TargetInstrInfo::isReallyTriviallyReMaterializableGeneric(
920  const MachineInstr &MI) const {
921  const MachineFunction &MF = *MI.getMF();
922  const MachineRegisterInfo &MRI = MF.getRegInfo();
923 
924  // Remat clients assume operand 0 is the defined register.
925  if (!MI.getNumOperands() || !MI.getOperand(0).isReg())
926  return false;
927  Register DefReg = MI.getOperand(0).getReg();
928 
929  // A sub-register definition can only be rematerialized if the instruction
930  // doesn't read the other parts of the register. Otherwise it is really a
931  // read-modify-write operation on the full virtual register which cannot be
932  // moved safely.
933  if (Register::isVirtualRegister(DefReg) && MI.getOperand(0).getSubReg() &&
934  MI.readsVirtualRegister(DefReg))
935  return false;
936 
937  // A load from a fixed stack slot can be rematerialized. This may be
938  // redundant with subsequent checks, but it's target-independent,
939  // simple, and a common case.
940  int FrameIdx = 0;
941  if (isLoadFromStackSlot(MI, FrameIdx) &&
942  MF.getFrameInfo().isImmutableObjectIndex(FrameIdx))
943  return true;
944 
945  // Avoid instructions obviously unsafe for remat.
946  if (MI.isNotDuplicable() || MI.mayStore() || MI.mayRaiseFPException() ||
947  MI.hasUnmodeledSideEffects())
948  return false;
949 
950  // Don't remat inline asm. We have no idea how expensive it is
951  // even if it's side effect free.
952  if (MI.isInlineAsm())
953  return false;
954 
955  // Avoid instructions which load from potentially varying memory.
956  if (MI.mayLoad() && !MI.isDereferenceableInvariantLoad())
957  return false;
958 
959  // If any of the registers accessed are non-constant, conservatively assume
960  // the instruction is not rematerializable.
961  for (const MachineOperand &MO : MI.operands()) {
962  if (!MO.isReg()) continue;
963  Register Reg = MO.getReg();
964  if (Reg == 0)
965  continue;
966 
967  // Check for a well-behaved physical register.
969  if (MO.isUse()) {
970  // If the physreg has no defs anywhere, it's just an ambient register
971  // and we can freely move its uses. Alternatively, if it's allocatable,
972  // it could get allocated to something with a def during allocation.
973  if (!MRI.isConstantPhysReg(Reg))
974  return false;
975  } else {
976  // A physreg def. We can't remat it.
977  return false;
978  }
979  continue;
980  }
981 
982  // Only allow one virtual-register def. There may be multiple defs of the
983  // same virtual register, though.
984  if (MO.isDef() && Reg != DefReg)
985  return false;
986 
987  // Don't allow any virtual-register uses. Rematting an instruction with
988  // virtual register uses would length the live ranges of the uses, which
989  // is not necessarily a good idea, certainly not "trivial".
990  if (MO.isUse())
991  return false;
992  }
993 
994  // Everything checked out.
995  return true;
996 }
997 
999  const MachineFunction *MF = MI.getMF();
1000  const TargetFrameLowering *TFI = MF->getSubtarget().getFrameLowering();
1001  bool StackGrowsDown =
1003 
1004  unsigned FrameSetupOpcode = getCallFrameSetupOpcode();
1005  unsigned FrameDestroyOpcode = getCallFrameDestroyOpcode();
1006 
1007  if (!isFrameInstr(MI))
1008  return 0;
1009 
1010  int SPAdj = TFI->alignSPAdjust(getFrameSize(MI));
1011 
1012  if ((!StackGrowsDown && MI.getOpcode() == FrameSetupOpcode) ||
1013  (StackGrowsDown && MI.getOpcode() == FrameDestroyOpcode))
1014  SPAdj = -SPAdj;
1015 
1016  return SPAdj;
1017 }
1018 
1019 /// isSchedulingBoundary - Test if the given instruction should be
1020 /// considered a scheduling boundary. This primarily includes labels
1021 /// and terminators.
1023  const MachineBasicBlock *MBB,
1024  const MachineFunction &MF) const {
1025  // Terminators and labels can't be scheduled around.
1026  if (MI.isTerminator() || MI.isPosition())
1027  return true;
1028 
1029  // INLINEASM_BR can jump to another block
1030  if (MI.getOpcode() == TargetOpcode::INLINEASM_BR)
1031  return true;
1032 
1033  // Don't attempt to schedule around any instruction that defines
1034  // a stack-oriented pointer, as it's unlikely to be profitable. This
1035  // saves compile time, because it doesn't require every single
1036  // stack slot reference to depend on the instruction that does the
1037  // modification.
1038  const TargetLowering &TLI = *MF.getSubtarget().getTargetLowering();
1040  return MI.modifiesRegister(TLI.getStackPointerRegisterToSaveRestore(), TRI);
1041 }
1042 
1043 // Provide a global flag for disabling the PreRA hazard recognizer that targets
1044 // may choose to honor.
1046  return !DisableHazardRecognizer;
1047 }
1048 
1049 // Default implementation of CreateTargetRAHazardRecognizer.
1052  const ScheduleDAG *DAG) const {
1053  // Dummy hazard recognizer allows all instructions to issue.
1054  return new ScheduleHazardRecognizer();
1055 }
1056 
1057 // Default implementation of CreateTargetMIHazardRecognizer.
1059  const InstrItineraryData *II, const ScheduleDAGMI *DAG) const {
1060  return new ScoreboardHazardRecognizer(II, DAG, "machine-scheduler");
1061 }
1062 
1063 // Default implementation of CreateTargetPostRAHazardRecognizer.
1066  const ScheduleDAG *DAG) const {
1067  return new ScoreboardHazardRecognizer(II, DAG, "post-RA-sched");
1068 }
1069 
1070 // Default implementation of getMemOperandWithOffset.
1072  const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset,
1073  bool &OffsetIsScalable, const TargetRegisterInfo *TRI) const {
1075  unsigned Width;
1076  if (!getMemOperandsWithOffsetWidth(MI, BaseOps, Offset, OffsetIsScalable,
1077  Width, TRI) ||
1078  BaseOps.size() != 1)
1079  return false;
1080  BaseOp = BaseOps.front();
1081  return true;
1082 }
1083 
1084 //===----------------------------------------------------------------------===//
1085 // SelectionDAG latency interface.
1086 //===----------------------------------------------------------------------===//
1087 
1088 int
1090  SDNode *DefNode, unsigned DefIdx,
1091  SDNode *UseNode, unsigned UseIdx) const {
1092  if (!ItinData || ItinData->isEmpty())
1093  return -1;
1094 
1095  if (!DefNode->isMachineOpcode())
1096  return -1;
1097 
1098  unsigned DefClass = get(DefNode->getMachineOpcode()).getSchedClass();
1099  if (!UseNode->isMachineOpcode())
1100  return ItinData->getOperandCycle(DefClass, DefIdx);
1101  unsigned UseClass = get(UseNode->getMachineOpcode()).getSchedClass();
1102  return ItinData->getOperandLatency(DefClass, DefIdx, UseClass, UseIdx);
1103 }
1104 
1106  SDNode *N) const {
1107  if (!ItinData || ItinData->isEmpty())
1108  return 1;
1109 
1110  if (!N->isMachineOpcode())
1111  return 1;
1112 
1113  return ItinData->getStageLatency(get(N->getMachineOpcode()).getSchedClass());
1114 }
1115 
1116 //===----------------------------------------------------------------------===//
1117 // MachineInstr latency interface.
1118 //===----------------------------------------------------------------------===//
1119 
1121  const MachineInstr &MI) const {
1122  if (!ItinData || ItinData->isEmpty())
1123  return 1;
1124 
1125  unsigned Class = MI.getDesc().getSchedClass();
1126  int UOps = ItinData->Itineraries[Class].NumMicroOps;
1127  if (UOps >= 0)
1128  return UOps;
1129 
1130  // The # of u-ops is dynamically determined. The specific target should
1131  // override this function to return the right number.
1132  return 1;
1133 }
1134 
1135 /// Return the default expected latency for a def based on it's opcode.
1137  const MachineInstr &DefMI) const {
1138  if (DefMI.isTransient())
1139  return 0;
1140  if (DefMI.mayLoad())
1141  return SchedModel.LoadLatency;
1142  if (isHighLatencyDef(DefMI.getOpcode()))
1143  return SchedModel.HighLatency;
1144  return 1;
1145 }
1146 
1148  return 0;
1149 }
1150 
1152  const MachineInstr &MI,
1153  unsigned *PredCost) const {
1154  // Default to one cycle for no itinerary. However, an "empty" itinerary may
1155  // still have a MinLatency property, which getStageLatency checks.
1156  if (!ItinData)
1157  return MI.mayLoad() ? 2 : 1;
1158 
1159  return ItinData->getStageLatency(MI.getDesc().getSchedClass());
1160 }
1161 
1163  const MachineInstr &DefMI,
1164  unsigned DefIdx) const {
1165  const InstrItineraryData *ItinData = SchedModel.getInstrItineraries();
1166  if (!ItinData || ItinData->isEmpty())
1167  return false;
1168 
1169  unsigned DefClass = DefMI.getDesc().getSchedClass();
1170  int DefCycle = ItinData->getOperandCycle(DefClass, DefIdx);
1171  return (DefCycle != -1 && DefCycle <= 1);
1172 }
1173 
1176  Register Reg) const {
1177  const MachineFunction *MF = MI.getMF();
1180  int64_t Offset;
1181  bool OffsetIsScalable;
1182 
1183  // To simplify the sub-register handling, verify that we only need to
1184  // consider physical registers.
1187 
1188  if (auto DestSrc = isCopyInstr(MI)) {
1189  Register DestReg = DestSrc->Destination->getReg();
1190 
1191  // If the copy destination is the forwarding reg, describe the forwarding
1192  // reg using the copy source as the backup location. Example:
1193  //
1194  // x0 = MOV x7
1195  // call callee(x0) ; x0 described as x7
1196  if (Reg == DestReg)
1197  return ParamLoadedValue(*DestSrc->Source, Expr);
1198 
1199  // Cases where super- or sub-registers needs to be described should
1200  // be handled by the target's hook implementation.
1201  assert(!TRI->isSuperOrSubRegisterEq(Reg, DestReg) &&
1202  "TargetInstrInfo::describeLoadedValue can't describe super- or "
1203  "sub-regs for copy instructions");
1204  return None;
1205  } else if (auto RegImm = isAddImmediate(MI, Reg)) {
1206  Register SrcReg = RegImm->Reg;
1207  Offset = RegImm->Imm;
1208  Expr = DIExpression::prepend(Expr, DIExpression::ApplyOffset, Offset);
1209  return ParamLoadedValue(MachineOperand::CreateReg(SrcReg, false), Expr);
1210  } else if (MI.hasOneMemOperand()) {
1211  // Only describe memory which provably does not escape the function. As
1212  // described in llvm.org/PR43343, escaped memory may be clobbered by the
1213  // callee (or by another thread).
1214  const auto &TII = MF->getSubtarget().getInstrInfo();
1215  const MachineFrameInfo &MFI = MF->getFrameInfo();
1216  const MachineMemOperand *MMO = MI.memoperands()[0];
1217  const PseudoSourceValue *PSV = MMO->getPseudoValue();
1218 
1219  // If the address points to "special" memory (e.g. a spill slot), it's
1220  // sufficient to check that it isn't aliased by any high-level IR value.
1221  if (!PSV || PSV->mayAlias(&MFI))
1222  return None;
1223 
1224  const MachineOperand *BaseOp;
1225  if (!TII->getMemOperandWithOffset(MI, BaseOp, Offset, OffsetIsScalable,
1226  TRI))
1227  return None;
1228 
1229  // FIXME: Scalable offsets are not yet handled in the offset code below.
1230  if (OffsetIsScalable)
1231  return None;
1232 
1233  // TODO: Can currently only handle mem instructions with a single define.
1234  // An example from the x86 target:
1235  // ...
1236  // DIV64m $rsp, 1, $noreg, 24, $noreg, implicit-def dead $rax, implicit-def $rdx
1237  // ...
1238  //
1239  if (MI.getNumExplicitDefs() != 1)
1240  return None;
1241 
1242  // TODO: In what way do we need to take Reg into consideration here?
1243 
1245  DIExpression::appendOffset(Ops, Offset);
1246  Ops.push_back(dwarf::DW_OP_deref_size);
1247  Ops.push_back(MMO->getSize());
1248  Expr = DIExpression::prependOpcodes(Expr, Ops);
1249  return ParamLoadedValue(*BaseOp, Expr);
1250  }
1251 
1252  return None;
1253 }
1254 
1255 /// Both DefMI and UseMI must be valid. By default, call directly to the
1256 /// itinerary. This may be overriden by the target.
1258  const MachineInstr &DefMI,
1259  unsigned DefIdx,
1260  const MachineInstr &UseMI,
1261  unsigned UseIdx) const {
1262  unsigned DefClass = DefMI.getDesc().getSchedClass();
1263  unsigned UseClass = UseMI.getDesc().getSchedClass();
1264  return ItinData->getOperandLatency(DefClass, DefIdx, UseClass, UseIdx);
1265 }
1266 
1268  const MachineInstr &MI, unsigned DefIdx,
1269  SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const {
1270  assert((MI.isRegSequence() ||
1271  MI.isRegSequenceLike()) && "Instruction do not have the proper type");
1272 
1273  if (!MI.isRegSequence())
1274  return getRegSequenceLikeInputs(MI, DefIdx, InputRegs);
1275 
1276  // We are looking at:
1277  // Def = REG_SEQUENCE v0, sub0, v1, sub1, ...
1278  assert(DefIdx == 0 && "REG_SEQUENCE only has one def");
1279  for (unsigned OpIdx = 1, EndOpIdx = MI.getNumOperands(); OpIdx != EndOpIdx;
1280  OpIdx += 2) {
1281  const MachineOperand &MOReg = MI.getOperand(OpIdx);
1282  if (MOReg.isUndef())
1283  continue;
1284  const MachineOperand &MOSubIdx = MI.getOperand(OpIdx + 1);
1285  assert(MOSubIdx.isImm() &&
1286  "One of the subindex of the reg_sequence is not an immediate");
1287  // Record Reg:SubReg, SubIdx.
1288  InputRegs.push_back(RegSubRegPairAndIdx(MOReg.getReg(), MOReg.getSubReg(),
1289  (unsigned)MOSubIdx.getImm()));
1290  }
1291  return true;
1292 }
1293 
1295  const MachineInstr &MI, unsigned DefIdx,
1296  RegSubRegPairAndIdx &InputReg) const {
1297  assert((MI.isExtractSubreg() ||
1298  MI.isExtractSubregLike()) && "Instruction do not have the proper type");
1299 
1300  if (!MI.isExtractSubreg())
1301  return getExtractSubregLikeInputs(MI, DefIdx, InputReg);
1302 
1303  // We are looking at:
1304  // Def = EXTRACT_SUBREG v0.sub1, sub0.
1305  assert(DefIdx == 0 && "EXTRACT_SUBREG only has one def");
1306  const MachineOperand &MOReg = MI.getOperand(1);
1307  if (MOReg.isUndef())
1308  return false;
1309  const MachineOperand &MOSubIdx = MI.getOperand(2);
1310  assert(MOSubIdx.isImm() &&
1311  "The subindex of the extract_subreg is not an immediate");
1312 
1313  InputReg.Reg = MOReg.getReg();
1314  InputReg.SubReg = MOReg.getSubReg();
1315  InputReg.SubIdx = (unsigned)MOSubIdx.getImm();
1316  return true;
1317 }
1318 
1320  const MachineInstr &MI, unsigned DefIdx,
1321  RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const {
1322  assert((MI.isInsertSubreg() ||
1323  MI.isInsertSubregLike()) && "Instruction do not have the proper type");
1324 
1325  if (!MI.isInsertSubreg())
1326  return getInsertSubregLikeInputs(MI, DefIdx, BaseReg, InsertedReg);
1327 
1328  // We are looking at:
1329  // Def = INSERT_SEQUENCE v0, v1, sub0.
1330  assert(DefIdx == 0 && "INSERT_SUBREG only has one def");
1331  const MachineOperand &MOBaseReg = MI.getOperand(1);
1332  const MachineOperand &MOInsertedReg = MI.getOperand(2);
1333  if (MOInsertedReg.isUndef())
1334  return false;
1335  const MachineOperand &MOSubIdx = MI.getOperand(3);
1336  assert(MOSubIdx.isImm() &&
1337  "One of the subindex of the reg_sequence is not an immediate");
1338  BaseReg.Reg = MOBaseReg.getReg();
1339  BaseReg.SubReg = MOBaseReg.getSubReg();
1340 
1341  InsertedReg.Reg = MOInsertedReg.getReg();
1342  InsertedReg.SubReg = MOInsertedReg.getSubReg();
1343  InsertedReg.SubIdx = (unsigned)MOSubIdx.getImm();
1344  return true;
1345 }
1346 
1347 // Returns a MIRPrinter comment for this machine operand.
1349  const MachineInstr &MI, const MachineOperand &Op, unsigned OpIdx,
1350  const TargetRegisterInfo *TRI) const {
1351 
1352  if (!MI.isInlineAsm())
1353  return "";
1354 
1355  std::string Flags;
1356  raw_string_ostream OS(Flags);
1357 
1358  if (OpIdx == InlineAsm::MIOp_ExtraInfo) {
1359  // Print HasSideEffects, MayLoad, MayStore, IsAlignStack
1360  unsigned ExtraInfo = Op.getImm();
1361  bool First = true;
1362  for (StringRef Info : InlineAsm::getExtraInfoNames(ExtraInfo)) {
1363  if (!First)
1364  OS << " ";
1365  First = false;
1366  OS << Info;
1367  }
1368 
1369  return OS.str();
1370  }
1371 
1372  int FlagIdx = MI.findInlineAsmFlagIdx(OpIdx);
1373  if (FlagIdx < 0 || (unsigned)FlagIdx != OpIdx)
1374  return "";
1375 
1376  assert(Op.isImm() && "Expected flag operand to be an immediate");
1377  // Pretty print the inline asm operand descriptor.
1378  unsigned Flag = Op.getImm();
1379  unsigned Kind = InlineAsm::getKind(Flag);
1380  OS << InlineAsm::getKindName(Kind);
1381 
1382  unsigned RCID = 0;
1385  if (TRI) {
1386  OS << ':' << TRI->getRegClassName(TRI->getRegClass(RCID));
1387  } else
1388  OS << ":RC" << RCID;
1389  }
1390 
1391  if (InlineAsm::isMemKind(Flag)) {
1392  unsigned MCID = InlineAsm::getMemoryConstraintID(Flag);
1393  OS << ":" << InlineAsm::getMemConstraintName(MCID);
1394  }
1395 
1396  unsigned TiedTo = 0;
1398  OS << " tiedto:$" << TiedTo;
1399 
1400  return OS.str();
1401 }
1402 
1404 
1406  Function &F, std::vector<outliner::Candidate> &Candidates) const {
1407  // Include target features from an arbitrary candidate for the outlined
1408  // function. This makes sure the outlined function knows what kinds of
1409  // instructions are going into it. This is fine, since all parent functions
1410  // must necessarily support the instructions that are in the outlined region.
1411  outliner::Candidate &FirstCand = Candidates.front();
1412  const Function &ParentFn = FirstCand.getMF()->getFunction();
1413  if (ParentFn.hasFnAttribute("target-features"))
1414  F.addFnAttr(ParentFn.getFnAttribute("target-features"));
1415  if (ParentFn.hasFnAttribute("target-cpu"))
1416  F.addFnAttr(ParentFn.getFnAttribute("target-cpu"));
1417 
1418  // Set nounwind, so we don't generate eh_frame.
1419  if (llvm::all_of(Candidates, [](const outliner::Candidate &C) {
1420  return C.getMF()->getFunction().hasFnAttribute(Attribute::NoUnwind);
1421  }))
1422  F.addFnAttr(Attribute::NoUnwind);
1423 }
1424 
1426  unsigned &Flags) const {
1427  // Some instrumentations create special TargetOpcode at the start which
1428  // expands to special code sequences which must be present.
1429  auto First = MBB.getFirstNonDebugInstr();
1430  if (First != MBB.end() &&
1431  (First->getOpcode() == TargetOpcode::FENTRY_CALL ||
1432  First->getOpcode() == TargetOpcode::PATCHABLE_FUNCTION_ENTER))
1433  return false;
1434 
1435  return true;
1436 }
llvm::DIExpression::prepend
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
Definition: DebugInfoMetadata.cpp:1492
i
i
Definition: README.txt:29
llvm::MCInstrDesc::getNumDefs
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Definition: MCInstrDesc.h:245
llvm::TargetInstrInfo::hasReassociableSibling
bool hasReassociableSibling(const MachineInstr &Inst, bool &Commuted) const
Return true when \P Inst has reassociable sibling.
Definition: TargetInstrInfo.cpp:718
llvm::MCSchedModel::HighLatency
unsigned HighLatency
Definition: MCSchedule.h:292
llvm::MachineFunctionProperties::hasProperty
bool hasProperty(Property P) const
Definition: MachineFunction.h:192
llvm::TargetLoweringBase::getStackPointerRegisterToSaveRestore
Register getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
Definition: TargetLowering.h:1827
llvm::TargetInstrInfo::getMemOperandWithOffset
bool getMemOperandWithOffset(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, const TargetRegisterInfo *TRI) const
Get the base operand and byte offset of an instruction that reads/writes memory.
Definition: TargetInstrInfo.cpp:1071
ScoreboardHazardRecognizer.h
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
llvm::MachineInstrBuilder::addImm
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Definition: MachineInstrBuilder.h:131
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MCAsmInfo::getCommentString
StringRef getCommentString() const
Definition: MCAsmInfo.h:653
llvm::StackMapOpers
MI-level stackmap operands.
Definition: StackMaps.h:35
llvm::MachineOperand::setIsInternalRead
void setIsInternalRead(bool Val=true)
Definition: MachineOperand.h:527
llvm::ISD::PATCHPOINT
@ PATCHPOINT
Definition: ISDOpcodes.h:1299
llvm::MCAsmInfo::getSeparatorString
const char * getSeparatorString() const
Definition: MCAsmInfo.h:647
UseMI
MachineInstrBuilder & UseMI
Definition: AArch64ExpandPseudoInsts.cpp:107
TargetFrameLowering.h
llvm::TargetInstrInfo::duplicate
virtual MachineInstr & duplicate(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) const
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
Definition: TargetInstrInfo.cpp:434
llvm::TargetInstrInfo::CreateTargetHazardRecognizer
virtual ScheduleHazardRecognizer * CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
Definition: TargetInstrInfo.cpp:1051
llvm::MachineOperand::CreateReg
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
Definition: MachineOperand.h:800
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::MachineRegisterInfo::createVirtualRegister
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Definition: MachineRegisterInfo.cpp:156
DebugInfoMetadata.h
llvm::MachineInstr::isNotDuplicable
bool isNotDuplicable(QueryType Type=AnyInBundle) const
Return true if this instruction cannot be safely duplicated.
Definition: MachineInstr.h:970
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:50
llvm::MachineInstrBuilder::add
const MachineInstrBuilder & add(const MachineOperand &MO) const
Definition: MachineInstrBuilder.h:224
llvm::Function
Definition: Function.h:60
getFunction
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:236
llvm::TargetInstrInfo::isThroughputPattern
virtual bool isThroughputPattern(MachineCombinerPattern Pattern) const
Return true when a code sequence can improve throughput.
Definition: TargetInstrInfo.cpp:800
llvm::MachineInstr::memoperands_begin
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
Definition: MachineInstr.h:731
llvm::InlineAsm::getKindName
static StringRef getKindName(unsigned Kind)
Definition: InlineAsm.h:414
llvm::TargetSubtargetInfo::getInstrInfo
virtual const TargetInstrInfo * getInstrInfo() const
Definition: TargetSubtargetInfo.h:95
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:629
llvm::MachineInstr::mayLoad
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Definition: MachineInstr.h:1056
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::MachineOperand::setIsKill
void setIsKill(bool Val=true)
Definition: MachineOperand.h:509
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::TargetInstrInfo::getExtractSubregInputs
bool getExtractSubregInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPairAndIdx &InputReg) const
Build the equivalent inputs of a EXTRACT_SUBREG for the given MI and DefIdx.
Definition: TargetInstrInfo.cpp:1294
llvm::MCInstrDesc::getSchedClass
unsigned getSchedClass() const
Return the scheduling class for this instruction.
Definition: MCInstrDesc.h:618
llvm::MachineFunction::getMachineMemOperand
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
Definition: MachineFunction.cpp:454
llvm::TargetInstrInfo::RegSubRegPairAndIdx
A pair composed of a pair of a register and a sub-register index, and another sub-register index.
Definition: TargetInstrInfo.h:512
llvm::TargetInstrInfo::getMachineCombinerPatterns
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns, bool DoRegPressureReduce) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
Definition: TargetInstrInfo.cpp:776
ErrorHandling.h
llvm::VirtRegMap
Definition: VirtRegMap.h:33
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
llvm::MachineRegisterInfo::getUniqueVRegDef
MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
Definition: MachineRegisterInfo.cpp:407
llvm::SDNode
Represents one node in the SelectionDAG.
Definition: SelectionDAGNodes.h:463
llvm::TargetSubtargetInfo::getRegisterInfo
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Definition: TargetSubtargetInfo.h:127
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::PseudoSourceValue::mayAlias
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:53
llvm::MachineOperand::setImm
void setImm(int64_t immVal)
Definition: MachineOperand.h:664
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:237
llvm::TargetInstrInfo::insertNoops
virtual void insertNoops(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Quantity) const
Insert noops into the instruction stream at the specified point.
Definition: TargetInstrInfo.cpp:73
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:321
llvm::MachineFunction::CreateMachineInstr
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
Definition: MachineFunction.cpp:373
llvm::MCSchedModel::LoadLatency
unsigned LoadLatency
Definition: MCSchedule.h:285
llvm::InlineAsm::isUseOperandTiedToDef
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
Definition: InlineAsm.h:369
llvm::TargetInstrInfo::ReplaceTailWithBranchTo
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const
Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to ...
Definition: TargetInstrInfo.cpp:140
TargetInstrInfo.h
llvm::MachineMemOperand
A description of a memory reference used in the backend.
Definition: MachineMemOperand.h:127
llvm::MachineInstr::getMF
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
Definition: MachineInstr.cpp:678
llvm::Optional
Definition: APInt.h:33
llvm::TargetInstrInfo::isCopyInstr
Optional< DestSourcePair > isCopyInstr(const MachineInstr &MI) const
If the specific machine instruction is a instruction that moves/copies value from one register to ano...
Definition: TargetInstrInfo.h:1035
llvm::TargetInstrInfo::getNop
virtual MCInst getNop() const
Return the noop instruction to use for a noop.
Definition: TargetInstrInfo.cpp:474
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2596
llvm::TargetInstrInfo::getInsertSubregInputs
bool getInsertSubregInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const
Build the equivalent inputs of a INSERT_SUBREG for the given MI and DefIdx.
Definition: TargetInstrInfo.cpp:1319
llvm::MachineFunction::cloneMachineInstrBundle
MachineInstr & cloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
Definition: MachineFunction.cpp:388
llvm::TargetSchedModel::getInstrItineraries
const InstrItineraryData * getInstrItineraries() const
Definition: TargetSchedule.h:82
llvm::PatchPointOpers
MI-level patchpoint operands.
Definition: StackMaps.h:76
llvm::InstrItineraryData::getOperandCycle
int getOperandCycle(unsigned ItinClassIndx, unsigned OperandIdx) const
Return the cycle for the given class and operand.
Definition: MCInstrItineraries.h:167
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::MCOperandInfo::isLookupPtrRegClass
bool isLookupPtrRegClass() const
Set if this operand is a pointer value and it requires a callback to look up its register class.
Definition: MCInstrDesc.h:103
isAsmComment
static bool isAsmComment(const char *Str, const MCAsmInfo &MAI)
Definition: TargetInstrInfo.cpp:80
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1400
llvm::MachineInstr::addMemOperand
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
Definition: MachineInstr.cpp:368
llvm::TargetInstrInfo::isHighLatencyDef
virtual bool isHighLatencyDef(int opc) const
Return true if this opcode has high latency to its result.
Definition: TargetInstrInfo.h:1648
F
#define F(x, y, z)
Definition: MD5.cpp:55
MachineRegisterInfo.h
llvm::TargetInstrInfo::RegSubRegPair
A pair composed of a register and a sub-register index.
Definition: TargetInstrInfo.h:494
llvm::InstrItineraryData::getOperandLatency
int getOperandLatency(unsigned DefClass, unsigned DefIdx, unsigned UseClass, unsigned UseIdx) const
Compute and return the use operand latency of a given itinerary class and operand index if the value ...
Definition: MCInstrItineraries.h:205
llvm::MachineBasicBlock::erase
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Definition: MachineBasicBlock.cpp:1314
llvm::TargetInstrInfo::insertBranch
virtual unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const
Insert branch code into the end of the specified MachineBasicBlock.
Definition: TargetInstrInfo.h:712
DisableHazardRecognizer
static cl::opt< bool > DisableHazardRecognizer("disable-sched-hazard", cl::Hidden, cl::init(false), cl::desc("Disable hazard detection during preRA scheduling"))
llvm::MachineCombinerPattern::REASSOC_AX_YB
@ REASSOC_AX_YB
llvm::MachineInstr::getFlags
uint16_t getFlags() const
Return the MI flags bitvector.
Definition: MachineInstr.h:352
llvm::TargetInstrInfo::getFrameSize
int64_t getFrameSize(const MachineInstr &I) const
Returns size of the frame associated with the given frame instruction.
Definition: TargetInstrInfo.h:223
llvm::MachineBasicBlock::addSuccessor
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
Definition: MachineBasicBlock.cpp:762
llvm::MachineOperand::isKill
bool isKill() const
Definition: MachineOperand.h:389
CommandLine.h
TargetLowering.h
llvm::TargetInstrInfo::getRegClass
virtual const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum,...
Definition: TargetInstrInfo.cpp:46
llvm::TargetRegisterClass::contains
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
Definition: TargetRegisterInfo.h:97
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1709
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:667
MCInstrItineraries.h
llvm::TargetInstrInfo::usePreRAHazardRecognizer
bool usePreRAHazardRecognizer() const
Provide a global flag for disabling the PreRA hazard recognizer that targets may choose to honor.
Definition: TargetInstrInfo.cpp:1045
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:98
llvm::TargetInstrInfo::commuteInstructionImpl
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
Definition: TargetInstrInfo.cpp:166
llvm::TargetInstrInfo::loadRegFromStackSlot
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Load the specified register of the given register class from the specified stack frame index.
Definition: TargetInstrInfo.h:1076
getReg
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
Definition: MipsDisassembler.cpp:517
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MachineOperand::getImm
int64_t getImm() const
Definition: MachineOperand.h:546
llvm::DIExpression::ApplyOffset
@ ApplyOffset
Definition: DebugInfoMetadata.h:2801
llvm::MachineInstr::setMemRefs
void setMemRefs(MachineFunction &MF, ArrayRef< MachineMemOperand * > MemRefs)
Assign this MachineInstr's memory reference descriptor list.
Definition: MachineInstr.cpp:357
llvm::TargetInstrInfo::getInsertSubregLikeInputs
virtual bool getInsertSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const
Target-dependent implementation of getInsertSubregInputs.
Definition: TargetInstrInfo.h:1289
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MachineInstr::getOperand
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:526
llvm::outliner::Candidate::getMF
MachineFunction * getMF() const
Definition: MachineOutliner.h:140
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3490
llvm::TargetInstrInfo::setSpecialOperandAttr
virtual void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2, MachineInstr &NewMI1, MachineInstr &NewMI2) const
This is an architecture-specific helper function of reassociateOps.
Definition: TargetInstrInfo.h:1214
llvm::MachineOperand::setSubReg
void setSubReg(unsigned subReg)
Definition: MachineOperand.h:480
llvm::Register::isPhysicalRegister
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Definition: Register.h:65
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::TargetInstrInfo::getRegSequenceLikeInputs
virtual bool getRegSequenceLikeInputs(const MachineInstr &MI, unsigned DefIdx, SmallVectorImpl< RegSubRegPairAndIdx > &InputRegs) const
Target-dependent implementation of getRegSequenceInputs.
Definition: TargetInstrInfo.h:1260
llvm::TargetInstrInfo::isReassociationCandidate
bool isReassociationCandidate(const MachineInstr &Inst, bool &Commuted) const
Return true if the input \P Inst is part of a chain of dependent ops that are suitable for reassociat...
Definition: TargetInstrInfo.cpp:748
llvm::MachineFunction::getProperties
const MachineFunctionProperties & getProperties() const
Get the function properties.
Definition: MachineFunction.h:748
llvm::TargetInstrInfo::insertNoop
virtual void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
Insert a noop into the instruction stream at the specified point.
Definition: TargetInstrInfo.cpp:66
llvm::MachineOperand::isMBB
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
Definition: MachineOperand.h:328
PseudoSourceValue.h
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:125
llvm::TargetInstrInfo::getNumMicroOps
virtual unsigned getNumMicroOps(const InstrItineraryData *ItinData, const MachineInstr &MI) const
Return the number of u-operations the given machine instruction will be decoded to on the target cpu.
Definition: TargetInstrInfo.cpp:1120
llvm::MCInstrDesc
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:197
llvm::ScoreboardHazardRecognizer
Definition: ScoreboardHazardRecognizer.h:29
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
llvm::Function::getFnAttribute
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.cpp:655
llvm::MCInstrDesc::isCommutable
bool isCommutable() const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z,...
Definition: MCInstrDesc.h:478
llvm::TargetInstrInfo::~TargetInstrInfo
virtual ~TargetInstrInfo()
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:147
llvm::TargetInstrInfo::mergeOutliningCandidateAttributes
virtual void mergeOutliningCandidateAttributes(Function &F, std::vector< outliner::Candidate > &Candidates) const
Optional target hook to create the LLVM IR attributes for the outlined function.
Definition: TargetInstrInfo.cpp:1405
MachineCombinerPattern.h
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
llvm::StringRef::data
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
llvm::TargetInstrInfo::defaultDefLatency
unsigned defaultDefLatency(const MCSchedModel &SchedModel, const MachineInstr &DefMI) const
Return the default expected latency for a def based on its opcode.
Definition: TargetInstrInfo.cpp:1136
llvm::InstrItineraryData::Itineraries
const InstrItinerary * Itineraries
Array of itineraries selected.
Definition: MCInstrItineraries.h:116
llvm::MachineFrameInfo::getObjectOffset
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
Definition: MachineFrameInfo.h:526
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::MachineInstr::isIdenticalTo
bool isIdenticalTo(const MachineInstr &Other, MICheckType Check=CheckDefs) const
Return true if this instruction is identical to Other.
Definition: MachineInstr.cpp:598
llvm::PseudoSourceValue
Special value supplied for machine level alias analysis.
Definition: PseudoSourceValue.h:35
llvm::MCOperandInfo::RegClass
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Definition: MCInstrDesc.h:90
llvm::TargetInstrInfo::isMBBSafeToOutlineFrom
virtual bool isMBBSafeToOutlineFrom(MachineBasicBlock &MBB, unsigned &Flags) const
Optional target hook that returns true if MBB is safe to outline from, and returns any target-specifi...
Definition: TargetInstrInfo.cpp:1425
llvm::InlineAsm::getKind
static unsigned getKind(unsigned Flags)
Definition: InlineAsm.h:351
RegSubRegPairAndIdx
TargetInstrInfo::RegSubRegPairAndIdx RegSubRegPairAndIdx
Definition: PeepholeOptimizer.cpp:101
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::TargetInstrInfo::hasReassociableOperands
virtual bool hasReassociableOperands(const MachineInstr &Inst, const MachineBasicBlock *MBB) const
Return true when \P Inst has reassociable operands in the same \P MBB.
Definition: TargetInstrInfo.cpp:699
llvm::InlineAsm::isMemKind
static bool isMemKind(unsigned Flag)
Definition: InlineAsm.h:301
llvm::TargetRegisterInfo::getPointerRegClass
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
Definition: TargetRegisterInfo.h:791
llvm::MachineRegisterInfo::getRegClass
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Definition: MachineRegisterInfo.h:647
llvm::MachineFunctionProperties::Property::NoVRegs
@ NoVRegs
llvm::TargetInstrInfo::createMIROperandComment
virtual std::string createMIROperandComment(const MachineInstr &MI, const MachineOperand &Op, unsigned OpIdx, const TargetRegisterInfo *TRI) const
Definition: TargetInstrInfo.cpp:1348
llvm::InstrItinerary::NumMicroOps
int16_t NumMicroOps
Definition: MCInstrItineraries.h:99
llvm::MCAsmInfo::getMaxInstLength
virtual unsigned getMaxInstLength(const MCSubtargetInfo *STI=nullptr) const
Returns the maximum possible encoded instruction size in bytes.
Definition: MCAsmInfo.h:639
llvm::MIMetadata
Set of metadata that should be preserved when using BuildMI().
Definition: MachineInstrBuilder.h:335
llvm::MCOperandInfo::isPredicate
bool isPredicate() const
Set if this is one of the operands that made up of the predicate operand that controls an isPredicabl...
Definition: MCInstrDesc.h:109
llvm::TargetInstrInfo::isAssociativeAndCommutative
virtual bool isAssociativeAndCommutative(const MachineInstr &Inst) const
Return true when \P Inst is both associative and commutative.
Definition: TargetInstrInfo.h:1174
llvm::TargetInstrInfo::PredicateInstruction
virtual bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const
Convert the instruction into a predicated instruction.
Definition: TargetInstrInfo.cpp:330
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:657
llvm::MachineInstrBuilder::addFrameIndex
const MachineInstrBuilder & addFrameIndex(int Idx) const
Definition: MachineInstrBuilder.h:152
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:629
llvm::cl::opt< bool >
llvm::TargetInstrInfo::getStackSlotRange
virtual bool getStackSlotRange(const TargetRegisterClass *RC, unsigned SubIdx, unsigned &Size, unsigned &Offset, const MachineFunction &MF) const
Compute the size in bytes and offset within a stack slot of a spilled register or subregister.
Definition: TargetInstrInfo.cpp:388
llvm::TargetFrameLowering::alignSPAdjust
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
Definition: TargetFrameLowering.h:105
llvm::TargetRegisterInfo::getSpillSize
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
Definition: TargetRegisterInfo.h:286
llvm::MachineOperand::isUndef
bool isUndef() const
Definition: MachineOperand.h:394
TargetSchedule.h
llvm::TargetRegisterInfo::getRegClass
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
Definition: TargetRegisterInfo.h:771
llvm::TargetInstrInfo::RegSubRegPair::Reg
Register Reg
Definition: TargetInstrInfo.h:495
llvm::TargetSchedModel
Provide an instruction scheduling machine model to CodeGen passes.
Definition: TargetSchedule.h:30
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition: MachineOperand.h:320
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::MachineInstrBuilder
Definition: MachineInstrBuilder.h:69
llvm::MachineFrameInfo::getObjectSize
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Definition: MachineFrameInfo.h:470
llvm::TargetRegisterInfo::getRegClassName
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
Definition: TargetRegisterInfo.h:777
llvm::MachineFunction::CloneMachineInstr
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
Definition: MachineFunction.cpp:383
llvm::TargetInstrInfo::isPredicated
virtual bool isPredicated(const MachineInstr &MI) const
Returns true if the instruction is already predicated.
Definition: TargetInstrInfo.h:1445
llvm::outliner::Candidate
An individual sequence of instructions to be replaced with a call to an outlined function.
Definition: MachineOutliner.h:37
llvm::DataLayout::isLittleEndian
bool isLittleEndian() const
Layout endianness...
Definition: DataLayout.h:244
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
llvm::DenseMap< unsigned, unsigned >
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::InlineAsm::isImmKind
static bool isImmKind(unsigned Flag)
Definition: InlineAsm.h:300
llvm::MachineFrameInfo::getObjectAlign
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
Definition: MachineFrameInfo.h:484
StringExtras.h
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:447
llvm::outliner::Candidate::front
MachineBasicBlock::iterator & front()
Definition: MachineOutliner.h:138
llvm::TargetInstrInfo::hasStoreToStackSlot
virtual bool hasStoreToStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand * > &Accesses) const
If the specified machine instruction has a store to a stack slot, return true along with the FrameInd...
Definition: TargetInstrInfo.cpp:374
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1843
llvm::ParamLoadedValue
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
Definition: TargetInstrInfo.h:67
llvm::TargetInstrInfo::commuteInstruction
MachineInstr * commuteInstruction(MachineInstr &MI, bool NewMI=false, unsigned OpIdx1=CommuteAnyOperandIndex, unsigned OpIdx2=CommuteAnyOperandIndex) const
This method commutes the operands of the given machine instruction MI.
Definition: TargetInstrInfo.cpp:249
llvm::MachineInstr::mmo_iterator
ArrayRef< MachineMemOperand * >::iterator mmo_iterator
Definition: MachineInstr.h:70
llvm::Register::isVirtualRegister
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
Definition: Register.h:71
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineBasicBlock::succ_begin
succ_iterator succ_begin()
Definition: MachineBasicBlock.h:369
llvm::TargetInstrInfo::describeLoadedValue
virtual Optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg.
Definition: TargetInstrInfo.cpp:1175
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:853
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:673
llvm::TargetInstrInfo::PipelinerLoopInfo::~PipelinerLoopInfo
virtual ~PipelinerLoopInfo()
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition: MachineBasicBlock.h:261
llvm::ISD::STACKMAP
@ STACKMAP
Definition: ISDOpcodes.h:1293
llvm::MachineInstr::memoperands_end
mmo_iterator memoperands_end() const
Access to memory operands of the instruction.
Definition: MachineInstr.h:738
llvm::InlineAsm::getMemoryConstraintID
static unsigned getMemoryConstraintID(unsigned Flag)
Definition: InlineAsm.h:355
llvm::MCInstrDesc::OpInfo
const MCOperandInfo * OpInfo
Definition: MCInstrDesc.h:208
llvm::TargetFrameLowering::getStackGrowthDirection
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
Definition: TargetFrameLowering.h:89
llvm::TargetInstrInfo::produceSameValue
virtual bool produceSameValue(const MachineInstr &MI0, const MachineInstr &MI1, const MachineRegisterInfo *MRI=nullptr) const
Return true if two machine instructions would produce identical values.
Definition: TargetInstrInfo.cpp:428
llvm::MachineInstrBuilder::addReg
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Definition: MachineInstrBuilder.h:97
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:359
llvm::MachineCombinerPattern::REASSOC_AX_BY
@ REASSOC_AX_BY
llvm::ScheduleDAGMI
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
Definition: MachineScheduler.h:273
llvm::TargetInstrInfo::getPatchpointUnfoldableRange
virtual std::pair< unsigned, unsigned > getPatchpointUnfoldableRange(const MachineInstr &MI) const
For a patchpoint, stackmap, or statepoint intrinsic, return the range of operands which can't be fold...
Definition: TargetInstrInfo.cpp:477
llvm::SDNode::isMachineOpcode
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode.
Definition: SelectionDAGNodes.h:699
llvm::MachineInstr::IgnoreVRegDefs
@ IgnoreVRegDefs
Definition: MachineInstr.h:1195
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::TargetInstrInfo::getSPAdjust
virtual int getSPAdjust(const MachineInstr &MI) const
Returns the actual stack pointer adjustment made by an instruction as part of a call sequence.
Definition: TargetInstrInfo.cpp:998
llvm::MachineBasicBlock::succ_empty
bool succ_empty() const
Definition: MachineBasicBlock.h:384
llvm::ScheduleDAG
Definition: ScheduleDAG.h:554
llvm::TargetInstrInfo::getPredicationCost
virtual unsigned getPredicationCost(const MachineInstr &MI) const
Definition: TargetInstrInfo.cpp:1147
llvm::TargetInstrInfo::hasLoadFromStackSlot
virtual bool hasLoadFromStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand * > &Accesses) const
If the specified machine instruction has a load from a stack slot, return true along with the FrameIn...
Definition: TargetInstrInfo.cpp:360
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::TargetInstrInfo::RegSubRegPair::SubReg
unsigned SubReg
Definition: TargetInstrInfo.h:496
MCAsmInfo.h
DataLayout.h
llvm::MachineBasicBlock::getFirstNonDebugInstr
iterator getFirstNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the first non-debug instruction in the basic block, or end().
Definition: MachineBasicBlock.cpp:258
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Dwarf.h
llvm::MachineInstr::getOpcode
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:516
llvm::MachineRegisterInfo::hasOneNonDBGUse
bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
Definition: MachineRegisterInfo.cpp:415
llvm::TargetInstrInfo::reMaterialize
virtual void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, unsigned SubIdx, const MachineInstr &Orig, const TargetRegisterInfo &TRI) const
Re-issue the specified 'original' instruction at the specific location targeting a new destination re...
Definition: TargetInstrInfo.cpp:418
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::TargetInstrInfo::storeRegToStackSlot
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index.
Definition: TargetInstrInfo.h:1064
llvm::MachineOperand::setIsUndef
void setIsUndef(bool Val=true)
Definition: MachineOperand.h:520
llvm::MachineOperand::setIsRenamable
void setIsRenamable(bool Val=true)
Definition: MachineOperand.cpp:137
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::InlineAsm::getMemConstraintName
static StringRef getMemConstraintName(unsigned Constraint)
Definition: InlineAsm.h:434
llvm::MachineInstr::getParent
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:313
llvm::TargetInstrInfo::isUnpredicatedTerminator
bool isUnpredicatedTerminator(const MachineInstr &MI) const
Returns true if the instruction is a terminator instruction that has not been predicated.
Definition: TargetInstrInfo.cpp:319
llvm::MachineInstr::getRegClassConstraint
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
Definition: MachineInstr.cpp:875
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:207
llvm::TargetInstrInfo::isFrameInstr
bool isFrameInstr(const MachineInstr &I) const
Returns true if the argument is a frame pseudo instruction.
Definition: TargetInstrInfo.h:205
llvm::TargetSubtargetInfo
TargetSubtargetInfo - Generic base class for all target subtargets.
Definition: TargetSubtargetInfo.h:62
llvm::MachineMemOperand::MOLoad
@ MOLoad
The memory access reads data.
Definition: MachineMemOperand.h:134
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::TargetInstrInfo::fixCommutedOpIndices
static bool fixCommutedOpIndices(unsigned &ResultIdx1, unsigned &ResultIdx2, unsigned CommutableOpIdx1, unsigned CommutableOpIdx2)
Assigns the (CommutableOpIdx1, CommutableOpIdx2) pair of commutable operand indices to (ResultIdx1,...
Definition: TargetInstrInfo.cpp:264
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineOperand::getSubReg
unsigned getSubReg() const
Definition: MachineOperand.h:364
llvm::MachineRegisterInfo::isConstantPhysReg
bool isConstantPhysReg(MCRegister PhysReg) const
Returns true if PhysReg is unallocatable and constant throughout the function.
Definition: MachineRegisterInfo.cpp:515
llvm::TargetInstrInfo::isSchedulingBoundary
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
Definition: TargetInstrInfo.cpp:1022
llvm::ISD::FrameIndex
@ FrameIndex
Definition: ISDOpcodes.h:80
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
llvm::MachineInstr::canFoldAsLoad
bool canFoldAsLoad(QueryType Type=IgnoreBundle) const
Return true for instructions that can be folded as memory operands in other instructions.
Definition: MachineInstr.h:1002
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
j
return j(j<< 16)
llvm::DIExpression::appendOffset
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
Definition: DebugInfoMetadata.cpp:1421
llvm::DIExpression::prependOpcodes
static DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
Definition: DebugInfoMetadata.cpp:1554
llvm::StatepointOpers
MI-level Statepoint operands.
Definition: StackMaps.h:158
llvm::TargetInstrInfo::getCallFrameDestroyOpcode
unsigned getCallFrameDestroyOpcode() const
Definition: TargetInstrInfo.h:202
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:623
llvm::TargetSubtargetInfo::getFrameLowering
virtual const TargetFrameLowering * getFrameLowering() const
Definition: TargetSubtargetInfo.h:96
llvm::InstrItineraryData::getStageLatency
unsigned getStageLatency(unsigned ItinClassIndx) const
Return the total stage latency of the given class.
Definition: MCInstrItineraries.h:149
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::InlineAsm::hasRegClassConstraint
static bool hasRegClassConstraint(unsigned Flag, unsigned &RC)
hasRegClassConstraint - Returns true if the flag contains a register class constraint.
Definition: InlineAsm.h:378
llvm::MachineBasicBlock::removeSuccessor
void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
Definition: MachineBasicBlock.cpp:800
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::TargetInstrInfo::getMemOperandsWithOffsetWidth
virtual bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, unsigned &Width, const TargetRegisterInfo *TRI) const
Get zero or more base operands and the byte offset of an instruction that reads/writes memory.
Definition: TargetInstrInfo.h:1362
llvm::MachineInstr::cloneInstrSymbols
void cloneInstrSymbols(MachineFunction &MF, const MachineInstr &MI)
Clone another MachineInstr's pre- and post- instruction symbols and replace ours with it.
Definition: MachineInstr.cpp:519
llvm::MachineBasicBlock::insert
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Definition: MachineBasicBlock.cpp:1327
llvm::ilist_iterator
Iterator for intrusive lists based on ilist_node.
Definition: ilist_iterator.h:57
MachineFrameInfo.h
llvm::MachineInstr::mayStore
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Definition: MachineInstr.h:1069
llvm::MachineMemOperand::getSize
uint64_t getSize() const
Return the size in bytes of the memory reference.
Definition: MachineMemOperand.h:235
foldPatchpoint
static MachineInstr * foldPatchpoint(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, const TargetInstrInfo &TII)
Definition: TargetInstrInfo.cpp:494
llvm::ISD::INLINEASM_BR
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
Definition: ISDOpcodes.h:1028
llvm::TargetInstrInfo::reassociateOps
void reassociateOps(MachineInstr &Root, MachineInstr &Prev, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const
Attempt to reassociate \P Root and \P Prev according to \P Pattern to reduce critical path length.
Definition: TargetInstrInfo.cpp:806
llvm::InlineAsm::getExtraInfoNames
static std::vector< StringRef > getExtraInfoNames(unsigned ExtraInfo)
Definition: InlineAsm.h:390
llvm::TargetInstrInfo::getRegSequenceInputs
bool getRegSequenceInputs(const MachineInstr &MI, unsigned DefIdx, SmallVectorImpl< RegSubRegPairAndIdx > &InputRegs) const
Build the equivalent inputs of a REG_SEQUENCE for the given MI and DefIdx.
Definition: TargetInstrInfo.cpp:1267
llvm::TargetInstrInfo::CreateTargetMIHazardRecognizer
virtual ScheduleHazardRecognizer * CreateTargetMIHazardRecognizer(const InstrItineraryData *, const ScheduleDAGMI *DAG) const
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
Definition: TargetInstrInfo.cpp:1058
StackMaps.h
llvm::MCSchedModel
Machine model for scheduling, bundling, and heuristics.
Definition: MCSchedule.h:244
llvm::TargetInstrInfo::getInstrLatency
virtual unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const
Compute the instruction latency of a given instruction.
Definition: TargetInstrInfo.cpp:1151
llvm::LiveIntervals
Definition: LiveIntervals.h:53
llvm::MachineOperand::isImm
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
Definition: MachineOperand.h:322
llvm::MachineMemOperand::MOStore
@ MOStore
The memory access writes data.
Definition: MachineMemOperand.h:136
llvm::AMDGPU::Hwreg::Width
Width
Definition: SIDefines.h:439
llvm::SDNode::getMachineOpcode
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
Definition: SelectionDAGNodes.h:704
llvm::TargetInstrInfo::hasLowDefLatency
virtual bool hasLowDefLatency(const TargetSchedModel &SchedModel, const MachineInstr &DefMI, unsigned DefIdx) const
Compute operand latency of a def of 'Reg'.
Definition: TargetInstrInfo.cpp:1162
llvm::TargetInstrInfo::getCallFrameSetupOpcode
unsigned getCallFrameSetupOpcode() const
These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise).
Definition: TargetInstrInfo.h:201
canFoldCopy
static const TargetRegisterClass * canFoldCopy(const MachineInstr &MI, unsigned FoldIdx)
Definition: TargetInstrInfo.cpp:443
llvm::MachineFrameInfo::isImmutableObjectIndex
bool isImmutableObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an immutable object.
Definition: MachineFrameInfo.h:701
llvm::getKillRegState
unsigned getKillRegState(bool B)
Definition: MachineInstrBuilder.h:546
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:106
MachineScheduler.h
llvm::Pattern
Definition: FileCheckImpl.h:614
llvm::TargetSubtargetInfo::getTargetLowering
virtual const TargetLowering * getTargetLowering() const
Definition: TargetSubtargetInfo.h:99
llvm::TargetInstrInfo::foldMemoryOperandImpl
virtual MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const
Target-dependent implementation for foldMemoryOperand.
Definition: TargetInstrInfo.h:1232
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:357
llvm::MachinePointerInfo::getFixedStack
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Definition: MachineOperand.cpp:1019
llvm::TargetInstrInfo::foldMemoryOperand
MachineInstr * foldMemoryOperand(MachineInstr &MI, ArrayRef< unsigned > Ops, int FI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const
Attempt to fold a load or store of the specified stack slot into the specified machine instruction fo...
Definition: TargetInstrInfo.cpp:559
MachineInstrBuilder.h
llvm::RISCVMatInt::RegImm
@ RegImm
Definition: RISCVMatInt.h:22
llvm::TargetInstrInfo::findCommutedOpIndices
virtual bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
Returns true iff the routine could find two commutable operands in the given machine instruction.
Definition: TargetInstrInfo.cpp:295
llvm::MachineInstrBuilder::setMIFlags
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
Definition: MachineInstrBuilder.h:273
N
#define N
llvm::MachineOperand::setReg
void setReg(Register Reg)
Change the register this operand corresponds to.
Definition: MachineOperand.cpp:56
DefMI
MachineInstrBuilder MachineInstrBuilder & DefMI
Definition: AArch64ExpandPseudoInsts.cpp:108
llvm::MachineInstr::getNumOperands
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:519
llvm::TargetInstrInfo::genAlternativeCodeSequence
virtual void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< unsigned, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
Definition: TargetInstrInfo.cpp:892
llvm::MachineCombinerPattern::REASSOC_XA_BY
@ REASSOC_XA_BY
llvm::TargetInstrInfo::getOperandLatency
virtual int getOperandLatency(const InstrItineraryData *ItinData, SDNode *DefNode, unsigned DefIdx, SDNode *UseNode, unsigned UseIdx) const
Definition: TargetInstrInfo.cpp:1089
llvm::CallingConv::Tail
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
Definition: CallingConv.h:76
llvm::MachineOperand::setMBB
void setMBB(MachineBasicBlock *MBB)
Definition: MachineOperand.h:698
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:285
llvm::MachineRegisterInfo::constrainRegClass
const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
Definition: MachineRegisterInfo.cpp:82
llvm::MCRegisterInfo::getSubRegIdxOffset
unsigned getSubRegIdxOffset(unsigned Idx) const
Get the offset of the bit range covered by a sub-register index.
Definition: MCRegisterInfo.cpp:62
llvm::MachineInstr::memoperands
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
Definition: MachineInstr.h:713
MachineMemOperand.h
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::TargetInstrInfo::CreateTargetPostRAHazardRecognizer
virtual ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *, const ScheduleDAG *DAG) const
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
Definition: TargetInstrInfo.cpp:1065
llvm::TargetFrameLowering::StackGrowsDown
@ StackGrowsDown
Definition: TargetFrameLowering.h:47
llvm::InlineAsm::MIOp_ExtraInfo
@ MIOp_ExtraInfo
Definition: InlineAsm.h:226
llvm::TargetRegisterClass::hasSubClassEq
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Definition: TargetRegisterInfo.h:130
llvm::MachineCombinerPattern::REASSOC_XA_YB
@ REASSOC_XA_YB
llvm::MCRegisterInfo::isSuperOrSubRegisterEq
bool isSuperOrSubRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register or sub-register of RegA or if RegB == RegA.
Definition: MCRegisterInfo.h:580
llvm::MCInstrInfo::get
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Definition: MCInstrInfo.h:63
llvm::MCOI::TIED_TO
@ TIED_TO
Definition: MCInstrDesc.h:35
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::cl::desc
Definition: CommandLine.h:413
raw_ostream.h
llvm::TargetInstrInfo::CommuteAnyOperandIndex
static const unsigned CommuteAnyOperandIndex
Definition: TargetInstrInfo.h:441
llvm::MachineInstr::tieOperands
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
Definition: MachineInstr.cpp:1094
llvm::MachineFunction::eraseCallSiteInfo
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
Definition: MachineFunction.cpp:924
llvm::ScheduleHazardRecognizer
HazardRecognizer - This determines whether or not an instruction can be issued this cycle,...
Definition: ScheduleHazardRecognizer.h:25
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::InstrItineraryData::isEmpty
bool isEmpty() const
Returns true if there are no itineraries.
Definition: MCInstrItineraries.h:126
llvm::TargetInstrInfo::isAddImmediate
virtual Optional< RegImmPair > isAddImmediate(const MachineInstr &MI, Register Reg) const
If the specific machine instruction is an instruction that adds an immediate value and a physical reg...
Definition: TargetInstrInfo.h:1046
llvm::raw_string_ostream::str
std::string & str()
Returns the string's reference.
Definition: raw_ostream.h:647
llvm::MachineMemOperand::MONone
@ MONone
Definition: MachineMemOperand.h:132
llvm::MCInstrDesc::getNumOperands
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Definition: MCInstrDesc.h:230
TargetRegisterInfo.h
llvm::InstrItineraryData
Itinerary data supplied by a subtarget to be used by a target.
Definition: MCInstrItineraries.h:109
llvm::MachineBasicBlock::end
iterator end()
Definition: MachineBasicBlock.h:307
SubReg
unsigned SubReg
Definition: AArch64AdvSIMDScalarPass.cpp:104
llvm::TargetInstrInfo::getExtractSubregLikeInputs
virtual bool getExtractSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPairAndIdx &InputReg) const
Target-dependent implementation of getExtractSubregInputs.
Definition: TargetInstrInfo.h:1274
llvm::TargetInstrInfo::RegSubRegPairAndIdx::SubIdx
unsigned SubIdx
Definition: TargetInstrInfo.h:513
llvm::TargetInstrInfo::getInlineAsmLength
virtual unsigned getInlineAsmLength(const char *Str, const MCAsmInfo &MAI, const TargetSubtargetInfo *STI=nullptr) const
Measure the specified inline asm to determine an approximation of its length.
Definition: TargetInstrInfo.cpp:99
llvm::TargetInstrInfo::isLoadFromStackSlot
virtual unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const
If the specified machine instruction is a direct load from a stack slot, return the virtual or physic...
Definition: TargetInstrInfo.h:265
llvm::MachineMemOperand::getPseudoValue
const PseudoSourceValue * getPseudoValue() const
Definition: MachineMemOperand.h:212
llvm::MachineCombinerPattern
MachineCombinerPattern
These are instruction patterns matched by the machine combiner pass.
Definition: MachineCombinerPattern.h:20
llvm::MCRegisterInfo::getSubRegIdxSize
unsigned getSubRegIdxSize(unsigned Idx) const
Get the size of the bit range covered by a sub-register index.
Definition: MCRegisterInfo.cpp:56