/// ScanForSpillSlotRefs - Scan all the machine instructions for spill slot /// references and update spill slot weights. void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) { SSRefs.resize(MFI->getObjectIndexEnd()); // FIXME: Need the equivalent of MachineRegisterInfo for frameindex operands. for (MachineFunction::iterator MBBI = MF.begin(), E = MF.end(); MBBI != E; ++MBBI) { MachineBasicBlock *MBB = &*MBBI; for (MachineBasicBlock::iterator MII = MBB->begin(), EE = MBB->end(); MII != EE; ++MII) { MachineInstr &MI = *MII; for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { MachineOperand &MO = MI.getOperand(i); if (!MO.isFI()) continue; int FI = MO.getIndex(); if (FI < 0) continue; if (!LS->hasInterval(FI)) continue; LiveInterval &li = LS->getInterval(FI); if (!MI.isDebugValue()) li.weight += LiveIntervals::getSpillWeight(false, true, MBFI, MI); } for (MachineInstr::mmo_iterator MMOI = MI.memoperands_begin(), EE = MI.memoperands_end(); MMOI != EE; ++MMOI) { MachineMemOperand *MMO = *MMOI; if (const FixedStackPseudoSourceValue *FSV = dyn_cast_or_null<FixedStackPseudoSourceValue>( MMO->getPseudoValue())) { int FI = FSV->getFrameIndex(); if (FI >= 0) SSRefs[FI].push_back(MMO); } } } } }
void MIPrinter::print(const MachineMemOperand &Op) { OS << '('; // TODO: Print operand's target specific flags. if (Op.isVolatile()) OS << "volatile "; if (Op.isNonTemporal()) OS << "non-temporal "; if (Op.isInvariant()) OS << "invariant "; if (Op.isLoad()) OS << "load "; else { assert(Op.isStore() && "Non load machine operand must be a store"); OS << "store "; } OS << Op.getSize() << (Op.isLoad() ? " from " : " into "); if (const Value *Val = Op.getValue()) { printIRValueReference(*Val); } else { const PseudoSourceValue *PVal = Op.getPseudoValue(); assert(PVal && "Expected a pseudo source value"); switch (PVal->kind()) { case PseudoSourceValue::Stack: OS << "stack"; break; case PseudoSourceValue::GOT: OS << "got"; break; case PseudoSourceValue::JumpTable: OS << "jump-table"; break; case PseudoSourceValue::ConstantPool: OS << "constant-pool"; break; case PseudoSourceValue::FixedStack: printStackObjectReference( cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex()); break; case PseudoSourceValue::GlobalValueCallEntry: OS << "call-entry "; cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand( OS, /*PrintType=*/false, MST); break; case PseudoSourceValue::ExternalSymbolCallEntry: OS << "call-entry $"; printLLVMNameWithoutPrefix( OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol()); break; } } printOffset(Op.getOffset()); if (Op.getBaseAlignment() != Op.getSize()) OS << ", align " << Op.getBaseAlignment(); auto AAInfo = Op.getAAInfo(); if (AAInfo.TBAA) { OS << ", !tbaa "; AAInfo.TBAA->printAsOperand(OS, MST); } if (AAInfo.Scope) { OS << ", !alias.scope "; AAInfo.Scope->printAsOperand(OS, MST); } if (AAInfo.NoAlias) { OS << ", !noalias "; AAInfo.NoAlias->printAsOperand(OS, MST); } if (Op.getRanges()) { OS << ", !range "; Op.getRanges()->printAsOperand(OS, MST); } OS << ')'; }
void MIPrinter::print(const LLVMContext &Context, const TargetInstrInfo &TII, const MachineMemOperand &Op) { OS << '('; if (Op.isVolatile()) OS << "volatile "; if (Op.isNonTemporal()) OS << "non-temporal "; if (Op.isDereferenceable()) OS << "dereferenceable "; if (Op.isInvariant()) OS << "invariant "; if (Op.getFlags() & MachineMemOperand::MOTargetFlag1) OS << '"' << getTargetMMOFlagName(TII, MachineMemOperand::MOTargetFlag1) << "\" "; if (Op.getFlags() & MachineMemOperand::MOTargetFlag2) OS << '"' << getTargetMMOFlagName(TII, MachineMemOperand::MOTargetFlag2) << "\" "; if (Op.getFlags() & MachineMemOperand::MOTargetFlag3) OS << '"' << getTargetMMOFlagName(TII, MachineMemOperand::MOTargetFlag3) << "\" "; assert((Op.isLoad() || Op.isStore()) && "machine memory operand must be a load or store (or both)"); if (Op.isLoad()) OS << "load "; if (Op.isStore()) OS << "store "; printSyncScope(Context, Op.getSyncScopeID()); if (Op.getOrdering() != AtomicOrdering::NotAtomic) OS << toIRString(Op.getOrdering()) << ' '; if (Op.getFailureOrdering() != AtomicOrdering::NotAtomic) OS << toIRString(Op.getFailureOrdering()) << ' '; OS << Op.getSize(); if (const Value *Val = Op.getValue()) { OS << ((Op.isLoad() && Op.isStore()) ? " on " : Op.isLoad() ? " from " : " into "); printIRValueReference(*Val); } else if (const PseudoSourceValue *PVal = Op.getPseudoValue()) { OS << ((Op.isLoad() && Op.isStore()) ? " on " : Op.isLoad() ? " from " : " into "); assert(PVal && "Expected a pseudo source value"); switch (PVal->kind()) { case PseudoSourceValue::Stack: OS << "stack"; break; case PseudoSourceValue::GOT: OS << "got"; break; case PseudoSourceValue::JumpTable: OS << "jump-table"; break; case PseudoSourceValue::ConstantPool: OS << "constant-pool"; break; case PseudoSourceValue::FixedStack: printStackObjectReference( cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex()); break; case PseudoSourceValue::GlobalValueCallEntry: OS << "call-entry "; cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand( OS, /*PrintType=*/false, MST); break; case PseudoSourceValue::ExternalSymbolCallEntry: OS << "call-entry $"; printLLVMNameWithoutPrefix( OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol()); break; case PseudoSourceValue::TargetCustom: llvm_unreachable("TargetCustom pseudo source values are not supported"); break; } } MachineOperand::printOperandOffset(OS, Op.getOffset()); if (Op.getBaseAlignment() != Op.getSize()) OS << ", align " << Op.getBaseAlignment(); auto AAInfo = Op.getAAInfo(); if (AAInfo.TBAA) { OS << ", !tbaa "; AAInfo.TBAA->printAsOperand(OS, MST); } if (AAInfo.Scope) { OS << ", !alias.scope "; AAInfo.Scope->printAsOperand(OS, MST); } if (AAInfo.NoAlias) { OS << ", !noalias "; AAInfo.NoAlias->printAsOperand(OS, MST); } if (Op.getRanges()) { OS << ", !range "; Op.getRanges()->printAsOperand(OS, MST); } OS << ')'; }