blob: ffee3bc43a26d39f120f87e9b3adfd020f108b04 [file] [log] [blame]
Adrian Prantlb16d9eb2015-01-12 22:19:22 +00001//===-- llvm/CodeGen/DwarfExpression.h - Dwarf Compile Unit ---*- C++ -*--===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains support for writing dwarf compile unit.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
15#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
16
17#include "llvm/Support/DataTypes.h"
18
19namespace llvm {
20
21class TargetMachine;
22
23/// Base class containing the logic for constructing DWARF expressions
24/// independently of whether they are emitted into a DIE or into a .debug_loc
25/// entry.
26class DwarfExpression {
Adrian Prantl00dbc2a2015-01-12 22:19:26 +000027protected:
Adrian Prantlb16d9eb2015-01-12 22:19:22 +000028 TargetMachine &TM;
29public:
30 DwarfExpression(TargetMachine &TM) : TM(TM) {}
31
32 virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0;
33 virtual void EmitSigned(int Value) = 0;
34 virtual void EmitUnsigned(unsigned Value) = 0;
Adrian Prantl00dbc2a2015-01-12 22:19:26 +000035
36 virtual unsigned getFrameRegister() = 0;
37
Adrian Prantlb16d9eb2015-01-12 22:19:22 +000038 /// Emit a dwarf register operation.
39 void AddReg(int DwarfReg, const char* Comment = nullptr);
40 /// Emit an (double-)indirect dwarf register operation.
41 void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false);
42
43 /// Emit a dwarf register operation for describing
44 /// - a small value occupying only part of a register or
45 /// - a register representing only part of a value.
46 void AddOpPiece(unsigned SizeInBits, unsigned OffsetInBits = 0);
47 /// Emit a shift-right dwarf expression.
48 void AddShr(unsigned ShiftBy);
49
Adrian Prantl00dbc2a2015-01-12 22:19:26 +000050 /// Emit an indirect dwarf register operation for the given machine register.
51 /// Returns false if no DWARF register exists for MachineReg.
52 bool AddMachineRegIndirect(unsigned MachineReg, int Offset);
53
Adrian Prantlb16d9eb2015-01-12 22:19:22 +000054 /// \brief Emit a partial DWARF register operation.
55 /// \param MLoc the register
56 /// \param PieceSize size and
57 /// \param PieceOffset offset of the piece in bits, if this is one
58 /// piece of an aggregate value.
59 ///
60 /// If size and offset is zero an operation for the entire
61 /// register is emitted: Some targets do not provide a DWARF
62 /// register number for every register. If this is the case, this
63 /// function will attempt to emit a DWARF register by emitting a
64 /// piece of a super-register or by piecing together multiple
65 /// subregisters that alias the register.
66 void AddMachineRegPiece(unsigned MachineReg,
67 unsigned PieceSizeInBits = 0,
68 unsigned PieceOffsetInBits = 0);
69};
70
71}
72
73#endif