mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
Make DwarfExpression store the AsmPrinter instead of the TargetMachine.
NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0ec7e836f9
commit
df545e8d6c
@ -133,6 +133,7 @@ public:
|
|||||||
virtual ~AsmPrinter();
|
virtual ~AsmPrinter();
|
||||||
|
|
||||||
DwarfDebug *getDwarfDebug() { return DD; }
|
DwarfDebug *getDwarfDebug() { return DD; }
|
||||||
|
DwarfDebug *getDwarfDebug() const { return DD; }
|
||||||
|
|
||||||
/// Return true if assembly output should contain comments.
|
/// Return true if assembly output should contain comments.
|
||||||
///
|
///
|
||||||
|
@ -37,8 +37,8 @@ class DebugLocDwarfExpression : public DwarfExpression {
|
|||||||
ByteStreamer &BS;
|
ByteStreamer &BS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebugLocDwarfExpression(TargetMachine &TM, ByteStreamer &BS)
|
DebugLocDwarfExpression(const AsmPrinter &AP, ByteStreamer &BS)
|
||||||
: DwarfExpression(TM), BS(BS) {}
|
: DwarfExpression(AP), BS(BS) {}
|
||||||
|
|
||||||
void EmitOp(uint8_t Op, const char *Comment) override;
|
void EmitOp(uint8_t Op, const char *Comment) override;
|
||||||
void EmitSigned(int Value) override;
|
void EmitSigned(int Value) override;
|
||||||
@ -222,14 +222,14 @@ void AsmPrinter::EmitDwarfRegOpPiece(ByteStreamer &Streamer,
|
|||||||
unsigned PieceSizeInBits,
|
unsigned PieceSizeInBits,
|
||||||
unsigned PieceOffsetInBits) const {
|
unsigned PieceOffsetInBits) const {
|
||||||
assert(MLoc.isReg() && "MLoc must be a register");
|
assert(MLoc.isReg() && "MLoc must be a register");
|
||||||
DebugLocDwarfExpression Expr(TM, Streamer);
|
DebugLocDwarfExpression Expr(*this, Streamer);
|
||||||
Expr.AddMachineRegPiece(MLoc.getReg(), PieceSizeInBits, PieceOffsetInBits);
|
Expr.AddMachineRegPiece(MLoc.getReg(), PieceSizeInBits, PieceOffsetInBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::EmitDwarfOpPiece(ByteStreamer &Streamer,
|
void AsmPrinter::EmitDwarfOpPiece(ByteStreamer &Streamer,
|
||||||
unsigned PieceSizeInBits,
|
unsigned PieceSizeInBits,
|
||||||
unsigned PieceOffsetInBits) const {
|
unsigned PieceOffsetInBits) const {
|
||||||
DebugLocDwarfExpression Expr(TM, Streamer);
|
DebugLocDwarfExpression Expr(*this, Streamer);
|
||||||
Expr.AddOpPiece(PieceSizeInBits, PieceOffsetInBits);
|
Expr.AddOpPiece(PieceSizeInBits, PieceOffsetInBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ void AsmPrinter::EmitDwarfOpPiece(ByteStreamer &Streamer,
|
|||||||
void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
|
void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
|
||||||
const MachineLocation &MLoc,
|
const MachineLocation &MLoc,
|
||||||
bool Indirect) const {
|
bool Indirect) const {
|
||||||
DebugLocDwarfExpression Expr(TM, Streamer);
|
DebugLocDwarfExpression Expr(*this, Streamer);
|
||||||
const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo();
|
const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo();
|
||||||
int Reg = TRI->getDwarfRegNum(MLoc.getReg(), false);
|
int Reg = TRI->getDwarfRegNum(MLoc.getReg(), false);
|
||||||
if (Reg < 0) {
|
if (Reg < 0) {
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "DwarfExpression.h"
|
#include "DwarfExpression.h"
|
||||||
|
|
||||||
|
#include "DwarfDebug.h"
|
||||||
#include "llvm/ADT/SmallBitVector.h"
|
#include "llvm/ADT/SmallBitVector.h"
|
||||||
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/Support/Dwarf.h"
|
#include "llvm/Support/Dwarf.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
@ -21,6 +24,10 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
const TargetRegisterInfo *DwarfExpression::getTRI() const {
|
||||||
|
return AP.TM.getSubtargetImpl()->getRegisterInfo();
|
||||||
|
}
|
||||||
|
|
||||||
void DwarfExpression::AddReg(int DwarfReg, const char* Comment) {
|
void DwarfExpression::AddReg(int DwarfReg, const char* Comment) {
|
||||||
assert(DwarfReg >= 0 && "invalid negative dwarf register number");
|
assert(DwarfReg >= 0 && "invalid negative dwarf register number");
|
||||||
if (DwarfReg < 32) {
|
if (DwarfReg < 32) {
|
||||||
@ -66,8 +73,7 @@ void DwarfExpression::AddShr(unsigned ShiftBy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DwarfExpression::AddMachineRegIndirect(unsigned MachineReg, int Offset) {
|
bool DwarfExpression::AddMachineRegIndirect(unsigned MachineReg, int Offset) {
|
||||||
const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo();
|
int DwarfReg = getTRI()->getDwarfRegNum(MachineReg, false);
|
||||||
int DwarfReg = TRI->getDwarfRegNum(MachineReg, false);
|
|
||||||
if (DwarfReg < 0)
|
if (DwarfReg < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -84,7 +90,7 @@ bool DwarfExpression::AddMachineRegIndirect(unsigned MachineReg, int Offset) {
|
|||||||
void DwarfExpression::AddMachineRegPiece(unsigned MachineReg,
|
void DwarfExpression::AddMachineRegPiece(unsigned MachineReg,
|
||||||
unsigned PieceSizeInBits,
|
unsigned PieceSizeInBits,
|
||||||
unsigned PieceOffsetInBits) {
|
unsigned PieceOffsetInBits) {
|
||||||
const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo();
|
const TargetRegisterInfo *TRI = getTRI();
|
||||||
int Reg = TRI->getDwarfRegNum(MachineReg, false);
|
int Reg = TRI->getDwarfRegNum(MachineReg, false);
|
||||||
|
|
||||||
// If this is a valid register number, emit it.
|
// If this is a valid register number, emit it.
|
||||||
|
@ -18,16 +18,20 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class TargetMachine;
|
class AsmPrinter;
|
||||||
|
class TargetRegisterInfo;
|
||||||
|
|
||||||
/// Base class containing the logic for constructing DWARF expressions
|
/// Base class containing the logic for constructing DWARF expressions
|
||||||
/// independently of whether they are emitted into a DIE or into a .debug_loc
|
/// independently of whether they are emitted into a DIE or into a .debug_loc
|
||||||
/// entry.
|
/// entry.
|
||||||
class DwarfExpression {
|
class DwarfExpression {
|
||||||
protected:
|
protected:
|
||||||
TargetMachine &TM;
|
const AsmPrinter &AP;
|
||||||
|
// Various convenience accessors that extract things out of AsmPrinter.
|
||||||
|
const TargetRegisterInfo *getTRI() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DwarfExpression(TargetMachine &TM) : TM(TM) {}
|
DwarfExpression(const AsmPrinter &AP) : AP(AP) {}
|
||||||
virtual ~DwarfExpression() {}
|
virtual ~DwarfExpression() {}
|
||||||
|
|
||||||
virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0;
|
virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0;
|
||||||
|
@ -49,8 +49,8 @@ class DIEDwarfExpression : public DwarfExpression {
|
|||||||
DwarfUnit &DU;
|
DwarfUnit &DU;
|
||||||
DIELoc &DIE;
|
DIELoc &DIE;
|
||||||
public:
|
public:
|
||||||
DIEDwarfExpression(TargetMachine &TM, DwarfUnit &DU, DIELoc &DIE)
|
DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU, DIELoc &DIE)
|
||||||
: DwarfExpression(TM), DU(DU), DIE(DIE) {}
|
: DwarfExpression(AP), DU(DU), DIE(DIE) {}
|
||||||
|
|
||||||
void EmitOp(uint8_t Op, const char* Comment = nullptr) override;
|
void EmitOp(uint8_t Op, const char* Comment = nullptr) override;
|
||||||
void EmitSigned(int Value) override;
|
void EmitSigned(int Value) override;
|
||||||
@ -68,8 +68,7 @@ void DIEDwarfExpression::EmitUnsigned(unsigned Value) {
|
|||||||
DU.addUInt(DIE, dwarf::DW_FORM_udata, Value);
|
DU.addUInt(DIE, dwarf::DW_FORM_udata, Value);
|
||||||
}
|
}
|
||||||
unsigned DIEDwarfExpression::getFrameRegister() {
|
unsigned DIEDwarfExpression::getFrameRegister() {
|
||||||
const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo();
|
return getTRI()->getFrameRegister(*AP.MF);
|
||||||
return TRI->getFrameRegister(*DU.getAsmPrinter()->MF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -431,7 +430,7 @@ void DwarfUnit::addSourceLine(DIE &Die, DINameSpace NS) {
|
|||||||
/// addRegisterOp - Add register operand.
|
/// addRegisterOp - Add register operand.
|
||||||
bool DwarfUnit::addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
|
bool DwarfUnit::addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
|
||||||
unsigned SizeInBits, unsigned OffsetInBits) {
|
unsigned SizeInBits, unsigned OffsetInBits) {
|
||||||
DIEDwarfExpression Expr(Asm->TM, *this, TheDie);
|
DIEDwarfExpression Expr(*Asm, *this, TheDie);
|
||||||
Expr.AddMachineRegPiece(Reg, SizeInBits, OffsetInBits);
|
Expr.AddMachineRegPiece(Reg, SizeInBits, OffsetInBits);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -439,7 +438,7 @@ bool DwarfUnit::addRegisterOpPiece(DIELoc &TheDie, unsigned Reg,
|
|||||||
/// addRegisterOffset - Add register offset.
|
/// addRegisterOffset - Add register offset.
|
||||||
bool DwarfUnit::addRegisterOffset(DIELoc &TheDie, unsigned Reg,
|
bool DwarfUnit::addRegisterOffset(DIELoc &TheDie, unsigned Reg,
|
||||||
int64_t Offset) {
|
int64_t Offset) {
|
||||||
DIEDwarfExpression Expr(Asm->TM, *this, TheDie);
|
DIEDwarfExpression Expr(*Asm, *this, TheDie);
|
||||||
return Expr.AddMachineRegIndirect(Reg, Offset);
|
return Expr.AddMachineRegIndirect(Reg, Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user