diff options
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
| -rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 6d3a933c96a3..4b5ae3cc202d 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -22,6 +22,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCPseudoProbe.h" #include "llvm/MC/MCRegister.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSection.h" @@ -90,7 +91,7 @@ void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {} MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), CurrentWinFrameInfo(nullptr), - UseAssemblerInfoForParsing(false) { + CurrentProcWinFrameInfoStartIndex(0), UseAssemblerInfoForParsing(false) { SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>()); } @@ -138,6 +139,21 @@ void MCStreamer::emitIntValue(uint64_t Value, unsigned Size) { unsigned Index = IsLittleEndian ? 0 : 8 - Size; emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size)); } +void MCStreamer::emitIntValue(APInt Value) { + if (Value.getNumWords() == 1) { + emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8); + return; + } + + const bool IsLittleEndianTarget = Context.getAsmInfo()->isLittleEndian(); + const bool ShouldSwap = sys::IsLittleEndianHost != IsLittleEndianTarget; + const APInt Swapped = ShouldSwap ? Value.byteSwap() : Value; + const unsigned Size = Value.getBitWidth() / 8; + SmallString<10> Tmp; + Tmp.resize(Size); + StoreIntToMemory(Swapped, reinterpret_cast<uint8_t *>(Tmp.data()), Size); + emitBytes(Tmp.str()); +} /// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the /// client having to pass in a MCExpr for constant integers. @@ -202,6 +218,9 @@ void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) { emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue); } +void llvm::MCStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLen, + llvm::SMLoc) {} + /// The implementation in this class just redirects to emitFill. void MCStreamer::emitZeros(uint64_t NumBytes) { emitFill(NumBytes, 0); } @@ -255,9 +274,9 @@ bool MCStreamer::hasUnfinishedDwarfFrameInfo() { MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() { if (!hasUnfinishedDwarfFrameInfo()) { - getContext().reportError(SMLoc(), "this directive must appear between " - ".cfi_startproc and .cfi_endproc " - "directives"); + getContext().reportError(getStartTokLoc(), + "this directive must appear between " + ".cfi_startproc and .cfi_endproc directives"); return nullptr; } return &DwarfFrameInfos.back(); @@ -674,6 +693,7 @@ void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) { MCSymbol *StartProc = emitCFILabel(); + CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size(); WinFrameInfos.emplace_back( std::make_unique<WinEH::FrameInfo>(Symbol, StartProc)); CurrentWinFrameInfo = WinFrameInfos.back().get(); @@ -689,6 +709,13 @@ void MCStreamer::EmitWinCFIEndProc(SMLoc Loc) { MCSymbol *Label = emitCFILabel(); CurFrame->End = Label; + if (!CurFrame->FuncletOrFuncEnd) + CurFrame->FuncletOrFuncEnd = CurFrame->End; + + for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size(); + I != E; ++I) + EmitWindowsUnwindTables(WinFrameInfos[I].get()); + SwitchSection(CurFrame->TextSection); } void MCStreamer::EmitWinCFIFuncletOrFuncEnd(SMLoc Loc) { @@ -947,10 +974,13 @@ void MCStreamer::emitRawText(const Twine &T) { void MCStreamer::EmitWindowsUnwindTables() { } -void MCStreamer::Finish() { +void MCStreamer::EmitWindowsUnwindTables(WinEH::FrameInfo *Frame) { +} + +void MCStreamer::Finish(SMLoc EndLoc) { if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) || (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) { - getContext().reportError(SMLoc(), "Unfinished frame!"); + getContext().reportError(EndLoc, "Unfinished frame!"); return; } @@ -1013,6 +1043,25 @@ void MCStreamer::emitInstruction(const MCInst &Inst, const MCSubtargetInfo &) { visitUsedExpr(*Inst.getOperand(i).getExpr()); } +void MCStreamer::emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, + uint64_t Attr, + const MCPseudoProbeInlineStack &InlineStack) { + auto &Context = getContext(); + + // Create a symbol at in the current section for use in the probe. + MCSymbol *ProbeSym = Context.createTempSymbol(); + + // Set the value of the symbol to use for the MCPseudoProbe. + emitLabel(ProbeSym); + + // Create a (local) probe entry with the symbol. + MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr); + + // Add the probe entry to this section's entries. + Context.getMCPseudoProbeTable().getProbeSections().addPseudoProbe( + getCurrentSectionOnly(), Probe, InlineStack); +} + void MCStreamer::emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) { // Get the Hi-Lo expression. @@ -1027,7 +1076,7 @@ void MCStreamer::emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, } // Otherwise, emit with .set (aka assignment). - MCSymbol *SetLabel = Context.createTempSymbol("set", true); + MCSymbol *SetLabel = Context.createTempSymbol("set"); emitAssignment(SetLabel, Diff); emitSymbolValue(SetLabel, Size); } |
