move some more stuff to asmprinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100351 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-04-04 20:20:50 +00:00
parent 9be4913136
commit d2af7853e3
5 changed files with 53 additions and 59 deletions

View File

@ -343,6 +343,15 @@ namespace llvm {
/// specifying (e.g. "LSDA").
void EmitEncodingByte(unsigned Val, const char *Desc = 0);
/// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
/// EmitReference - Emit a reference to a label with a specified encoding.
///
void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
//===------------------------------------------------------------------===//
// Inline Asm Support
//===------------------------------------------------------------------===//

View File

@ -15,6 +15,9 @@
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Dwarf.h"
using namespace llvm;
@ -126,3 +129,32 @@ void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
OutStreamer.EmitIntValue(Val, 1, 0/*addrspace*/);
}
/// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned AsmPrinter::GetSizeOfEncodedValue(unsigned Encoding) const {
if (Encoding == dwarf::DW_EH_PE_omit)
return 0;
switch (Encoding & 0x07) {
default: assert(0 && "Invalid encoded value.");
case dwarf::DW_EH_PE_absptr: return TM.getTargetData()->getPointerSize();
case dwarf::DW_EH_PE_udata2: return 2;
case dwarf::DW_EH_PE_udata4: return 4;
case dwarf::DW_EH_PE_udata8: return 8;
}
}
void AsmPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
const MCExpr *Exp =
TLOF.getExprForDwarfReference(Sym, Mang, MMI, Encoding, OutStreamer);
OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0);
}
void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
const MCExpr *Exp =
TLOF.getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, OutStreamer);
OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0);
}

View File

@ -106,7 +106,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
if (PersonalityFn) {
// There is a personality function.
*APtr++ = 'P';
AugmentationSize += 1 + SizeOfEncodedValue(PerEncoding);
AugmentationSize += 1 + Asm->GetSizeOfEncodedValue(PerEncoding);
}
if (UsesLSDA[Index]) {
@ -140,7 +140,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
if (PersonalityFn) {
Asm->EmitEncodingByte(PerEncoding, "Personality");
Asm->OutStreamer.AddComment("Personality");
EmitReference(PersonalityFn, PerEncoding);
Asm->EmitReference(PersonalityFn, PerEncoding);
}
if (UsesLSDA[Index])
Asm->EmitEncodingByte(LSDAEncoding, "LSDA");
@ -227,23 +227,24 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number);
Asm->OutStreamer.AddComment("FDE initial location");
EmitReference(EHFuncBeginSym, FDEEncoding);
Asm->EmitReference(EHFuncBeginSym, FDEEncoding);
Asm->OutStreamer.AddComment("FDE address range");
Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_func_end",
EHFrameInfo.Number),
EHFuncBeginSym, SizeOfEncodedValue(FDEEncoding));
EHFuncBeginSym,
Asm->GetSizeOfEncodedValue(FDEEncoding));
// If there is a personality and landing pads then point to the language
// specific data area in the exception table.
if (MMI->getPersonalities()[0] != NULL) {
unsigned Size = SizeOfEncodedValue(LSDAEncoding);
unsigned Size = Asm->GetSizeOfEncodedValue(LSDAEncoding);
Asm->EmitULEB128(Size, "Augmentation size");
Asm->OutStreamer.AddComment("Language Specific Data Area");
if (EHFrameInfo.hasLandingPads)
EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
LSDAEncoding);
Asm->EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
LSDAEncoding);
else
Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
@ -681,7 +682,7 @@ void DwarfException::EmitExceptionTable() {
// in target-independent code.
//
TTypeEncoding = Asm->getObjFileLowering().getTTypeEncoding();
TypeFormatSize = SizeOfEncodedValue(TTypeEncoding);
TypeFormatSize = Asm->GetSizeOfEncodedValue(TTypeEncoding);
}
// Begin the exception table.
@ -867,9 +868,10 @@ void DwarfException::EmitExceptionTable() {
Asm->OutStreamer.AddComment("TypeInfo");
if (GV)
EmitReference(GV, TTypeEncoding);
Asm->EmitReference(GV, TTypeEncoding);
else
Asm->OutStreamer.EmitIntValue(0, SizeOfEncodedValue(TTypeEncoding), 0);
Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding),
0);
}
// Emit the Exception Specifications.

View File

@ -37,37 +37,6 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A)
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
SubprogramCount(0) {}
/// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const {
if (Encoding == dwarf::DW_EH_PE_omit)
return 0;
switch (Encoding & 0x07) {
default: assert(0 && "Invalid encoded value.");
case dwarf::DW_EH_PE_absptr: return TD->getPointerSize();
case dwarf::DW_EH_PE_udata2: return 2;
case dwarf::DW_EH_PE_udata4: return 4;
case dwarf::DW_EH_PE_udata8: return 8;
}
}
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Asm->Mang,
Asm->MMI, Encoding,
Asm->OutStreamer);
Asm->OutStreamer.EmitValue(Exp, SizeOfEncodedValue(Encoding), /*addrspace*/0);
}
void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
const MCExpr *Exp =
TLOF.getExprForDwarfGlobalReference(GV, Asm->Mang, Asm->MMI, Encoding,
Asm->OutStreamer);
Asm->OutStreamer.EmitValue(Exp, SizeOfEncodedValue(Encoding), /*addrspace*/0);
}
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
const MCSymbol *Section,

View File

@ -74,24 +74,6 @@ public:
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
const TargetData *getTargetData() const { return TD; }
/// SizeOfEncodedValue - Return the size of the encoding in bytes.
unsigned SizeOfEncodedValue(unsigned Encoding) const;
/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
/// encoding. If verbose assembly output is enabled, we output comments
/// describing the encoding. Desc is a string saying what the encoding is
/// specifying (e.g. "LSDA").
void EmitEncodingByte(unsigned Val, const char *Desc);
/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
void EmitCFAByte(unsigned Val);
/// EmitReference - Emit a reference to a label.
///
void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
/// EmitSectionOffset - Emit Label-Section or use a special purpose directive
/// to emit a section offset if the target has one.
void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,