diff options
Diffstat (limited to 'lib/MC/MCObjectStreamer.cpp')
| -rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 115 | 
1 files changed, 104 insertions, 11 deletions
| diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 972610ac8d6eb..d2ac0f50261d2 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -20,6 +20,7 @@  #include "llvm/MC/MCSection.h"  #include "llvm/MC/MCSymbol.h"  #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/SourceMgr.h"  #include "llvm/Support/TargetRegistry.h"  using namespace llvm; @@ -125,7 +126,8 @@ void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,    MCDataFragment *DF = getOrCreateDataFragment();    flushPendingLabels(DF, DF->getContents().size()); -  MCLineEntry::Make(this, getCurrentSection().first); +  MCCVLineEntry::Make(this); +  MCDwarfLineEntry::Make(this, getCurrentSection().first);    // Avoid fixups when possible.    int64_t AbsValue; @@ -232,7 +234,8 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst,    // Now that a machine instruction has been assembled into this section, make    // a line entry for any .loc directive that has been seen. -  MCLineEntry::Make(this, getCurrentSection().first); +  MCCVLineEntry::Make(this); +  MCDwarfLineEntry::Make(this, getCurrentSection().first);    // If this instruction doesn't need relaxation, just emit it as data.    MCAssembler &Assembler = getAssembler(); @@ -249,9 +252,9 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst,    if (Assembler.getRelaxAll() ||        (Assembler.isBundlingEnabled() && Sec->isBundleLocked())) {      MCInst Relaxed; -    getAssembler().getBackend().relaxInstruction(Inst, Relaxed); +    getAssembler().getBackend().relaxInstruction(Inst, STI, Relaxed);      while (getAssembler().getBackend().mayNeedRelaxation(Relaxed)) -      getAssembler().getBackend().relaxInstruction(Relaxed, Relaxed); +      getAssembler().getBackend().relaxInstruction(Relaxed, STI, Relaxed);      EmitInstToData(Relaxed, STI);      return;    } @@ -301,7 +304,7 @@ void MCObjectStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,                                               StringRef FileName) {    // In case we see two .loc directives in a row, make sure the    // first one gets a line entry. -  MCLineEntry::Make(this, getCurrentSection().first); +  MCDwarfLineEntry::Make(this, getCurrentSection().first);    this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,                                            Isa, Discriminator, FileName); @@ -362,8 +365,56 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,    insert(new MCDwarfCallFrameFragment(*AddrDelta));  } +void MCObjectStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, +                                          unsigned Line, unsigned Column, +                                          bool PrologueEnd, bool IsStmt, +                                          StringRef FileName) { +  // In case we see two .cv_loc directives in a row, make sure the +  // first one gets a line entry. +  MCCVLineEntry::Make(this); + +  this->MCStreamer::EmitCVLocDirective(FunctionId, FileNo, Line, Column, +                                       PrologueEnd, IsStmt, FileName); +} + +void MCObjectStreamer::EmitCVLinetableDirective(unsigned FunctionId, +                                                const MCSymbol *Begin, +                                                const MCSymbol *End) { +  getContext().getCVContext().emitLineTableForFunction(*this, FunctionId, Begin, +                                                       End); +  this->MCStreamer::EmitCVLinetableDirective(FunctionId, Begin, End); +} + +void MCObjectStreamer::EmitCVInlineLinetableDirective( +    unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, +    const MCSymbol *FnStartSym, const MCSymbol *FnEndSym, +    ArrayRef<unsigned> SecondaryFunctionIds) { +  getContext().getCVContext().emitInlineLineTableForFunction( +      *this, PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, +      FnEndSym, SecondaryFunctionIds); +  this->MCStreamer::EmitCVInlineLinetableDirective( +      PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym, +      SecondaryFunctionIds); +} + +void MCObjectStreamer::EmitCVDefRangeDirective( +    ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges, +    StringRef FixedSizePortion) { +  getContext().getCVContext().emitDefRange(*this, Ranges, FixedSizePortion); +  this->MCStreamer::EmitCVDefRangeDirective(Ranges, FixedSizePortion); +} + +void MCObjectStreamer::EmitCVStringTableDirective() { +  getContext().getCVContext().emitStringTable(*this); +} +void MCObjectStreamer::EmitCVFileChecksumsDirective() { +  getContext().getCVContext().emitFileChecksums(*this); +} + +  void MCObjectStreamer::EmitBytes(StringRef Data) { -  MCLineEntry::Make(this, getCurrentSection().first); +  MCCVLineEntry::Make(this); +  MCDwarfLineEntry::Make(this, getCurrentSection().first);    MCDataFragment *DF = getOrCreateDataFragment();    flushPendingLabels(DF, DF->getContents().size());    DF->getContents().append(Data.begin(), Data.end()); @@ -420,13 +471,18 @@ bool MCObjectStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,    if (!Offset.evaluateAsAbsolute(OffsetValue))      llvm_unreachable("Offset is not absolute"); +  if (OffsetValue < 0) +    llvm_unreachable("Offset is negative"); +    MCDataFragment *DF = getOrCreateDataFragment();    flushPendingLabels(DF, DF->getContents().size()); -  MCFixupKind Kind; -  if (!Assembler->getBackend().getFixupKind(Name, Kind)) +  Optional<MCFixupKind> MaybeKind = Assembler->getBackend().getFixupKind(Name); +  if (!MaybeKind.hasValue())      return true; +  MCFixupKind Kind = *MaybeKind; +    if (Expr == nullptr)      Expr =          MCSymbolRefExpr::create(getContext().createTempSymbol(), getContext()); @@ -434,11 +490,48 @@ bool MCObjectStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,    return false;  } -void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) { +void MCObjectStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {    const MCSection *Sec = getCurrentSection().first; +  (void)Sec;    assert(Sec && "need a section"); -  unsigned ItemSize = Sec->isVirtualSection() ? 0 : 1; -  insert(new MCFillFragment(FillValue, ItemSize, NumBytes)); +  insert(new MCFillFragment(FillValue, NumBytes)); +} + +void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue, +                                SMLoc Loc) { +  MCDataFragment *DF = getOrCreateDataFragment(); +  flushPendingLabels(DF, DF->getContents().size()); + +  int64_t IntNumBytes; +  if (!NumBytes.evaluateAsAbsolute(IntNumBytes, getAssembler())) { +    getContext().reportError(Loc, "expected absolute expression"); +    return; +  } + +  if (IntNumBytes <= 0) { +    getContext().reportError(Loc, "invalid number of bytes"); +    return; +  } + +  emitFill(IntNumBytes, FillValue); +} + +void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size, +                                int64_t Expr, SMLoc Loc) { +  int64_t IntNumValues; +  if (!NumValues.evaluateAsAbsolute(IntNumValues, getAssembler())) { +    getContext().reportError(Loc, "expected absolute expression"); +    return; +  } + +  if (IntNumValues < 0) { +    getContext().getSourceManager()->PrintMessage( +        Loc, SourceMgr::DK_Warning, +        "'.fill' directive with negative repeat count has no effect"); +    return; +  } + +  MCStreamer::emitFill(IntNumValues, Size, Expr);  }  void MCObjectStreamer::FinishImpl() { | 
