diff options
author | Derek Schuff <dschuff@chromium.org> | 2013-01-30 11:34:40 -0800 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2013-01-30 11:34:40 -0800 |
commit | 1843e19bce9b11fc840858e136c6c52cf8b42e0b (patch) | |
tree | e8bfc928152e2d3b3dd120d141d13dc08a9b49e4 /lib/MC/MCObjectStreamer.cpp | |
parent | aa0fa8a8df25807f784ec9ca9deeb40328636595 (diff) | |
parent | a662a9862501fc86904e90054f7c1519101d9126 (diff) |
Merge commit 'a662a9862501fc86904e90054f7c1519101d9126'
Conflicts:
include/llvm/CodeGen/IntrinsicLowering.h
include/llvm/MC/MCAssembler.h
include/llvm/MC/MCObjectStreamer.h
lib/LLVMBuild.txt
lib/Linker/LinkArchives.cpp
lib/MC/MCAssembler.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/MCParser/AsmParser.cpp
lib/MC/MCPureStreamer.cpp
lib/MC/WinCOFFStreamer.cpp
lib/Makefile
lib/Support/Unix/Memory.inc
lib/Support/Unix/Process.inc
lib/Support/Unix/Program.inc
lib/Target/ARM/ARM.h
lib/Target/ARM/ARMFastISel.cpp
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
lib/Target/Mips/MipsInstrFPU.td
lib/Target/X86/CMakeLists.txt
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86TargetMachine.cpp
lib/Target/X86/X86TargetObjectFile.cpp
lib/Transforms/InstCombine/InstCombineCalls.cpp
test/CodeGen/X86/fast-isel-x86-64.ll
tools/llc/llc.cpp
tools/lto/LTOModule.cpp
utils/TableGen/EDEmitter.cpp
Diffstat (limited to 'lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | lib/MC/MCObjectStreamer.cpp | 124 |
1 files changed, 55 insertions, 69 deletions
diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index d34eb3c435..471170491e 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -16,7 +16,6 @@ #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" -#include "llvm/MC/MCSection.h" // @LOCALMOD #include "llvm/MC/MCSymbol.h" #include "llvm/Support/ErrorHandling.h" using namespace llvm; @@ -45,6 +44,13 @@ MCObjectStreamer::~MCObjectStreamer() { delete Assembler; } +void MCObjectStreamer::reset() { + if (Assembler) + Assembler->reset(); + CurSectionData = 0; + MCStreamer::reset(); +} + MCFragment *MCObjectStreamer::getCurrentFragment() const { assert(getCurrentSectionData() && "No current section!"); @@ -100,9 +106,9 @@ void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, EmitIntValue(AbsValue, Size, AddrSpace); return; } - DF->addFixup(MCFixup::Create(DF->getContents().size(), - Value, - MCFixup::getKindForSize(Size, false))); + DF->getFixups().push_back( + MCFixup::Create(DF->getContents().size(), Value, + MCFixup::getKindForSize(Size, false))); DF->getContents().resize(DF->getContents().size() + Size, 0); } @@ -129,6 +135,10 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) { SD.setOffset(F->getContents().size()); } +void MCObjectStreamer::EmitDebugLabel(MCSymbol *Symbol) { + EmitLabel(Symbol); +} + void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) { int64_t IntValue; if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { @@ -154,62 +164,18 @@ void MCObjectStreamer::EmitWeakReference(MCSymbol *Alias, report_fatal_error("This file format doesn't support weak aliases."); } -// @LOCALMOD-BEGIN ======================================================== - -void MCObjectStreamer::EmitBundleAlignStart() { - MCSectionData *SD = getCurrentSectionData(); - assert(SD->isBundlingEnabled() && - ".bundle_align_start called, but bundling disabled!"); - assert(!SD->isBundleLocked() && - ".bundle_align_start while bundle locked"); - SD->setBundleAlignNext(MCFragment::BundleAlignStart); -} - -void MCObjectStreamer::EmitBundleAlignEnd() { - MCSectionData *SD = getCurrentSectionData(); - assert(SD->isBundlingEnabled() && - ".bundle_align_end called, but bundling disabled!"); - assert(!SD->isBundleLocked() && - ".bundle_align_end while bundle locked"); - SD->setBundleAlignNext(MCFragment::BundleAlignEnd); -} - -void MCObjectStreamer::EmitBundleLock() { - MCSectionData *SD = getCurrentSectionData(); - assert(SD->isBundlingEnabled() && - ".bundle_lock called, but bundling disabled!"); - assert(!SD->isBundleLocked() && - ".bundle_lock issued when bundle already locked"); - SD->setBundleLocked(true); - SD->setBundleGroupFirstFrag(true); -} - -void MCObjectStreamer::EmitBundleUnlock() { - MCSectionData *SD = getCurrentSectionData(); - assert(SD->isBundlingEnabled() && - ".bundle_unlock called, but bundling disabled!"); - assert(SD->isBundleLocked() && - ".bundle_unlock called when bundle not locked"); - // If there has been at least one fragment emitted inside - // this bundle lock, then we need to mark the last emitted - // fragment as the group end. - if (!SD->isBundleGroupFirstFrag()) { - assert(getCurrentFragment() != NULL); - getCurrentFragment()->setBundleGroupEnd(true); - } - SD->setBundleLocked(false); - SD->setBundleGroupFirstFrag(false); -} -// @LOCALMOD-END ========================================================== - void MCObjectStreamer::ChangeSection(const MCSection *Section) { assert(Section && "Cannot switch to a null section!"); CurSectionData = &getAssembler().getOrCreateSectionData(*Section); } -void MCObjectStreamer::EmitInstruction(const MCInst &Inst) { +void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { + getAssembler().getOrCreateSymbolData(*Symbol); + Symbol->setVariableValue(AddValueSymbols(Value)); +} +void MCObjectStreamer::EmitInstruction(const MCInst &Inst) { // @LOCALMOD-BEGIN if (getAssembler().getBackend().CustomExpandInst(Inst, *this)) { return; @@ -221,21 +187,27 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) { if (Inst.getOperand(i).isExpr()) AddValueSymbols(Inst.getOperand(i).getExpr()); - getCurrentSectionData()->setHasInstructions(true); + MCSectionData *SD = getCurrentSectionData(); + SD->setHasInstructions(true); // 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()); // If this instruction doesn't need relaxation, just emit it as data. - if (!getAssembler().getBackend().mayNeedRelaxation(Inst)) { + MCAssembler &Assembler = getAssembler(); + if (!Assembler.getBackend().mayNeedRelaxation(Inst)) { EmitInstToData(Inst); return; } - // Otherwise, if we are relaxing everything, relax the instruction as much as - // possible and emit it as data. - if (getAssembler().getRelaxAll()) { + // Otherwise, relax and emit it as data if either: + // - The RelaxAll flag was passed + // - Bundling is enabled and this instruction is inside a bundle-locked + // group. We want to emit all such instructions into the same data + // fragment. + if (Assembler.getRelaxAll() || + (Assembler.isBundlingEnabled() && SD->isBundleLocked())) { MCInst Relaxed; getAssembler().getBackend().relaxInstruction(Inst, Relaxed); while (getAssembler().getBackend().mayNeedRelaxation(Relaxed)) @@ -249,13 +221,31 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) { } void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst) { - MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData()); + // Always create a new, separate fragment here, because its size can change + // during relaxation. + MCRelaxableFragment *IF = + new MCRelaxableFragment(Inst, getCurrentSectionData()); SmallString<128> Code; raw_svector_ostream VecOS(Code); getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, IF->getFixups()); VecOS.flush(); - IF->getCode().append(Code.begin(), Code.end()); + IF->getContents().append(Code.begin(), Code.end()); +} + +const char *BundlingNotImplementedMsg = + "Aligned bundling is not implemented for this object format"; + +void MCObjectStreamer::EmitBundleAlignMode(unsigned AlignPow2) { + llvm_unreachable(BundlingNotImplementedMsg); +} + +void MCObjectStreamer::EmitBundleLock(bool AlignToEnd) { + llvm_unreachable(BundlingNotImplementedMsg); +} + +void MCObjectStreamer::EmitBundleUnlock() { + llvm_unreachable(BundlingNotImplementedMsg); } void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta, @@ -291,7 +281,6 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, void MCObjectStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { assert(AddrSpace == 0 && "Address space must be 0!"); getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end()); - getCurrentSectionData()->MarkBundleOffsetUnknown(); // @LOCALMOD } void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment, @@ -303,10 +292,6 @@ void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment, new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit, getCurrentSectionData()); - // @LOCALMOD-BEGIN - // Bump the bundle offset to account for alignment. - getCurrentSectionData()->AlignBundleOffsetTo(ByteAlignment); - // @LOCALMOD-END // Update the maximum alignment on the current section if necessary. if (ByteAlignment > getCurrentSectionData()->getAlignment()) getCurrentSectionData()->setAlignment(ByteAlignment); @@ -336,7 +321,7 @@ bool MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, if (!Delta->EvaluateAsAbsolute(Res, getAssembler())) return true; - EmitFill(Res, Value, 0); + EmitFill(Res, Value); return false; } @@ -344,7 +329,8 @@ bool MCObjectStreamer::EmitValueToOffset(const MCExpr *Offset, void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) { MCDataFragment *DF = getOrCreateDataFragment(); - DF->addFixup(MCFixup::Create(DF->getContents().size(), Value, FK_GPRel_4)); + DF->getFixups().push_back(MCFixup::Create(DF->getContents().size(), + Value, FK_GPRel_4)); DF->getContents().resize(DF->getContents().size() + 4, 0); } @@ -352,7 +338,8 @@ void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) { void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) { MCDataFragment *DF = getOrCreateDataFragment(); - DF->addFixup(MCFixup::Create(DF->getContents().size(), Value, FK_GPRel_4)); + DF->getFixups().push_back(MCFixup::Create(DF->getContents().size(), + Value, FK_GPRel_4)); DF->getContents().resize(DF->getContents().size() + 8, 0); } @@ -362,7 +349,6 @@ void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue, // FIXME: A MCFillFragment would be more memory efficient but MCExpr has // problems evaluating expressions across multiple fragments. getOrCreateDataFragment()->getContents().append(NumBytes, FillValue); - getCurrentSectionData()->MarkBundleOffsetUnknown(); } void MCObjectStreamer::FinishImpl() { |