mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Move EmitFrameMoves into AsmPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100371 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3c754aa815
commit
02b86b93dc
@ -41,6 +41,7 @@ namespace llvm {
|
||||
class MachineConstantPoolValue;
|
||||
class MachineJumpTableInfo;
|
||||
class MachineModuleInfo;
|
||||
class MachineMove;
|
||||
class MCInst;
|
||||
class MCContext;
|
||||
class MCSection;
|
||||
@ -341,7 +342,7 @@ namespace llvm {
|
||||
/// 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 = 0);
|
||||
void EmitEncodingByte(unsigned Val, const char *Desc = 0) const;
|
||||
|
||||
/// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
|
||||
unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
|
||||
@ -361,6 +362,15 @@ namespace llvm {
|
||||
void EmitSectionOffset(const MCSymbol *Label,
|
||||
const MCSymbol *SectionLabel) const;
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Dwarf Lowering Routines
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||
/// frame.
|
||||
void EmitFrameMoves(const std::vector<MachineMove> &Moves,
|
||||
MCSymbol *BaseLabel, bool isEH) const;
|
||||
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Inline Asm Support
|
||||
|
@ -13,17 +13,24 @@
|
||||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
#include "llvm/CodeGen/AsmPrinter.h"
|
||||
#include "llvm/CodeGen/MachineLocation.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCSection.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Dwarf Emission Helper Routines
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// EmitSLEB128 - emit the specified signed leb128 value.
|
||||
void AsmPrinter::EmitSLEB128(int Value, const char *Desc) const {
|
||||
if (isVerbose() && Desc)
|
||||
@ -118,7 +125,7 @@ static const char *DecodeDWARFEncoding(unsigned Encoding) {
|
||||
/// encoding. If verbose assembly output is enabled, we output comments
|
||||
/// describing the encoding. Desc is an optional string saying what the
|
||||
/// encoding is specifying (e.g. "LSDA").
|
||||
void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) {
|
||||
void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) const {
|
||||
if (isVerbose()) {
|
||||
if (Desc != 0)
|
||||
OutStreamer.AddComment(Twine(Desc)+" Encoding = " +
|
||||
@ -196,4 +203,77 @@ void AsmPrinter::EmitSectionOffset(const MCSymbol *Label,
|
||||
EmitLabelDifference(Label, SectionLabel, 4);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Dwarf Lowering Routines
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||
/// frame.
|
||||
void AsmPrinter::EmitFrameMoves(const std::vector<MachineMove> &Moves,
|
||||
MCSymbol *BaseLabel, bool isEH) const {
|
||||
const TargetRegisterInfo *RI = TM.getRegisterInfo();
|
||||
|
||||
int stackGrowth = TM.getTargetData()->getPointerSize();
|
||||
if (TM.getFrameInfo()->getStackGrowthDirection() !=
|
||||
TargetFrameInfo::StackGrowsUp)
|
||||
stackGrowth *= -1;
|
||||
|
||||
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
|
||||
const MachineMove &Move = Moves[i];
|
||||
MCSymbol *Label = Move.getLabel();
|
||||
// Throw out move if the label is invalid.
|
||||
if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
|
||||
|
||||
const MachineLocation &Dst = Move.getDestination();
|
||||
const MachineLocation &Src = Move.getSource();
|
||||
|
||||
// Advance row if new location.
|
||||
if (BaseLabel && Label) {
|
||||
MCSymbol *ThisSym = Label;
|
||||
if (ThisSym != BaseLabel) {
|
||||
EmitCFAByte(dwarf::DW_CFA_advance_loc4);
|
||||
EmitLabelDifference(ThisSym, BaseLabel, 4);
|
||||
BaseLabel = ThisSym;
|
||||
}
|
||||
}
|
||||
|
||||
// If advancing cfa.
|
||||
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
|
||||
assert(!Src.isReg() && "Machine move not supported yet.");
|
||||
|
||||
if (Src.getReg() == MachineLocation::VirtualFP) {
|
||||
EmitCFAByte(dwarf::DW_CFA_def_cfa_offset);
|
||||
} else {
|
||||
EmitCFAByte(dwarf::DW_CFA_def_cfa);
|
||||
EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register");
|
||||
}
|
||||
|
||||
EmitULEB128(-Src.getOffset(), "Offset");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
|
||||
assert(Dst.isReg() && "Machine move not supported yet.");
|
||||
EmitCFAByte(dwarf::DW_CFA_def_cfa_register);
|
||||
EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register");
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), isEH);
|
||||
int Offset = Dst.getOffset() / stackGrowth;
|
||||
|
||||
if (Offset < 0) {
|
||||
EmitCFAByte(dwarf::DW_CFA_offset_extended_sf);
|
||||
EmitULEB128(Reg, "Reg");
|
||||
EmitSLEB128(Offset, "Offset");
|
||||
} else if (Reg < 64) {
|
||||
EmitCFAByte(dwarf::DW_CFA_offset + Reg);
|
||||
EmitULEB128(Offset, "Offset");
|
||||
} else {
|
||||
EmitCFAByte(dwarf::DW_CFA_offset_extended);
|
||||
EmitULEB128(Reg, "Reg");
|
||||
EmitULEB128(Offset, "Offset");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2852,7 +2852,7 @@ void DwarfDebug::emitCommonDebugFrame() {
|
||||
std::vector<MachineMove> Moves;
|
||||
RI->getInitialFrameState(Moves);
|
||||
|
||||
EmitFrameMoves(0, Moves, false);
|
||||
Asm->EmitFrameMoves(Moves, 0, false);
|
||||
|
||||
Asm->EmitAlignment(2, 0, 0, false);
|
||||
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common_end"));
|
||||
@ -2893,7 +2893,7 @@ emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo) {
|
||||
Asm->EmitLabelDifference(Asm->GetTempSymbol("func_end",DebugFrameInfo.Number),
|
||||
FuncBeginSym, TD->getPointerSize());
|
||||
|
||||
EmitFrameMoves(FuncBeginSym, DebugFrameInfo.Moves, false);
|
||||
Asm->EmitFrameMoves(DebugFrameInfo.Moves, FuncBeginSym, false);
|
||||
|
||||
Asm->EmitAlignment(2, 0, 0, false);
|
||||
Asm->OutStreamer.EmitLabel(DebugFrameEnd);
|
||||
|
@ -151,7 +151,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
|
||||
// Indicate locations of general callee saved registers in frame.
|
||||
std::vector<MachineMove> Moves;
|
||||
RI->getInitialFrameState(Moves);
|
||||
EmitFrameMoves(0, Moves, true);
|
||||
Asm->EmitFrameMoves(Moves, 0, true);
|
||||
|
||||
// On Darwin the linker honors the alignment of eh_frame, which means it must
|
||||
// be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
|
||||
@ -253,7 +253,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
|
||||
}
|
||||
|
||||
// Indicate locations of function specific callee saved registers in frame.
|
||||
EmitFrameMoves(EHFuncBeginSym, EHFrameInfo.Moves, true);
|
||||
Asm->EmitFrameMoves(EHFrameInfo.Moves, EHFuncBeginSym, true);
|
||||
|
||||
// On Darwin the linker honors the alignment of eh_frame, which means it
|
||||
// must be 8-byte on 64-bit targets to match what gcc does. Otherwise you
|
||||
|
@ -37,73 +37,3 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A)
|
||||
RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
|
||||
SubprogramCount(0) {
|
||||
}
|
||||
|
||||
|
||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||
/// frame.
|
||||
void DwarfPrinter::EmitFrameMoves(MCSymbol *BaseLabel,
|
||||
const std::vector<MachineMove> &Moves,
|
||||
bool isEH) {
|
||||
int stackGrowth = TD->getPointerSize();
|
||||
if (Asm->TM.getFrameInfo()->getStackGrowthDirection() !=
|
||||
TargetFrameInfo::StackGrowsUp)
|
||||
stackGrowth *= -1;
|
||||
|
||||
for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
|
||||
const MachineMove &Move = Moves[i];
|
||||
MCSymbol *Label = Move.getLabel();
|
||||
// Throw out move if the label is invalid.
|
||||
if (Label && !Label->isDefined()) continue; // Not emitted, in dead code.
|
||||
|
||||
const MachineLocation &Dst = Move.getDestination();
|
||||
const MachineLocation &Src = Move.getSource();
|
||||
|
||||
// Advance row if new location.
|
||||
if (BaseLabel && Label) {
|
||||
MCSymbol *ThisSym = Label;
|
||||
if (ThisSym != BaseLabel) {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_advance_loc4);
|
||||
Asm->EmitLabelDifference(ThisSym, BaseLabel, 4);
|
||||
BaseLabel = ThisSym;
|
||||
}
|
||||
}
|
||||
|
||||
// If advancing cfa.
|
||||
if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
|
||||
assert(!Src.isReg() && "Machine move not supported yet.");
|
||||
|
||||
if (Src.getReg() == MachineLocation::VirtualFP) {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa_offset);
|
||||
} else {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa);
|
||||
Asm->EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register");
|
||||
}
|
||||
|
||||
Asm->EmitULEB128(-Src.getOffset(), "Offset");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
|
||||
assert(Dst.isReg() && "Machine move not supported yet.");
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_def_cfa_register);
|
||||
Asm->EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register");
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), isEH);
|
||||
int Offset = Dst.getOffset() / stackGrowth;
|
||||
|
||||
if (Offset < 0) {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_offset_extended_sf);
|
||||
Asm->EmitULEB128(Reg, "Reg");
|
||||
Asm->EmitSLEB128(Offset, "Offset");
|
||||
} else if (Reg < 64) {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_offset + Reg);
|
||||
Asm->EmitULEB128(Offset, "Offset");
|
||||
} else {
|
||||
Asm->EmitCFAByte(dwarf::DW_CFA_offset_extended);
|
||||
Asm->EmitULEB128(Reg, "Reg");
|
||||
Asm->EmitULEB128(Offset, "Offset");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,6 @@ public:
|
||||
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
|
||||
const TargetData *getTargetData() const { return TD; }
|
||||
|
||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||
/// frame.
|
||||
void EmitFrameMoves(MCSymbol *BaseLabel,
|
||||
const std::vector<MachineMove> &Moves, bool isEH);
|
||||
};
|
||||
|
||||
} // end llvm namespace
|
||||
|
Loading…
Reference in New Issue
Block a user