diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-01-13 00:04:06 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-01-13 00:04:06 +0000 |
commit | 66f25958450064bece4428cc9aa49cdcc42f46dc (patch) | |
tree | 7a4445b4f5e7f7853499287ae6d69417e194ec5f /llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | |
parent | 1777c12206805b032aa448b44eec9a3d635124a1 (diff) | |
download | bcm5719-llvm-66f25958450064bece4428cc9aa49cdcc42f46dc.tar.gz bcm5719-llvm-66f25958450064bece4428cc9aa49cdcc42f46dc.zip |
Debug Info: Move support for constants into DwarfExpression.
Move the declaration of DebugLocDwarfExpression into DwarfExpression.h
because it needs to be accessed from AsmPrinterDwarf.cpp and DwarfDebug.cpp
NFC.
llvm-svn: 225734
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 767846c224a..1df0ea4f79f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -21,14 +21,17 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" - using namespace llvm; const TargetRegisterInfo *DwarfExpression::getTRI() const { return AP.TM.getSubtargetImpl()->getRegisterInfo(); } -void DwarfExpression::AddReg(int DwarfReg, const char* Comment) { +unsigned DwarfExpression::getDwarfVersion() const { + return AP.getDwarfDebug()->getDwarfVersion(); +} + +void DwarfExpression::AddReg(int DwarfReg, const char *Comment) { assert(DwarfReg >= 0 && "invalid negative dwarf register number"); if (DwarfReg < 32) { EmitOp(dwarf::DW_OP_reg0 + DwarfReg, Comment); @@ -51,8 +54,7 @@ void DwarfExpression::AddRegIndirect(int DwarfReg, int Offset, bool Deref) { EmitOp(dwarf::DW_OP_deref); } -void DwarfExpression::AddOpPiece(unsigned SizeInBits, - unsigned OffsetInBits) { +void DwarfExpression::AddOpPiece(unsigned SizeInBits, unsigned OffsetInBits) { assert(SizeInBits > 0 && "piece has size zero"); const unsigned SizeOfByte = 8; if (OffsetInBits > 0 || SizeInBits % SizeOfByte) { @@ -164,3 +166,28 @@ void DwarfExpression::AddMachineRegPiece(unsigned MachineReg, // FIXME: We have no reasonable way of handling errors in here. EmitOp(dwarf::DW_OP_nop, "nop (could not find a dwarf register number)"); } + +void DwarfExpression::AddSignedConstant(int Value) { + EmitOp(dwarf::DW_OP_consts); + EmitSigned(Value); + // The proper way to describe a constant value is + // DW_OP_constu <const>, DW_OP_stack_value. + // Unfortunately, DW_OP_stack_value was not available until DWARF-4, + // so we will continue to generate DW_OP_constu <const> for DWARF-2 + // and DWARF-3. Technically, this is incorrect since DW_OP_const <const> + // actually describes a value at a constant addess, not a constant value. + // However, in the past there was no better way to describe a constant + // value, so the producers and consumers started to rely on heuristics + // to disambiguate the value vs. location status of the expression. + // See PR21176 for more details. + if (getDwarfVersion() >= 4) + EmitOp(dwarf::DW_OP_stack_value); +} + +void DwarfExpression::AddUnsignedConstant(unsigned Value) { + EmitOp(dwarf::DW_OP_constu); + EmitUnsigned(Value); + // cf. comment in DwarfExpression::AddSignedConstant(). + if (getDwarfVersion() >= 4) + EmitOp(dwarf::DW_OP_stack_value); +} |