forked from OSchip/llvm-project
now that the magic is dispelled, move EmitSectionOffset to AsmPrinter.
llvm-svn: 100368
This commit is contained in:
parent
324c86600d
commit
70a4fcea1e
|
@ -14,7 +14,9 @@
|
||||||
#define DEBUG_TYPE "asm-printer"
|
#define DEBUG_TYPE "asm-printer"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
#include "llvm/MC/MCSection.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
@ -158,3 +160,40 @@ void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{
|
||||||
TLOF.getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, OutStreamer);
|
TLOF.getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, OutStreamer);
|
||||||
OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0);
|
OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
|
||||||
|
/// section. This can be done with a special directive if the target supports
|
||||||
|
/// it (e.g. cygwin) or by emitting it as an offset from a label at the start
|
||||||
|
/// of the section.
|
||||||
|
///
|
||||||
|
/// SectionLabel is a temporary label emitted at the start of the section that
|
||||||
|
/// Label lives in.
|
||||||
|
void AsmPrinter::EmitSectionOffset(const MCSymbol *Label,
|
||||||
|
const MCSymbol *SectionLabel) const {
|
||||||
|
// On COFF targets, we have to emit the special .secrel32 directive.
|
||||||
|
if (const char *SecOffDir = MAI->getDwarfSectionOffsetDirective()) {
|
||||||
|
// FIXME: MCize.
|
||||||
|
OutStreamer.EmitRawText(SecOffDir + Twine(Label->getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the section that we're referring to, based on SectionLabel.
|
||||||
|
const MCSection &Section = SectionLabel->getSection();
|
||||||
|
|
||||||
|
// If Label has already been emitted, verify that it is in the same section as
|
||||||
|
// section label for sanity.
|
||||||
|
assert((!Label->isInSection() || &Label->getSection() == &Section) &&
|
||||||
|
"Section offset using wrong section base for label");
|
||||||
|
|
||||||
|
// If the section in question will end up with an address of 0 anyway, we can
|
||||||
|
// just emit an absolute reference to save a relocation.
|
||||||
|
if (Section.isBaseAddressKnownZero()) {
|
||||||
|
OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, emit it as a label difference from the start of the section.
|
||||||
|
EmitLabelDifference(Label, SectionLabel, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2567,7 +2567,8 @@ void DwarfDebug::emitDebugInfo() {
|
||||||
Asm->OutStreamer.AddComment("DWARF version number");
|
Asm->OutStreamer.AddComment("DWARF version number");
|
||||||
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
||||||
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
|
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
|
||||||
EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"), DwarfAbbrevSectionSym);
|
Asm->EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"),
|
||||||
|
DwarfAbbrevSectionSym);
|
||||||
Asm->OutStreamer.AddComment("Address Size (in bytes)");
|
Asm->OutStreamer.AddComment("Address Size (in bytes)");
|
||||||
Asm->EmitInt8(TD->getPointerSize());
|
Asm->EmitInt8(TD->getPointerSize());
|
||||||
|
|
||||||
|
@ -2878,8 +2879,8 @@ emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo) {
|
||||||
Asm->OutStreamer.EmitLabel(DebugFrameBegin);
|
Asm->OutStreamer.EmitLabel(DebugFrameBegin);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("FDE CIE offset");
|
Asm->OutStreamer.AddComment("FDE CIE offset");
|
||||||
EmitSectionOffset(Asm->GetTempSymbol("debug_frame_common"),
|
Asm->EmitSectionOffset(Asm->GetTempSymbol("debug_frame_common"),
|
||||||
DwarfFrameSectionSym);
|
DwarfFrameSectionSym);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("FDE initial location");
|
Asm->OutStreamer.AddComment("FDE initial location");
|
||||||
MCSymbol *FuncBeginSym =
|
MCSymbol *FuncBeginSym =
|
||||||
|
@ -2917,8 +2918,8 @@ void DwarfDebug::emitDebugPubNames() {
|
||||||
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
|
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
|
||||||
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
|
Asm->EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
|
||||||
DwarfInfoSectionSym);
|
DwarfInfoSectionSym);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Compilation Unit Length");
|
Asm->OutStreamer.AddComment("Compilation Unit Length");
|
||||||
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
|
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
|
||||||
|
@ -2961,8 +2962,8 @@ void DwarfDebug::emitDebugPubTypes() {
|
||||||
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
Asm->EmitInt16(dwarf::DWARF_VERSION);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Offset of Compilation ModuleCU Info");
|
Asm->OutStreamer.AddComment("Offset of Compilation ModuleCU Info");
|
||||||
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
|
Asm->EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
|
||||||
DwarfInfoSectionSym);
|
DwarfInfoSectionSym);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Compilation ModuleCU Length");
|
Asm->OutStreamer.AddComment("Compilation ModuleCU Length");
|
||||||
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
|
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
|
||||||
|
@ -3107,11 +3108,11 @@ void DwarfDebug::emitDebugInlineInfo() {
|
||||||
Asm->OutStreamer.EmitBytes(Name, 0);
|
Asm->OutStreamer.EmitBytes(Name, 0);
|
||||||
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
|
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
|
||||||
} else
|
} else
|
||||||
EmitSectionOffset(getStringPoolEntry(getRealLinkageName(LName)),
|
Asm->EmitSectionOffset(getStringPoolEntry(getRealLinkageName(LName)),
|
||||||
DwarfStrSectionSym);
|
DwarfStrSectionSym);
|
||||||
|
|
||||||
Asm->OutStreamer.AddComment("Function name");
|
Asm->OutStreamer.AddComment("Function name");
|
||||||
EmitSectionOffset(getStringPoolEntry(Name), DwarfStrSectionSym);
|
Asm->EmitSectionOffset(getStringPoolEntry(Name), DwarfStrSectionSym);
|
||||||
Asm->EmitULEB128(Labels.size(), "Inline count");
|
Asm->EmitULEB128(Labels.size(), "Inline count");
|
||||||
|
|
||||||
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
|
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSection.h"
|
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
|
@ -40,41 +39,6 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
|
|
||||||
/// section. This can be done with a special directive if the target supports
|
|
||||||
/// it (e.g. cygwin) or by emitting it as an offset from a label at the start
|
|
||||||
/// of the section.
|
|
||||||
///
|
|
||||||
/// SectionLabel is a temporary label emitted at the start of the section that
|
|
||||||
/// Label lives in.
|
|
||||||
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
|
|
||||||
const MCSymbol *SectionLabel) const {
|
|
||||||
// On COFF targets, we have to emit the special .secrel32 directive.
|
|
||||||
if (const char *SecOffDir = MAI->getDwarfSectionOffsetDirective()) {
|
|
||||||
// FIXME: MCize.
|
|
||||||
Asm->OutStreamer.EmitRawText(SecOffDir + Twine(Label->getName()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the section that we're referring to, based on SectionLabel.
|
|
||||||
const MCSection &Section = SectionLabel->getSection();
|
|
||||||
|
|
||||||
// If Label has already been emitted, verify that it is in the same section as
|
|
||||||
// section label for sanity.
|
|
||||||
assert((!Label->isInSection() || &Label->getSection() == &Section) &&
|
|
||||||
"Section offset using wrong section base for label");
|
|
||||||
|
|
||||||
// If the section in question will end up with an address of 0 anyway, we can
|
|
||||||
// just emit an absolute reference to save a relocation.
|
|
||||||
if (Section.isBaseAddressKnownZero()) {
|
|
||||||
Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, emit it as a label difference from the start of the section.
|
|
||||||
Asm->EmitLabelDifference(Label, SectionLabel, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||||
/// frame.
|
/// frame.
|
||||||
void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
|
void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
|
||||||
|
|
|
@ -74,16 +74,6 @@ public:
|
||||||
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
|
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
|
||||||
const TargetData *getTargetData() const { return TD; }
|
const TargetData *getTargetData() const { return TD; }
|
||||||
|
|
||||||
/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
|
|
||||||
/// section. This can be done with a special directive if the target supports
|
|
||||||
/// it (e.g. cygwin) or by emitting it as an offset from a label at the start
|
|
||||||
/// of the section.
|
|
||||||
///
|
|
||||||
/// SectionLabel is a temporary label emitted at the start of the section that
|
|
||||||
/// Label lives in.
|
|
||||||
void EmitSectionOffset(const MCSymbol *Label,
|
|
||||||
const MCSymbol *SectionLabel) const;
|
|
||||||
|
|
||||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||||
/// frame.
|
/// frame.
|
||||||
void EmitFrameMoves(MCSymbol *BaseLabel,
|
void EmitFrameMoves(MCSymbol *BaseLabel,
|
||||||
|
|
Loading…
Reference in New Issue