mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-18 10:24:45 +00:00
Debug Info: Implement DwarfCompileUnit::addComplexAddress() using
DIEDwarfExpression (and get rid of a bunch of redundant code). NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "DwarfCompileUnit.h"
|
#include "DwarfCompileUnit.h"
|
||||||
|
|
||||||
|
#include "DwarfExpression.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/GlobalValue.h"
|
#include "llvm/IR/GlobalValue.h"
|
||||||
@@ -771,53 +772,19 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die,
|
|||||||
dwarf::Attribute Attribute,
|
dwarf::Attribute Attribute,
|
||||||
const MachineLocation &Location) {
|
const MachineLocation &Location) {
|
||||||
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
DIELoc *Loc = new (DIEValueAllocator) DIELoc();
|
||||||
unsigned N = DV.getNumAddrElements();
|
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
|
||||||
unsigned i = 0;
|
DIExpression Expr = DV.getExpression();
|
||||||
bool validReg;
|
if (Location.getOffset()) {
|
||||||
if (Location.isReg()) {
|
if (DwarfExpr.AddMachineRegIndirect(Location.getReg(),
|
||||||
if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_plus) {
|
Location.getOffset())) {
|
||||||
assert(!DV.getVariable().isIndirect() &&
|
DwarfExpr.AddExpression(Expr);
|
||||||
"double indirection not handled");
|
assert(!DV.getVariable().isIndirect()
|
||||||
// If first address element is OpPlus then emit
|
&& "double indirection not handled");
|
||||||
// DW_OP_breg + Offset instead of DW_OP_reg + Offset.
|
}
|
||||||
validReg = addRegisterOffset(*Loc, Location.getReg(), DV.getAddrElement(1));
|
} else {
|
||||||
i = 2;
|
if (DwarfExpr.AddMachineRegExpression(Expr, Location.getReg()))
|
||||||
} else if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_deref) {
|
if (DV.getVariable().isIndirect())
|
||||||
assert(!DV.getVariable().isIndirect() &&
|
DwarfExpr.EmitOp(dwarf::DW_OP_deref);
|
||||||
"double indirection not handled");
|
|
||||||
validReg = addRegisterOpPiece(*Loc, Location.getReg(),
|
|
||||||
DV.getExpression().getPieceSize(),
|
|
||||||
DV.getExpression().getPieceOffset());
|
|
||||||
i = 3;
|
|
||||||
} else
|
|
||||||
validReg = addRegisterOpPiece(*Loc, Location.getReg());
|
|
||||||
} else
|
|
||||||
validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset());
|
|
||||||
|
|
||||||
if (!validReg)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (; i < N; ++i) {
|
|
||||||
uint64_t Element = DV.getAddrElement(i);
|
|
||||||
if (Element == dwarf::DW_OP_plus) {
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_udata, DV.getAddrElement(++i));
|
|
||||||
|
|
||||||
} else if (Element == dwarf::DW_OP_deref) {
|
|
||||||
if (!Location.isReg())
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
|
|
||||||
|
|
||||||
} else if (Element == dwarf::DW_OP_piece) {
|
|
||||||
const unsigned SizeOfByte = 8;
|
|
||||||
unsigned PieceOffsetInBits = DV.getAddrElement(++i) * SizeOfByte;
|
|
||||||
unsigned PieceSizeInBits = DV.getAddrElement(++i) * SizeOfByte;
|
|
||||||
// Emit DW_OP_bit_piece Size Offset.
|
|
||||||
assert(PieceSizeInBits > 0 && "piece has zero size");
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_bit_piece);
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_udata, PieceSizeInBits);
|
|
||||||
addUInt(*Loc, dwarf::DW_FORM_udata, PieceOffsetInBits);
|
|
||||||
} else
|
|
||||||
llvm_unreachable("unknown DIBuilder Opcode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now attach the location information to the DIE.
|
// Now attach the location information to the DIE.
|
||||||
|
Reference in New Issue
Block a user