diff options
author | Adrian Prantl <aprantl@apple.com> | 2015-01-12 22:19:22 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2015-01-12 22:19:22 +0000 |
commit | b16d9ebb0c53c8b3631dc3d8420e4fba538598ad (patch) | |
tree | d77587320193c07e29e0dfa6f1031e9ca50e6939 /llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | |
parent | 0d4fb985042bc00d4a9ed017a652f6840061a6db (diff) | |
download | bcm5719-llvm-b16d9ebb0c53c8b3631dc3d8420e4fba538598ad.tar.gz bcm5719-llvm-b16d9ebb0c53c8b3631dc3d8420e4fba538598ad.zip |
Debug info: Factor out the creation of DWARF expressions from AsmPrinter
into a new class DwarfExpression that can be shared between AsmPrinter
and DwarfUnit.
This is the first step towards unifying the two entirely redundant
implementations of dwarf expression emission in DwarfUnit and AsmPrinter.
Almost no functional change — Testcases were updated because asm comments
that used to be on two lines now appear on the same line, which is
actually preferable.
llvm-svn: 225706
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h new file mode 100644 index 00000000000..193f4307d88 --- /dev/null +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -0,0 +1,65 @@ +//===-- llvm/CodeGen/DwarfExpression.h - Dwarf Compile Unit ---*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains support for writing dwarf compile unit. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H +#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H + +#include "llvm/Support/DataTypes.h" + +namespace llvm { + +class TargetMachine; + +/// Base class containing the logic for constructing DWARF expressions +/// independently of whether they are emitted into a DIE or into a .debug_loc +/// entry. +class DwarfExpression { + TargetMachine &TM; +public: + DwarfExpression(TargetMachine &TM) : TM(TM) {} + + virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0; + virtual void EmitSigned(int Value) = 0; + virtual void EmitUnsigned(unsigned Value) = 0; + /// Emit a dwarf register operation. + void AddReg(int DwarfReg, const char* Comment = nullptr); + /// Emit an (double-)indirect dwarf register operation. + void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false); + + /// Emit a dwarf register operation for describing + /// - a small value occupying only part of a register or + /// - a register representing only part of a value. + void AddOpPiece(unsigned SizeInBits, unsigned OffsetInBits = 0); + /// Emit a shift-right dwarf expression. + void AddShr(unsigned ShiftBy); + + /// \brief Emit a partial DWARF register operation. + /// \param MLoc the register + /// \param PieceSize size and + /// \param PieceOffset offset of the piece in bits, if this is one + /// piece of an aggregate value. + /// + /// If size and offset is zero an operation for the entire + /// register is emitted: Some targets do not provide a DWARF + /// register number for every register. If this is the case, this + /// function will attempt to emit a DWARF register by emitting a + /// piece of a super-register or by piecing together multiple + /// subregisters that alias the register. + void AddMachineRegPiece(unsigned MachineReg, + unsigned PieceSizeInBits = 0, + unsigned PieceOffsetInBits = 0); +}; + +} + +#endif |