32#define DEBUG_TYPE "instr-emitter" 
   44  unsigned N = 
Node->getNumValues();
 
   45  while (
N && 
Node->getValueType(
N - 1) == MVT::Glue)
 
   47  if (
N && 
Node->getValueType(
N - 1) == MVT::Other)
 
 
   60                              unsigned &NumImpUses) {
 
   61  unsigned N = 
Node->getNumOperands();
 
   62  while (
N && 
Node->getOperand(
N - 1).getValueType() == MVT::Glue)
 
   64  if (
N && 
Node->getOperand(
N - 1).getValueType() == MVT::Other)
 
   68  NumImpUses = 
N - NumExpUses;
 
   69  for (
unsigned I = 
N; 
I > NumExpUses; --
I) {
 
   73      if (RN->getReg().isPhysical())
 
 
   85                                   VRBaseMapType &VRBaseMap) {
 
   91    bool isNew = VRBaseMap.insert(std::make_pair(
Op, SrcReg)).second;
 
   93    assert(isNew && 
"Node emitted out of order - early");
 
  100  const TargetRegisterClass *UseRC = 
nullptr;
 
  101  MVT VT = 
Op.getSimpleValueType();
 
  104  if (TLI->isTypeLegal(VT))
 
  105    UseRC = TLI->getRegClassFor(VT, 
Op->isDivergent());
 
  107  for (SDNode *User : 
Op->users()) {
 
  114      } 
else if (DestReg != SrcReg)
 
  117      for (
unsigned i = 0, e = 
User->getNumOperands(); i != e; ++i) {
 
  118        if (
User->getOperand(i) != 
Op)
 
  120        if (VT == MVT::Other || VT == MVT::Glue)
 
  123        if (
User->isMachineOpcode()) {
 
  124          const MCInstrDesc &
II = TII->get(
User->getMachineOpcode());
 
  125          const TargetRegisterClass *RC = 
nullptr;
 
  126          if (i + 
II.getNumDefs() < 
II.getNumOperands()) {
 
  127            RC = TRI->getAllocatableClass(
 
  128                TII->getRegClass(
II, i + 
II.getNumDefs(), TRI));
 
  133            const TargetRegisterClass *ComRC =
 
  134                TRI->getCommonSubClass(UseRC, RC);
 
  148  const TargetRegisterClass *SrcRC = 
nullptr, *DstRC = 
nullptr;
 
  149  SrcRC = TRI->getMinimalPhysRegClass(SrcReg, VT);
 
  153    DstRC = MRI->getRegClass(VRBase);
 
  155    assert(TRI->isTypeLegalForClass(*UseRC, VT) &&
 
  156           "Incompatible phys register def and uses!");
 
  167    VRBase = MRI->createVirtualRegister(DstRC);
 
  168    BuildMI(*MBB, InsertPos, 
Op.getDebugLoc(), TII->get(TargetOpcode::COPY),
 
  175  bool isNew = VRBaseMap.insert(std::make_pair(
Op, VRBase)).second;
 
  177  assert(isNew && 
"Node emitted out of order - early");
 
  180void InstrEmitter::CreateVirtualRegisters(
SDNode *Node,
 
  183                                       bool IsClone, 
bool IsCloned,
 
  184                                       VRBaseMapType &VRBaseMap) {
 
  185  assert(
Node->getMachineOpcode() != TargetOpcode::IMPLICIT_DEF &&
 
  186         "IMPLICIT_DEF should have been handled as a special case elsewhere!");
 
  189  bool HasVRegVariadicDefs = !MF->getTarget().usesPhysRegsForValues() &&
 
  190                             II.isVariadic() && 
II.variadicOpsAreDefs();
 
  191  unsigned NumVRegs = HasVRegVariadicDefs ? NumResults : 
II.getNumDefs();
 
  192  if (
Node->getMachineOpcode() == TargetOpcode::STATEPOINT)
 
  193    NumVRegs = NumResults;
 
  194  for (
unsigned i = 0; i < NumVRegs; ++i) {
 
  199    const TargetRegisterClass *RC =
 
  200        TRI->getAllocatableClass(TII->getRegClass(
II, i, TRI));
 
  205    if (i < NumResults && TLI->isTypeLegal(
Node->getSimpleValueType(i))) {
 
  206      const TargetRegisterClass *VTRC = TLI->getRegClassFor(
 
  207          Node->getSimpleValueType(i),
 
  208          (
Node->isDivergent() || (RC && TRI->isDivergentRegClass(RC))));
 
  210        VTRC = TRI->getCommonSubClass(RC, VTRC);
 
  215    if (!
II.operands().empty() && 
II.operands()[i].isOptionalDef()) {
 
  222    if (!VRBase && !IsClone && !IsCloned)
 
  223      for (SDNode *User : 
Node->users()) {
 
  225            User->getOperand(2).getNode() == Node &&
 
  226            User->getOperand(2).getResNo() == i) {
 
  229            const TargetRegisterClass *RegRC = MRI->getRegClass(
Reg);
 
  242      assert(RC && 
"Isn't a register operand!");
 
  243      VRBase = MRI->createVirtualRegister(RC);
 
  249    if (i < NumResults) {
 
  253      bool isNew = VRBaseMap.insert(std::make_pair(
Op, VRBase)).second;
 
  255      assert(isNew && 
"Node emitted out of order - early");
 
  263  if (
Op.isMachineOpcode() &&
 
  264      Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF) {
 
  268    const TargetRegisterClass *RC = TLI->getRegClassFor(
 
  269        Op.getSimpleValueType(), 
Op.getNode()->isDivergent());
 
  270    Register VReg = MRI->createVirtualRegister(RC);
 
  271    BuildMI(*MBB, InsertPos, 
Op.getDebugLoc(),
 
  272            TII->get(TargetOpcode::IMPLICIT_DEF), VReg);
 
  277  assert(
I != VRBaseMap.end() && 
"Node emitted out of order - late");
 
  282  if (
Op->isMachineOpcode()) {
 
  283    switch (
Op->getMachineOpcode()) {
 
  284    case TargetOpcode::CONVERGENCECTRL_ANCHOR:
 
  285    case TargetOpcode::CONVERGENCECTRL_ENTRY:
 
  286    case TargetOpcode::CONVERGENCECTRL_LOOP:
 
  287    case TargetOpcode::CONVERGENCECTRL_GLUE:
 
  296  switch (
Op->getOpcode()) {
 
  297  case ISD::CONVERGENCECTRL_ANCHOR:
 
  298  case ISD::CONVERGENCECTRL_ENTRY:
 
  299  case ISD::CONVERGENCECTRL_LOOP:
 
  300  case ISD::CONVERGENCECTRL_GLUE:
 
 
  314                                 VRBaseMapType &VRBaseMap,
 
  315                                 bool IsDebug, 
bool IsClone, 
bool IsCloned) {
 
  316  assert(
Op.getValueType() != MVT::Other &&
 
  317         Op.getValueType() != MVT::Glue &&
 
  318         "Chain and glue operands should occur at end of operand list!");
 
  322  const MCInstrDesc &MCID = MIB->
getDesc();
 
  324                  MCID.
operands()[IIOpNum].isOptionalDef();
 
  331    const TargetRegisterClass *OpRC = 
nullptr;
 
  332    if (IIOpNum < II->getNumOperands())
 
  333      OpRC = TII->getRegClass(*
II, IIOpNum, TRI);
 
  339      if (
Op.isMachineOpcode() &&
 
  340          Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF)
 
  343      const TargetRegisterClass *ConstrainedRC
 
  344        = MRI->constrainRegClass(VReg, OpRC, MinNumRegs);
 
  345      if (!ConstrainedRC) {
 
  346        OpRC = TRI->getAllocatableClass(OpRC);
 
  347        assert(OpRC && 
"Constraints cannot be fulfilled for allocation");
 
  348        Register NewVReg = MRI->createVirtualRegister(OpRC);
 
  350                TII->
get(TargetOpcode::COPY), NewVReg)
 
  355           "Constraining an allocatable VReg produced an unallocatable class?");
 
  373                !(IsClone || IsCloned);
 
  394                              VRBaseMapType &VRBaseMap, 
bool IsDebug,
 
  395                              bool IsClone, 
bool IsCloned) {
 
  396  if (
Op.isMachineOpcode()) {
 
  397    AddRegisterOperand(MIB, 
Op, IIOpNum, 
II, VRBaseMap,
 
  398                       IsDebug, IsClone, IsCloned);
 
  400    if (
C->getAPIntValue().getSignificantBits() <= 64) {
 
  404          ConstantInt::get(MF->getFunction().getContext(), 
C->getAPIntValue()));
 
  410    MVT OpVT = 
Op.getSimpleValueType();
 
  411    const TargetRegisterClass *IIRC =
 
  412        II ? TRI->getAllocatableClass(TII->getRegClass(*
II, IIOpNum, TRI))
 
  414    const TargetRegisterClass *OpRC =
 
  415        TLI->isTypeLegal(OpVT)
 
  416            ? TLI->getRegClassFor(OpVT,
 
  417                                  Op.getNode()->isDivergent() ||
 
  418                                      (IIRC && TRI->isDivergentRegClass(IIRC)))
 
  421    if (OpRC && IIRC && OpRC != IIRC && VReg.
isVirtual()) {
 
  422      Register NewVReg = MRI->createVirtualRegister(IIRC);
 
  423      BuildMI(*MBB, InsertPos, 
Op.getNode()->getDebugLoc(),
 
  424               TII->get(TargetOpcode::COPY), NewVReg).
addReg(VReg);
 
  430    bool Imp = 
II && (IIOpNum >= 
II->getNumOperands() && !
II->isVariadic());
 
  436                         TGA->getTargetFlags());
 
  438    MIB.
addMBB(BBNode->getBasicBlock());
 
  445    Align Alignment = 
CP->getAlign();
 
  448    MachineConstantPool *MCP = MF->getConstantPool();
 
  449    if (
CP->isMachineConstantPoolEntry())
 
  457    MIB.
addSym(SymNode->getMCSymbol());
 
  461                        BA->getTargetFlags());
 
  463    MIB.
addTargetIndex(TI->getIndex(), TI->getOffset(), TI->getTargetFlags());
 
  465    assert(
Op.getValueType() != MVT::Other &&
 
  466           Op.getValueType() != MVT::Glue &&
 
  467           "Chain and glue operands should occur at end of operand list!");
 
  468    AddRegisterOperand(MIB, 
Op, IIOpNum, 
II, VRBaseMap,
 
  469                       IsDebug, IsClone, IsCloned);
 
  475  const TargetRegisterClass *VRC = MRI->getRegClass(VReg);
 
  476  const TargetRegisterClass *RC = TRI->getSubClassWithSubReg(VRC, SubIdx);
 
  481    RC = MRI->constrainRegClass(VReg, RC, 
MinRCSize);
 
  489  RC = TRI->getSubClassWithSubReg(TLI->getRegClassFor(VT, isDivergent), SubIdx);
 
  490  assert(RC && 
"No legal register class for VT supports that SubIdx");
 
  491  Register NewReg = MRI->createVirtualRegister(RC);
 
  492  BuildMI(*MBB, InsertPos, 
DL, TII->get(TargetOpcode::COPY), NewReg)
 
  499void InstrEmitter::EmitSubregNode(
SDNode *Node, VRBaseMapType &VRBaseMap,
 
  500                                  bool IsClone, 
bool IsCloned) {
 
  502  unsigned Opc = 
Node->getMachineOpcode();
 
  506  for (SDNode *User : 
Node->users()) {
 
  508        User->getOperand(2).getNode() == Node) {
 
  517  if (
Opc == TargetOpcode::EXTRACT_SUBREG) {
 
  521    unsigned SubIdx = 
Node->getConstantOperandVal(1);
 
  522    const TargetRegisterClass *TRC =
 
  523      TLI->getRegClassFor(
Node->getSimpleValueType(0), 
Node->isDivergent());
 
  528    if (R && 
R->getReg().isPhysical()) {
 
  532      Reg = 
R ? 
R->getReg() : getVR(
Node->getOperand(0), VRBaseMap);
 
  539        TII->isCoalescableExtInstr(*
DefMI, SrcReg, DstReg, DefSubIdx) &&
 
  540        SubIdx == DefSubIdx &&
 
  541        TRC == MRI->getRegClass(SrcReg)) {
 
  547      VRBase = MRI->createVirtualRegister(TRC);
 
  549              TII->get(TargetOpcode::COPY), VRBase).
addReg(SrcReg);
 
  550      MRI->clearKillFlags(SrcReg);
 
  556        Reg = ConstrainForSubReg(
Reg, SubIdx,
 
  557                                 Node->getOperand(0).getSimpleValueType(),
 
  558                                 Node->isDivergent(), 
Node->getDebugLoc());
 
  561        VRBase = MRI->createVirtualRegister(TRC);
 
  564      MachineInstrBuilder CopyMI =
 
  566                  TII->get(TargetOpcode::COPY), VRBase);
 
  570        CopyMI.
addReg(TRI->getSubReg(
Reg, SubIdx));
 
  572  } 
else if (
Opc == TargetOpcode::INSERT_SUBREG ||
 
  573             Opc == TargetOpcode::SUBREG_TO_REG) {
 
  593    const TargetRegisterClass *SRC =
 
  594        TLI->getRegClassFor(
Node->getSimpleValueType(0), 
Node->isDivergent());
 
  595    SRC = TRI->getSubClassWithSubReg(SRC, SubIdx);
 
  596    assert(SRC && 
"No register class supports VT and SubIdx for INSERT_SUBREG");
 
  598    if (VRBase == 0 || !SRC->
hasSubClassEq(MRI->getRegClass(VRBase)))
 
  599      VRBase = MRI->createVirtualRegister(SRC);
 
  602    MachineInstrBuilder MIB =
 
  607    if (
Opc == TargetOpcode::SUBREG_TO_REG) {
 
  611      AddOperand(MIB, N0, 0, 
nullptr, VRBaseMap, 
false,
 
  614    AddOperand(MIB, N1, 0, 
nullptr, VRBaseMap, 
false,
 
  617    MBB->
insert(InsertPos, MIB);
 
  619    llvm_unreachable(
"Node is not insert_subreg, extract_subreg, or subreg_to_reg");
 
  622  bool isNew = VRBaseMap.insert(std::make_pair(
Op, VRBase)).second;
 
  624  assert(isNew && 
"Node emitted out of order - early");
 
  632InstrEmitter::EmitCopyToRegClassNode(
SDNode *Node,
 
  633                                     VRBaseMapType &VRBaseMap) {
 
  635  unsigned DstRCIdx = 
Node->getConstantOperandVal(1);
 
  636  const TargetRegisterClass *DstRC =
 
  637    TRI->getAllocatableClass(TRI->getRegClass(DstRCIdx));
 
  638  Register NewVReg = MRI->createVirtualRegister(DstRC);
 
  639  const MCInstrDesc &
II = TII->get(TargetOpcode::COPY);
 
  640  MachineInstrBuilder MIB = 
BuildMI(*MF, 
Node->getDebugLoc(), 
II, NewVReg);
 
  641  AddOperand(MIB, 
Node->getOperand(0), 1, &
II, VRBaseMap, 
false,
 
  644  MBB->insert(InsertPos, MIB);
 
  646  bool isNew = VRBaseMap.insert(std::make_pair(
Op, NewVReg)).second;
 
  648  assert(isNew && 
"Node emitted out of order - early");
 
  653void InstrEmitter::EmitRegSequence(
SDNode *Node, VRBaseMapType &VRBaseMap,
 
  654                                   bool IsClone, 
bool IsCloned) {
 
  655  unsigned DstRCIdx = 
Node->getConstantOperandVal(0);
 
  656  const TargetRegisterClass *RC = TRI->getRegClass(DstRCIdx);
 
  657  Register NewVReg = MRI->createVirtualRegister(TRI->getAllocatableClass(RC));
 
  658  const MCInstrDesc &
II = TII->get(TargetOpcode::REG_SEQUENCE);
 
  659  MachineInstrBuilder MIB = 
BuildMI(*MF, 
Node->getDebugLoc(), 
II, NewVReg);
 
  668         "REG_SEQUENCE must have an odd number of operands!");
 
  669  for (
unsigned i = 1; i != 
NumOps; ++i) {
 
  675      if (!R || !
R->getReg().isPhysical()) {
 
  676        unsigned SubIdx = 
Op->getAsZExtVal();
 
  678        const TargetRegisterClass *TRC = MRI->getRegClass(
SubReg);
 
  679        const TargetRegisterClass *SRC =
 
  680        TRI->getMatchingSuperRegClass(RC, TRC, SubIdx);
 
  681        if (SRC && SRC != RC) {
 
  682          MRI->setRegClass(NewVReg, SRC);
 
  687    AddOperand(MIB, 
Op, i+1, &
II, VRBaseMap, 
false,
 
  691  MBB->insert(InsertPos, MIB);
 
  693  bool isNew = VRBaseMap.insert(std::make_pair(
Op, NewVReg)).second;
 
  695  assert(isNew && 
"Node emitted out of order - early");
 
  705             ->isValidLocationForIntrinsic(
DL) &&
 
  706         "Expected inlined-at fields to agree");
 
  711         "dbg_value with no location operands?");
 
  717  if (EmitDebugInstrRefs)
 
 
  732  const Value *V = 
Op.getConst();
 
  734    if (CI->getBitWidth() > 64)
 
  736    if (CI->getBitWidth() == 1)
 
 
  758    switch (
Op.getKind()) {
 
  772      if (VRBaseMap.
count(V) == 0)
 
  775        AddOperand(MIB, V, (*MIB).getNumOperands(), &DbgValDesc, VRBaseMap,
 
 
  791  const MCInstrDesc &RefII = TII->get(TargetOpcode::DBG_INSTR_REF);
 
  833  auto AddVRegOp = [&](
Register VReg) {
 
  853      if (!MRI->hasOneDef(VReg)) {
 
  858      DefMI = &*MRI->def_instr_begin(VReg);
 
  865      if (
I == VRBaseMap.
end())
 
  869      VReg = getVR(
Op, VRBaseMap);
 
  873      if (!MRI->hasOneDef(VReg)) {
 
  878      DefMI = &*MRI->def_instr_begin(VReg);
 
  888    if (
DefMI->isCopyLike() || TII->isCopyInstr(*
DefMI)) {
 
  894    unsigned OperandIdx = 0;
 
  895    for (
const auto &MO : 
DefMI->operands()) {
 
  896      if (MO.isReg() && MO.isDef() && MO.getReg() == VReg)
 
  900    assert(OperandIdx < DefMI->getNumOperands());
 
  903    unsigned InstrNum = 
DefMI->getDebugInstrNum();
 
  909  if (MOs.
size() != OpCount)
 
  912  return BuildMI(*MF, 
DL, RefII, 
false, MOs, Var, Expr);
 
 
  934  const MCInstrDesc &DbgValDesc = TII->get(TargetOpcode::DBG_VALUE_LIST);
 
 
  952         "Non variadic dbg_value should have only one location op");
 
  958    const Value *V = LocationOps[0].getConst();
 
 
  983         "Expected inlined-at fields to agree");
 
 
  996EmitMachineNode(
SDNode *
Node, 
bool IsClone, 
bool IsCloned,
 
  997                VRBaseMapType &VRBaseMap) {
 
  998  unsigned Opc = 
Node->getMachineOpcode();
 
 1001  if (
Opc == TargetOpcode::EXTRACT_SUBREG ||
 
 1002      Opc == TargetOpcode::INSERT_SUBREG ||
 
 1003      Opc == TargetOpcode::SUBREG_TO_REG) {
 
 1004    EmitSubregNode(
Node, VRBaseMap, IsClone, IsCloned);
 
 1009  if (
Opc == TargetOpcode::COPY_TO_REGCLASS) {
 
 1010    EmitCopyToRegClassNode(
Node, VRBaseMap);
 
 1015  if (
Opc == TargetOpcode::REG_SEQUENCE) {
 
 1016    EmitRegSequence(Node, VRBaseMap, IsClone, IsCloned);
 
 1020  if (
Opc == TargetOpcode::IMPLICIT_DEF)
 
 1024  const MCInstrDesc &
II = TII->get(
Opc);
 
 1026  unsigned NumDefs = 
II.getNumDefs();
 
 1030  if (
Opc == TargetOpcode::STACKMAP || 
Opc == TargetOpcode::PATCHPOINT) {
 
 1035    if (
Opc == TargetOpcode::PATCHPOINT) {
 
 1037      NumDefs = NumResults;
 
 1040  } 
else if (
Opc == TargetOpcode::STATEPOINT) {
 
 1041    NumDefs = NumResults;
 
 1044  unsigned NumImpUses = 0;
 
 1045  unsigned NodeOperands =
 
 1047  bool HasVRegVariadicDefs = !MF->getTarget().usesPhysRegsForValues() &&
 
 1048                             II.isVariadic() && 
II.variadicOpsAreDefs();
 
 1049  bool HasPhysRegOuts = NumResults > NumDefs && !
II.implicit_defs().empty() &&
 
 1050                        !HasVRegVariadicDefs;
 
 1052  unsigned NumMIOperands = NodeOperands + NumResults;
 
 1053  if (
II.isVariadic())
 
 1054    assert(NumMIOperands >= 
II.getNumOperands() &&
 
 1055           "Too few operands for a variadic node!");
 
 1057    assert(NumMIOperands >= 
II.getNumOperands() &&
 
 1059               II.getNumOperands() + 
II.implicit_defs().size() + NumImpUses &&
 
 1060           "#operands for dag node doesn't match .td file!");
 
 1064  MachineInstrBuilder MIB = 
BuildMI(*MF, 
Node->getDebugLoc(), 
II);
 
 1068  const SDNodeFlags 
Flags = 
Node->getFlags();
 
 1069  if (
Flags.hasUnpredictable())
 
 1075    CreateVirtualRegisters(Node, MIB, 
II, IsClone, IsCloned, VRBaseMap);
 
 1077    if (
Flags.hasNoSignedZeros())
 
 1080    if (
Flags.hasAllowReciprocal())
 
 1083    if (
Flags.hasNoNaNs())
 
 1086    if (
Flags.hasNoInfs())
 
 1089    if (
Flags.hasAllowContract())
 
 1092    if (
Flags.hasApproximateFuncs())
 
 1095    if (
Flags.hasAllowReassociation())
 
 1098    if (
Flags.hasNoUnsignedWrap())
 
 1101    if (
Flags.hasNoSignedWrap())
 
 1104    if (
Flags.hasExact())
 
 1107    if (
Flags.hasNoFPExcept())
 
 1110    if (
Flags.hasDisjoint())
 
 1113    if (
Flags.hasSameSign())
 
 1119  bool HasOptPRefs = NumDefs > NumResults;
 
 1120  assert((!HasOptPRefs || !HasPhysRegOuts) &&
 
 1121         "Unable to cope with optional defs and phys regs defs!");
 
 1122  unsigned NumSkip = HasOptPRefs ? NumDefs - NumResults : 0;
 
 1123  for (
unsigned i = NumSkip; i != NodeOperands; ++i)
 
 1124    AddOperand(MIB, 
Node->getOperand(i), i-NumSkip+NumDefs, &
II,
 
 1125               VRBaseMap, 
false, IsClone, IsCloned);
 
 1129    for (
unsigned i = 0; ScratchRegs[i]; ++i)
 
 1143  MBB->insert(InsertPos, MIB);
 
 1163  if (HasPhysRegOuts) {
 
 1164    for (
unsigned i = NumDefs; i < NumResults; ++i) {
 
 1166      if (!
Node->hasAnyUseOfValue(i))
 
 1170      EmitCopyFromReg(
SDValue(Node, i), IsClone, 
Reg, VRBaseMap);
 
 1175  if (
Node->getValueType(
Node->getNumValues()-1) == MVT::Glue) {
 
 1176    for (SDNode *
F = 
Node->getGluedUser(); 
F; 
F = 
F->getGluedUser()) {
 
 1187      const MCInstrDesc &MCID = TII->get(
F->getMachineOpcode());
 
 1201  if (
II.isCall() && MF->getFunction().hasFnAttribute(Attribute::StrictFP)) {
 
 1207  if (!UsedRegs.
empty() || !
II.implicit_defs().empty() || 
II.hasOptionalDef())
 
 1212  if (
Opc == TargetOpcode::STATEPOINT && NumDefs > 0) {
 
 1213    assert(!HasPhysRegOuts && 
"STATEPOINT mishandled");
 
 1214    MachineInstr *
MI = MIB;
 
 1216    int First = StatepointOpers(
MI).getFirstGCPtrIdx();
 
 1217    assert(
First > 0 && 
"Statepoint has Defs but no GC ptr list");
 
 1219    while (Def < NumDefs) {
 
 1220      if (
MI->getOperand(Use).isReg())
 
 1221        MI->tieOperands(Def++, Use);
 
 1226  if (SDNode *GluedNode = 
Node->getGluedNode()) {
 
 1228    if (GluedNode->getOpcode() ==
 
 1229        ~(
unsigned)TargetOpcode::CONVERGENCECTRL_GLUE) {
 
 1230      Register VReg = getVR(GluedNode->getOperand(0), VRBaseMap);
 
 1238  if (
II.hasPostISelHook())
 
 1239    TLI->AdjustInstrPostInstrSelection(*MIB, Node);
 
 1245EmitSpecialNode(
SDNode *Node, 
bool IsClone, 
bool IsCloned,
 
 1246                VRBaseMapType &VRBaseMap) {
 
 1247  switch (
Node->getOpcode()) {
 
 1252    llvm_unreachable(
"This target-independent node should have been selected!");
 
 1265              TII->get(TargetOpcode::IMPLICIT_DEF), DestReg);
 
 1270      SrcReg = 
R->getReg();
 
 1272      SrcReg = getVR(SrcVal, VRBaseMap);
 
 1274    if (SrcReg == DestReg) 
 
 1277    BuildMI(*MBB, InsertPos, 
Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
 
 1283    EmitCopyFromReg(
SDValue(Node, 0), IsClone, SrcReg, VRBaseMap);
 
 1287  case ISD::ANNOTATION_LABEL: {
 
 1288    unsigned Opc = (
Node->getOpcode() == ISD::EH_LABEL)
 
 1289                       ? TargetOpcode::EH_LABEL
 
 1290                       : TargetOpcode::ANNOTATION_LABEL;
 
 1297  case ISD::LIFETIME_START:
 
 1298  case ISD::LIFETIME_END: {
 
 1299    unsigned TarOp = (
Node->getOpcode() == ISD::LIFETIME_START)
 
 1300                         ? TargetOpcode::LIFETIME_START
 
 1301                         : TargetOpcode::LIFETIME_END;
 
 1303    BuildMI(*MBB, InsertPos, 
Node->getDebugLoc(), TII->get(TarOp))
 
 1308  case ISD::PSEUDO_PROBE: {
 
 1309    unsigned TarOp = TargetOpcode::PSEUDO_PROBE;
 
 1314    BuildMI(*MBB, InsertPos, 
Node->getDebugLoc(), TII->get(TarOp))
 
 1322  case ISD::INLINEASM:
 
 1323  case ISD::INLINEASM_BR: {
 
 1325    if (
Node->getOperand(
NumOps-1).getValueType() == MVT::Glue)
 
 1329    unsigned TgtOpc = 
Node->getOpcode() == ISD::INLINEASM_BR
 
 1330                          ? TargetOpcode::INLINEASM_BR
 
 1331                          : TargetOpcode::INLINEASM;
 
 1332    MachineInstrBuilder MIB =
 
 1333        BuildMI(*MF, 
Node->getDebugLoc(), TII->get(TgtOpc));
 
 1348    SmallVector<unsigned, 8> GroupIdx;
 
 1355      unsigned Flags = 
Node->getConstantOperandVal(i);
 
 1356      const InlineAsm::Flag 
F(Flags);
 
 1357      const unsigned NumVals = 
F.getNumOperandRegisters();
 
 1363      switch (
F.getKind()) {
 
 1365        for (
unsigned j = 0; 
j != NumVals; ++
j, ++i) {
 
 1375        for (
unsigned j = 0; 
j != NumVals; ++
j, ++i) {
 
 1387        for (
unsigned j = 0; 
j != NumVals; ++
j, ++i)
 
 1388          AddOperand(MIB, 
Node->getOperand(i), 0, 
nullptr, VRBaseMap,
 
 1389                     false, IsClone, IsCloned);
 
 1392        if (
F.isRegUseKind()) {
 
 1394          if (
F.isUseOperandTiedToDef(DefGroup)) {
 
 1395            unsigned DefIdx = GroupIdx[DefGroup] + 1;
 
 1396            unsigned UseIdx = GroupIdx.
back() + 1;
 
 1397            for (
unsigned j = 0; 
j != NumVals; ++
j)
 
 1403        for (
unsigned j = 0; 
j != NumVals; ++
j, ++i) {
 
 1405          AddOperand(MIB, 
Op, 0, 
nullptr, VRBaseMap,
 
 1406                     false, IsClone, IsCloned);
 
 1411                MF->getSubtarget().classifyGlobalFunctionReference(
 
 1421    if (MF->getFunction().hasFnAttribute(Attribute::StrictFP)) {
 
 1434        MachineOperand *MO =
 
 1436        assert(MO && 
"No def operand for clobbered register?");
 
 1447    MBB->
insert(InsertPos, MIB);
 
 1457    : MF(mbb->
getParent()), MRI(&MF->getRegInfo()),
 
 1458      TII(MF->getSubtarget().getInstrInfo()),
 
 1459      TRI(MF->getSubtarget().getRegisterInfo()),
 
 1460      TLI(MF->getSubtarget().getTargetLowering()), MBB(mbb),
 
 1461      InsertPos(insertpos) {
 
 1462  EmitDebugInstrRefs = mbb->
getParent()->useDebugInstrRef();
 
 
MachineInstrBuilder MachineInstrBuilder & DefMI
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
static const Function * getParent(const Value *V)
 
This file contains constants used for implementing Dwarf debug support.
 
static bool isConvergenceCtrlMachineOp(SDValue Op)
 
MachineOperand GetMOForConstDbgOp(const SDDbgOperand &Op)
 
const unsigned MinRCSize
MinRCSize - Smallest register class we allow when constraining virtual registers.
 
static unsigned countOperands(SDNode *Node, unsigned NumExpUses, unsigned &NumImpUses)
countOperands - The inputs to target nodes have any actual inputs first, followed by an optional chai...
 
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
 
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
 
Promote Memory to Register
 
MachineInstr unsigned OpIdx
 
uint64_t IntrinsicInst * II
 
This file describes how to lower LLVM code to machine code.
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
ConstantFP - Floating Point Values [float, double].
 
This is the shared class of boolean and integer constants.
 
uint64_t getZExtValue() const
 
static LLVM_ABI DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
 
LLVM_ABI std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
 
static LLVM_ABI const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
 
static LLVM_ABI const DIExpression * convertToUndefExpression(const DIExpression *Expr)
Removes all elements from Expr that do not apply to an undef debug value, which includes every operat...
 
Base class for variables.
 
iterator find(const_arg_type_t< KeyT > Val)
 
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
 
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
 
MachineInstr * EmitDbgValue(SDDbgValue *SD, VRBaseMapType &VRBaseMap)
EmitDbgValue - Generate machine instruction for a dbg_value node.
 
MachineInstr * EmitDbgInstrRef(SDDbgValue *SD, VRBaseMapType &VRBaseMap)
Emit a dbg_value as a DBG_INSTR_REF.
 
SmallDenseMap< SDValue, Register, 16 > VRBaseMapType
 
MachineInstr * EmitDbgLabel(SDDbgLabel *SD)
Generate machine instruction for a dbg_label node.
 
MachineInstr * EmitDbgNoLocation(SDDbgValue *SD)
Emit a DBG_VALUE $noreg, indicating a variable has no location.
 
static unsigned CountResults(SDNode *Node)
CountResults - The results of target nodes have register or immediate operands first,...
 
MachineInstr * EmitDbgValueList(SDDbgValue *SD, VRBaseMapType &VRBaseMap)
Emit a DBG_VALUE_LIST from the operands to SDDbgValue.
 
InstrEmitter(const TargetMachine &TM, MachineBasicBlock *mbb, MachineBasicBlock::iterator insertpos)
InstrEmitter - Construct an InstrEmitter and set it to start inserting at the given position in the g...
 
void AddDbgValueLocationOps(MachineInstrBuilder &MIB, const MCInstrDesc &DbgValDesc, ArrayRef< SDDbgOperand > Locations, VRBaseMapType &VRBaseMap)
 
MachineInstr * EmitDbgValueFromSingleOp(SDDbgValue *SD, VRBaseMapType &VRBaseMap)
Emit a DBG_VALUE from the operands to SDDbgValue.
 
Describe properties that are true of each instruction in the target description file.
 
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
 
ArrayRef< MCOperandInfo > operands() const
 
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
 
ArrayRef< MCPhysReg > implicit_uses() const
Return a list of registers that are potentially read by any instance of this machine instruction.
 
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
 
MachineInstrBundleIterator< MachineInstr > iterator
 
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
 
const MachineInstrBuilder & addTargetIndex(unsigned Idx, int64_t Offset=0, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
 
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & addCImm(const ConstantInt *Val) const
 
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
 
const MachineInstrBuilder & addBlockAddress(const BlockAddress *BA, int64_t Offset=0, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & add(const MachineOperand &MO) const
 
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
 
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
 
const MachineInstrBuilder & addFrameIndex(int Idx) const
 
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
 
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
 
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
 
const MachineInstrBuilder & addJumpTableIndex(unsigned Idx, unsigned TargetFlags=0) const
 
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
 
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
 
Representation of each machine instruction.
 
LLVM_ABI void setCFIType(MachineFunction &MF, uint32_t Type)
Set the CFI type for the instruction.
 
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr reads the specified register.
 
unsigned getNumOperands() const
Retuns the total number of operands.
 
LLVM_ABI void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
 
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
 
LLVM_ABI void insert(mop_iterator InsertBefore, ArrayRef< MachineOperand > Ops)
Inserts Ops BEFORE It. Can untie/retie tied operands.
 
LLVM_ABI void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
 
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
 
LLVM_ABI void setPhysRegsDeadExcept(ArrayRef< Register > UsedRegs, const TargetRegisterInfo &TRI)
Mark every physreg used by this instruction as dead except those in the UsedRegs list.
 
const MachineOperand & getOperand(unsigned i) const
 
MachineOperand * findRegisterDefOperand(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
 
MachineOperand class - Representation of each machine instruction operand.
 
static MachineOperand CreateFPImm(const ConstantFP *CFP)
 
bool isReg() const
isReg - Tests if this is a MO_Register operand.
 
static MachineOperand CreateCImm(const ConstantInt *CI)
 
void setIsEarlyClobber(bool Val=true)
 
static MachineOperand CreateImm(int64_t Val)
 
static MachineOperand CreateDbgInstrRef(unsigned InstrIdx, unsigned OpIdx)
 
void setTargetFlags(unsigned F)
 
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)
 
Wrapper class representing virtual and physical registers.
 
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
 
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
 
Holds the information from a dbg_label node through SDISel.
 
MDNode * getLabel() const
Returns the MDNode pointer for the label.
 
const DebugLoc & getDebugLoc() const
Returns the DebugLoc.
 
Holds the information for a single machine location through SDISel; either an SDNode,...
 
Register getVReg() const
Returns the Virtual Register for a VReg.
 
unsigned getResNo() const
Returns the ResNo for a register ref.
 
static SDDbgOperand fromConst(const Value *Const)
 
SDNode * getSDNode() const
Returns the SDNode* for a register ref.
 
@ VREG
Value is a virtual register.
 
@ FRAMEIX
Value is contents of a stack location.
 
@ SDNODE
Value is the result of an expression.
 
@ CONST
Value is a constant.
 
Holds the information from a dbg_value node through SDISel.
 
const DebugLoc & getDebugLoc() const
Returns the DebugLoc.
 
DIVariable * getVariable() const
Returns the DIVariable pointer for the variable.
 
bool isInvalidated() const
 
ArrayRef< SDDbgOperand > getLocationOps() const
 
DIExpression * getExpression() const
Returns the DIExpression pointer for the expression.
 
bool isIndirect() const
Returns whether this is an indirect value.
 
void setIsEmitted()
setIsEmitted / isEmitted - Getter/Setter for flag indicating that this SDDbgValue has been emitted to...
 
Represents one node in the SelectionDAG.
 
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
 
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
 
bool isMachineOpcode() const
 
unsigned getMachineOpcode() const
 
void push_back(const T &Elt)
 
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
 
static LLVM_ABI unsigned getNextMetaArgIdx(const MachineInstr *MI, unsigned CurIdx)
Get index of next meta operand.
 
Primary interface to the complete machine description for the target machine.
 
bool isAllocatable() const
Return true if this register class may be used to create virtual registers.
 
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
 
bool expensiveOrImpossibleToCopy() const
 
LLVM Value Representation.
 
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
 
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
 
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
 
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
 
@ C
The default llvm calling convention, compatible with C.
 
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
 
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
 
@ EntryToken
EntryToken - This is the marker used to indicate the start of a region.
 
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
 
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
 
@ Define
Register definition.
 
@ EarlyClobber
Register definition happens before uses.
 
@ User
could "use" a pointer
 
NodeAddr< DefNode * > Def
 
NodeAddr< UseNode * > Use
 
NodeAddr< NodeBase * > Node
 
This is an optimization pass for GlobalISel generic memory operations.
 
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
 
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
 
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
 
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
 
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
 
unsigned getImplRegState(bool B)
 
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
unsigned getDebugRegState(bool B)
 
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
 
unsigned getDefRegState(bool B)
 
unsigned getKillRegState(bool B)
 
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
 
DWARFExpression::Operation Op
 
ArrayRef(const T &OneElt) -> ArrayRef< T >
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
TODO: Might pack better if we changed this to a Struct of Arrays, since MachineOperand is width 32,...