move EmitCFAByte to AsmPrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100348 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-04 20:01:25 +00:00
parent a64371828e
commit 7a101f45c1
2 changed files with 20 additions and 19 deletions

View File

@ -16,6 +16,7 @@
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Dwarf.h"
using namespace llvm;
/// EmitSLEB128 - emit the specified signed leb128 value.
@ -69,3 +70,15 @@ void AsmPrinter::EmitULEB128(unsigned Value, const char *Desc,
}
}
/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
void AsmPrinter::EmitCFAByte(unsigned Val) const {
if (isVerbose()) {
if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset+64)
OutStreamer.AddComment("DW_CFA_offset + Reg (" +
Twine(Val-dwarf::DW_CFA_offset) + ")");
else
OutStreamer.AddComment(dwarf::CallFrameString(Val));
}
OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}

View File

@ -100,18 +100,6 @@ void DwarfPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}
/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
void DwarfPrinter::EmitCFAByte(unsigned Val) {
if (Asm->isVerbose()) {
if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset+64)
Asm->OutStreamer.AddComment("DW_CFA_offset + Reg (" +
Twine(Val-dwarf::DW_CFA_offset) + ")");
else
Asm->OutStreamer.AddComment(dwarf::CallFrameString(Val));
}
Asm->OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
@ -176,7 +164,7 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
if (BaseLabel && Label) {
MCSymbol *ThisSym = Label;
if (ThisSym != BaseLabel) {
EmitCFAByte(dwarf::DW_CFA_advance_loc4);
Asm->EmitCFAByte(dwarf::DW_CFA_advance_loc4);
Asm->EmitLabelDifference(ThisSym, BaseLabel, 4);
BaseLabel = ThisSym;
}
@ -186,9 +174,9 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
if (!Src.isReg()) {
if (Src.getReg() == MachineLocation::VirtualFP) {
EmitCFAByte(dwarf::DW_CFA_def_cfa_offset);
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa_offset);
} else {
EmitCFAByte(dwarf::DW_CFA_def_cfa);
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa);
Asm->EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register");
}
@ -200,7 +188,7 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
} else if (Src.isReg() &&
Src.getReg() == MachineLocation::VirtualFP) {
if (Dst.isReg()) {
EmitCFAByte(dwarf::DW_CFA_def_cfa_register);
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa_register);
Asm->EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register");
} else {
llvm_unreachable("Machine move not supported yet.");
@ -210,14 +198,14 @@ void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
int Offset = Dst.getOffset() / stackGrowth;
if (Offset < 0) {
EmitCFAByte(dwarf::DW_CFA_offset_extended_sf);
Asm->EmitCFAByte(dwarf::DW_CFA_offset_extended_sf);
Asm->EmitULEB128(Reg, "Reg");
Asm->EmitSLEB128(Offset, "Offset");
} else if (Reg < 64) {
EmitCFAByte(dwarf::DW_CFA_offset + Reg);
Asm->EmitCFAByte(dwarf::DW_CFA_offset + Reg);
Asm->EmitULEB128(Offset, "Offset");
} else {
EmitCFAByte(dwarf::DW_CFA_offset_extended);
Asm->EmitCFAByte(dwarf::DW_CFA_offset_extended);
Asm->EmitULEB128(Reg, "Reg");
Asm->EmitULEB128(Offset, "Offset");
}