diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 92 |
1 files changed, 67 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index fb1d392e..9503537 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -447,45 +447,68 @@ void MachineInstr::cloneMergedMemRefs(MachineFunction &MF, setMemRefs(MF, MergedMMOs); } -MCSymbol *MachineInstr::getOrCreatePreInstrTempSymbol(MCContext &MCCtx) { - MCSymbol *S = getPreInstrSymbol(); - if (S) - return S; +void MachineInstr::setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol) { + MCSymbol *OldSymbol = getPreInstrSymbol(); + if (OldSymbol == Symbol) + return; + if (OldSymbol && !Symbol) { + // We're removing a symbol rather than adding one. Try to clean up any + // extra info carried around. + if (Info.is<EIIK_PreInstrSymbol>()) { + Info.clear(); + return; + } - // Create a new temp symbol. - S = MCCtx.createTempSymbol(); + if (memoperands_empty()) { + assert(getPostInstrSymbol() && + "Should never have only a single symbol allocated out-of-line!"); + Info.set<EIIK_PostInstrSymbol>(getPostInstrSymbol()); + return; + } - if (!Info) { + // Otherwise fallback on the generic update. + } else if (!Info || Info.is<EIIK_PreInstrSymbol>()) { // If we don't have any other extra info, we can store this inline. - Info.set<EIIK_PreInstrSymbol>(S); - return S; + Info.set<EIIK_PreInstrSymbol>(Symbol); + return; } - // Otherwise, allocate a fully set of extra info. + // Otherwise, allocate a full new set of extra info. + // FIXME: Maybe we should make the symbols in the extra info mutable? Info.set<EIIK_OutOfLine>( - getMF()->createMIExtraInfo(memoperands(), S, getPostInstrSymbol())); - - return S; + MF.createMIExtraInfo(memoperands(), Symbol, getPostInstrSymbol())); } -MCSymbol *MachineInstr::getOrCreatePostInstrTempSymbol(MCContext &MCCtx) { - MCSymbol *S = getPostInstrSymbol(); - if (S) - return S; +void MachineInstr::setPostInstrSymbol(MachineFunction &MF, MCSymbol *Symbol) { + MCSymbol *OldSymbol = getPostInstrSymbol(); + if (OldSymbol == Symbol) + return; + if (OldSymbol && !Symbol) { + // We're removing a symbol rather than adding one. Try to clean up any + // extra info carried around. + if (Info.is<EIIK_PostInstrSymbol>()) { + Info.clear(); + return; + } - // Create a new temp symbol. - S = MCCtx.createTempSymbol(); + if (memoperands_empty()) { + assert(getPreInstrSymbol() && + "Should never have only a single symbol allocated out-of-line!"); + Info.set<EIIK_PreInstrSymbol>(getPreInstrSymbol()); + return; + } - if (!Info) { + // Otherwise fallback on the generic update. + } else if (!Info || Info.is<EIIK_PostInstrSymbol>()) { // If we don't have any other extra info, we can store this inline. - Info.set<EIIK_PostInstrSymbol>(S); - return S; + Info.set<EIIK_PostInstrSymbol>(Symbol); + return; } - // Otherwise, allocate a fully set of extra info. + // Otherwise, allocate a full new set of extra info. + // FIXME: Maybe we should make the symbols in the extra info mutable? Info.set<EIIK_OutOfLine>( - getMF()->createMIExtraInfo(memoperands(), getPreInstrSymbol(), S)); - return S; + MF.createMIExtraInfo(memoperands(), getPreInstrSymbol(), Symbol)); } uint16_t MachineInstr::mergeFlagsWith(const MachineInstr &Other) const { @@ -1592,6 +1615,25 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST, } } + // Print any optional symbols attached to this instruction as-if they were + // operands. + if (MCSymbol *PreInstrSymbol = getPreInstrSymbol()) { + if (!FirstOp) { + FirstOp = false; + OS << ','; + } + OS << " pre-instr-symbol "; + MachineOperand::printSymbol(OS, *PreInstrSymbol); + } + if (MCSymbol *PostInstrSymbol = getPostInstrSymbol()) { + if (!FirstOp) { + FirstOp = false; + OS << ','; + } + OS << " post-instr-symbol "; + MachineOperand::printSymbol(OS, *PostInstrSymbol); + } + if (!SkipDebugLoc) { if (const DebugLoc &DL = getDebugLoc()) { if (!FirstOp) |