LLVM  14.0.0git
DwarfExpression.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/DwarfExpression.h - Dwarf Compile Unit ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for writing dwarf compile unit.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
15 
16 #include "ByteStreamer.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/None.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/ADT/SmallVector.h"
22 #include <cassert>
23 #include <cstdint>
24 #include <iterator>
25 
26 namespace llvm {
27 
28 class AsmPrinter;
29 class APInt;
30 class DwarfCompileUnit;
31 class DIELoc;
32 class TargetRegisterInfo;
33 class MachineLocation;
34 
35 /// Holds a DIExpression and keeps track of how many operands have been consumed
36 /// so far.
39 
40 public:
42  if (!Expr) {
43  assert(Start == End);
44  return;
45  }
46  Start = Expr->expr_op_begin();
47  End = Expr->expr_op_end();
48  }
49 
51  : Start(Expr.begin()), End(Expr.end()) {}
52 
53  DIExpressionCursor(const DIExpressionCursor &) = default;
54 
55  /// Consume one operation.
57  if (Start == End)
58  return None;
59  return *(Start++);
60  }
61 
62  /// Consume N operations.
63  void consume(unsigned N) { std::advance(Start, N); }
64 
65  /// Return the current operation.
67  if (Start == End)
68  return None;
69  return *(Start);
70  }
71 
72  /// Return the next operation.
74  if (Start == End)
75  return None;
76 
77  auto Next = Start.getNext();
78  if (Next == End)
79  return None;
80 
81  return *Next;
82  }
83 
84  /// Determine whether there are any operations left in this expression.
85  operator bool() const { return Start != End; }
86 
87  DIExpression::expr_op_iterator begin() const { return Start; }
88  DIExpression::expr_op_iterator end() const { return End; }
89 
90  /// Retrieve the fragment information, if any.
92  return DIExpression::getFragmentInfo(Start, End);
93  }
94 };
95 
96 /// Base class containing the logic for constructing DWARF expressions
97 /// independently of whether they are emitted into a DIE or into a .debug_loc
98 /// entry.
99 ///
100 /// Some DWARF operations, e.g. DW_OP_entry_value, need to calculate the size
101 /// of a succeeding DWARF block before the latter is emitted to the output.
102 /// To handle such cases, data can conditionally be emitted to a temporary
103 /// buffer, which can later on be committed to the main output. The size of the
104 /// temporary buffer is queryable, allowing for the size of the data to be
105 /// emitted before the data is committed.
107 protected:
108  /// Holds information about all subregisters comprising a register location.
109  struct Register {
111  unsigned SubRegSize;
112  const char *Comment;
113 
114  /// Create a full register, no extra DW_OP_piece operators necessary.
115  static Register createRegister(int RegNo, const char *Comment) {
116  return {RegNo, 0, Comment};
117  }
118 
119  /// Create a subregister that needs a DW_OP_piece operator with SizeInBits.
120  static Register createSubRegister(int RegNo, unsigned SizeInBits,
121  const char *Comment) {
122  return {RegNo, SizeInBits, Comment};
123  }
124 
125  bool isSubRegister() const { return SubRegSize; }
126  };
127 
128  /// Whether we are currently emitting an entry value operation.
129  bool IsEmittingEntryValue = false;
130 
132 
133  /// The register location, if any.
135 
136  /// Current Fragment Offset in Bits.
138 
139  /// Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
140  unsigned SubRegisterSizeInBits : 16;
141  unsigned SubRegisterOffsetInBits : 16;
142 
143  /// The kind of location description being produced.
144  enum { Unknown = 0, Register, Memory, Implicit };
145 
146  /// Additional location flags which may be combined with any location kind.
147  /// Currently, entry values are not supported for the Memory location kind.
148  enum { EntryValue = 1 << 0, Indirect = 1 << 1, CallSiteParamValue = 1 << 2 };
149 
150  unsigned LocationKind : 3;
151  unsigned SavedLocationKind : 3;
152  unsigned LocationFlags : 3;
153  unsigned DwarfVersion : 4;
154 
155 public:
156  /// Set the location (\p Loc) and \ref DIExpression (\p DIExpr) to describe.
157  void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr);
158 
159  bool isUnknownLocation() const { return LocationKind == Unknown; }
160 
161  bool isMemoryLocation() const { return LocationKind == Memory; }
162 
163  bool isRegisterLocation() const { return LocationKind == Register; }
164 
165  bool isImplicitLocation() const { return LocationKind == Implicit; }
166 
167  bool isEntryValue() const { return LocationFlags & EntryValue; }
168 
169  bool isIndirect() const { return LocationFlags & Indirect; }
170 
172 
174 
175 protected:
176  /// Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed
177  /// to represent a subregister.
178  void setSubRegisterPiece(unsigned SizeInBits, unsigned OffsetInBits) {
179  assert(SizeInBits < 65536 && OffsetInBits < 65536);
180  SubRegisterSizeInBits = SizeInBits;
182  }
183 
184  /// Add masking operations to stencil out a subregister.
185  void maskSubRegister();
186 
187  /// Output a dwarf operand and an optional assembler comment.
188  virtual void emitOp(uint8_t Op, const char *Comment = nullptr) = 0;
189 
190  /// Emit a raw signed value.
191  virtual void emitSigned(int64_t Value) = 0;
192 
193  /// Emit a raw unsigned value.
194  virtual void emitUnsigned(uint64_t Value) = 0;
195 
196  virtual void emitData1(uint8_t Value) = 0;
197 
198  virtual void emitBaseTypeRef(uint64_t Idx) = 0;
199 
200  /// Start emitting data to the temporary buffer. The data stored in the
201  /// temporary buffer can be committed to the main output using
202  /// commitTemporaryBuffer().
203  virtual void enableTemporaryBuffer() = 0;
204 
205  /// Disable emission to the temporary buffer. This does not commit data
206  /// in the temporary buffer to the main output.
207  virtual void disableTemporaryBuffer() = 0;
208 
209  /// Return the emitted size, in number of bytes, for the data stored in the
210  /// temporary buffer.
211  virtual unsigned getTemporaryBufferSize() = 0;
212 
213  /// Commit the data stored in the temporary buffer to the main output.
214  virtual void commitTemporaryBuffer() = 0;
215 
216  /// Emit a normalized unsigned constant.
217  void emitConstu(uint64_t Value);
218 
219  /// Return whether the given machine register is the frame register in the
220  /// current function.
221  virtual bool isFrameRegister(const TargetRegisterInfo &TRI,
222  llvm::Register MachineReg) = 0;
223 
224  /// Emit a DW_OP_reg operation. Note that this is only legal inside a DWARF
225  /// register location description.
226  void addReg(int DwarfReg, const char *Comment = nullptr);
227 
228  /// Emit a DW_OP_breg operation.
229  void addBReg(int DwarfReg, int Offset);
230 
231  /// Emit DW_OP_fbreg <Offset>.
232  void addFBReg(int Offset);
233 
234  /// Emit a partial DWARF register operation.
235  ///
236  /// \param MachineReg The register number.
237  /// \param MaxSize If the register must be composed from
238  /// sub-registers this is an upper bound
239  /// for how many bits the emitted DW_OP_piece
240  /// may cover.
241  ///
242  /// If size and offset is zero an operation for the entire register is
243  /// emitted: Some targets do not provide a DWARF register number for every
244  /// register. If this is the case, this function will attempt to emit a DWARF
245  /// register by emitting a fragment of a super-register or by piecing together
246  /// multiple subregisters that alias the register.
247  ///
248  /// \return false if no DWARF register exists for MachineReg.
249  bool addMachineReg(const TargetRegisterInfo &TRI, llvm::Register MachineReg,
250  unsigned MaxSize = ~1U);
251 
252  /// Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.
253  /// \param OffsetInBits This is an optional offset into the location that
254  /// is at the top of the DWARF stack.
255  void addOpPiece(unsigned SizeInBits, unsigned OffsetInBits = 0);
256 
257  /// Emit a shift-right dwarf operation.
258  void addShr(unsigned ShiftBy);
259 
260  /// Emit a bitwise and dwarf operation.
261  void addAnd(unsigned Mask);
262 
263  /// Emit a DW_OP_stack_value, if supported.
264  ///
265  /// The proper way to describe a constant value is DW_OP_constu <const>,
266  /// DW_OP_stack_value. Unfortunately, DW_OP_stack_value was not available
267  /// until DWARF 4, so we will continue to generate DW_OP_constu <const> for
268  /// DWARF 2 and DWARF 3. Technically, this is incorrect since DW_OP_const
269  /// <const> actually describes a value at a constant address, not a constant
270  /// value. However, in the past there was no better way to describe a
271  /// constant value, so the producers and consumers started to rely on
272  /// heuristics to disambiguate the value vs. location status of the
273  /// expression. See PR21176 for more details.
274  void addStackValue();
275 
276  /// Finalize an entry value by emitting its size operand, and committing the
277  /// DWARF block which has been emitted to the temporary buffer.
278  void finalizeEntryValue();
279 
280  /// Cancel the emission of an entry value.
281  void cancelEntryValue();
282 
283  ~DwarfExpression() = default;
284 
285 public:
290 
291  /// This needs to be called last to commit any pending changes.
292  void finalize();
293 
294  /// Emit a signed constant.
295  void addSignedConstant(int64_t Value);
296 
297  /// Emit an unsigned constant.
299 
300  /// Emit an unsigned constant.
301  void addUnsignedConstant(const APInt &Value);
302 
303  /// Emit an floating point constant.
304  void addConstantFP(const APFloat &Value, const AsmPrinter &AP);
305 
306  /// Lock this down to become a memory location description.
310  }
311 
312  /// Lock this down to become an entry value location.
313  void setEntryValueFlags(const MachineLocation &Loc);
314 
315  /// Lock this down to become a call site parameter location.
317 
318  /// Emit a machine register location. As an optimization this may also consume
319  /// the prefix of a DwarfExpression if a more efficient representation for
320  /// combining the register location and the first operation exists.
321  ///
322  /// \param FragmentOffsetInBits If this is one fragment out of a
323  /// fragmented
324  /// location, this is the offset of the
325  /// fragment inside the entire variable.
326  /// \return false if no DWARF register exists
327  /// for MachineReg.
329  DIExpressionCursor &Expr,
330  llvm::Register MachineReg,
331  unsigned FragmentOffsetInBits = 0);
332 
333  /// Begin emission of an entry value dwarf operation. The entry value's
334  /// first operand is the size of the DWARF block (its second operand),
335  /// which needs to be calculated at time of emission, so we don't emit
336  /// any operands here.
338 
339  /// Return the index of a base type with the given properties and
340  /// create one if necessary.
341  unsigned getOrCreateBaseType(unsigned BitSize, dwarf::TypeKind Encoding);
342 
343  /// Emit all remaining operations in the DIExpressionCursor.
344  ///
345  /// \param FragmentOffsetInBits If this is one fragment out of multiple
346  /// locations, this is the offset of the
347  /// fragment inside the entire variable.
348  void addExpression(DIExpressionCursor &&Expr,
349  unsigned FragmentOffsetInBits = 0);
350  void
352  llvm::function_ref<bool(unsigned, DIExpressionCursor &)> InsertArg);
353 
354  /// If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to
355  /// the fragment described by \c Expr.
356  void addFragmentOffset(const DIExpression *Expr);
357 
358  void emitLegacySExt(unsigned FromBits);
359  void emitLegacyZExt(unsigned FromBits);
360 
361  /// Emit location information expressed via WebAssembly location + offset
362  /// The Index is an identifier for locals, globals or operand stack.
363  void addWasmLocation(unsigned Index, uint64_t Offset);
364 };
365 
366 /// DwarfExpression implementation for .debug_loc entries.
368 
369  struct TempBuffer {
370  SmallString<32> Bytes;
371  std::vector<std::string> Comments;
373 
374  TempBuffer(bool GenerateComments) : BS(Bytes, Comments, GenerateComments) {}
375  };
376 
377  std::unique_ptr<TempBuffer> TmpBuf;
378  BufferByteStreamer &OutBS;
379  bool IsBuffering = false;
380 
381  /// Return the byte streamer that currently is being emitted to.
382  ByteStreamer &getActiveStreamer() { return IsBuffering ? TmpBuf->BS : OutBS; }
383 
384  void emitOp(uint8_t Op, const char *Comment = nullptr) override;
385  void emitSigned(int64_t Value) override;
386  void emitUnsigned(uint64_t Value) override;
387  void emitData1(uint8_t Value) override;
388  void emitBaseTypeRef(uint64_t Idx) override;
389 
390  void enableTemporaryBuffer() override;
391  void disableTemporaryBuffer() override;
392  unsigned getTemporaryBufferSize() override;
393  void commitTemporaryBuffer() override;
394 
395  bool isFrameRegister(const TargetRegisterInfo &TRI,
396  llvm::Register MachineReg) override;
397 
398 public:
401  : DwarfExpression(DwarfVersion, CU), OutBS(BS) {}
402 };
403 
404 /// DwarfExpression implementation for singular DW_AT_location.
405 class DIEDwarfExpression final : public DwarfExpression {
406  const AsmPrinter &AP;
407  DIELoc &OutDIE;
408  DIELoc TmpDIE;
409  bool IsBuffering = false;
410 
411  /// Return the DIE that currently is being emitted to.
412  DIELoc &getActiveDIE() { return IsBuffering ? TmpDIE : OutDIE; }
413 
414  void emitOp(uint8_t Op, const char *Comment = nullptr) override;
415  void emitSigned(int64_t Value) override;
416  void emitUnsigned(uint64_t Value) override;
417  void emitData1(uint8_t Value) override;
418  void emitBaseTypeRef(uint64_t Idx) override;
419 
420  void enableTemporaryBuffer() override;
421  void disableTemporaryBuffer() override;
422  unsigned getTemporaryBufferSize() override;
423  void commitTemporaryBuffer() override;
424 
425  bool isFrameRegister(const TargetRegisterInfo &TRI,
426  llvm::Register MachineReg) override;
427 
428 public:
430 
433  return &OutDIE;
434  }
435 };
436 
437 } // end namespace llvm
438 
439 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
llvm::DwarfExpression::SubRegisterSizeInBits
unsigned SubRegisterSizeInBits
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
Definition: DwarfExpression.h:140
llvm::MachineLocation
Definition: MachineLocation.h:22
llvm::DwarfExpression::addFBReg
void addFBReg(int Offset)
Emit DW_OP_fbreg <Offset>.
Definition: DwarfExpression.cpp:67
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::DwarfExpression::addUnsignedConstant
void addUnsignedConstant(uint64_t Value)
Emit an unsigned constant.
Definition: DwarfExpression.cpp:197
llvm::DwarfExpression::emitConstu
void emitConstu(uint64_t Value)
Emit a normalized unsigned constant.
Definition: DwarfExpression.cpp:28
llvm::DwarfExpression::Memory
@ Memory
Definition: DwarfExpression.h:144
Optional.h
llvm::DwarfExpression::Register::Comment
const char * Comment
Definition: DwarfExpression.h:112
DebugInfoMetadata.h
llvm::DwarfExpression::addShr
void addShr(unsigned ShiftBy)
Emit a shift-right dwarf operation.
Definition: DwarfExpression.cpp:89
llvm::DwarfExpression::enableTemporaryBuffer
virtual void enableTemporaryBuffer()=0
Start emitting data to the temporary buffer.
llvm::DwarfCompileUnit
Definition: DwarfCompileUnit.h:47
llvm::DwarfExpression::emitSigned
virtual void emitSigned(int64_t Value)=0
Emit a raw signed value.
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::DwarfExpression::TagOffset
Optional< uint8_t > TagOffset
Definition: DwarfExpression.h:173
llvm::DwarfExpression::Register
Holds information about all subregisters comprising a register location.
Definition: DwarfExpression.h:109
llvm::DwarfExpression::DwarfRegs
SmallVector< Register, 2 > DwarfRegs
The register location, if any.
Definition: DwarfExpression.h:134
llvm::Optional
Definition: APInt.h:33
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::DIE
A structured debug information entry.
Definition: DIE.h:739
llvm::DIExpressionCursor::getFragmentInfo
Optional< DIExpression::FragmentInfo > getFragmentInfo() const
Retrieve the fragment information, if any.
Definition: DwarfExpression.h:91
llvm::DwarfExpression::DwarfVersion
unsigned DwarfVersion
Definition: DwarfExpression.h:153
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2586
llvm::DIExpressionCursor::begin
DIExpression::expr_op_iterator begin() const
Definition: DwarfExpression.h:87
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::DwarfExpression::setLocation
void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)
Set the location (Loc) and DIExpression (DIExpr) to describe.
Definition: DwarfExpression.cpp:380
llvm::DwarfExpression::finalizeEntryValue
void finalizeEntryValue()
Finalize an entry value by emitting its size operand, and committing the DWARF block which has been e...
Definition: DwarfExpression.cpp:404
llvm::DwarfExpression::LocationKind
unsigned LocationKind
Definition: DwarfExpression.h:150
llvm::DwarfExpression::Register::SubRegSize
unsigned SubRegSize
Definition: DwarfExpression.h:111
llvm::DwarfExpression::isMemoryLocation
bool isMemoryLocation() const
Definition: DwarfExpression.h:161
llvm::DwarfExpression::setCallSiteParamValueFlag
void setCallSiteParamValueFlag()
Lock this down to become a call site parameter location.
Definition: DwarfExpression.h:316
llvm::DwarfExpression::Implicit
@ Implicit
Definition: DwarfExpression.h:144
llvm::DwarfExpression
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
Definition: DwarfExpression.h:106
llvm::DwarfExpression::isImplicitLocation
bool isImplicitLocation() const
Definition: DwarfExpression.h:165
llvm::DwarfExpression::commitTemporaryBuffer
virtual void commitTemporaryBuffer()=0
Commit the data stored in the temporary buffer to the main output.
llvm::DwarfExpression::setSubRegisterPiece
void setSubRegisterPiece(unsigned SizeInBits, unsigned OffsetInBits)
Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed to represent a subregister.
Definition: DwarfExpression.h:178
llvm::DIEDwarfExpression::finalize
DIELoc * finalize()
Definition: DwarfExpression.h:431
llvm::DwarfExpression::isFrameRegister
virtual bool isFrameRegister(const TargetRegisterInfo &TRI, llvm::Register MachineReg)=0
Return whether the given machine register is the frame register in the current function.
llvm::DwarfExpression::emitData1
virtual void emitData1(uint8_t Value)=0
llvm::DwarfExpression::setEntryValueFlags
void setEntryValueFlags(const MachineLocation &Loc)
Lock this down to become an entry value location.
Definition: DwarfExpression.cpp:374
llvm::DwarfExpression::getOrCreateBaseType
unsigned getOrCreateBaseType(unsigned BitSize, dwarf::TypeKind Encoding)
Return the index of a base type with the given properties and create one if necessary.
Definition: DwarfExpression.cpp:435
llvm::DwarfExpression::addConstantFP
void addConstantFP(const APFloat &Value, const AsmPrinter &AP)
Emit an floating point constant.
Definition: DwarfExpression.cpp:223
llvm::DwarfExpression::emitLegacySExt
void emitLegacySExt(unsigned FromBits)
Definition: DwarfExpression.cpp:667
llvm::DwarfExpression::finalize
void finalize()
This needs to be called last to commit any pending changes.
Definition: DwarfExpression.cpp:644
llvm::DwarfExpression::OffsetInBits
uint64_t OffsetInBits
Current Fragment Offset in Bits.
Definition: DwarfExpression.h:137
llvm::DIExpressionCursor::consume
void consume(unsigned N)
Consume N operations.
Definition: DwarfExpression.h:63
llvm::DwarfExpression::setMemoryLocationKind
void setMemoryLocationKind()
Lock this down to become a memory location description.
Definition: DwarfExpression.h:307
llvm::DwarfExpression::addMachineRegExpression
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
Definition: DwarfExpression.cpp:250
llvm::DwarfExpression::addWasmLocation
void addWasmLocation(unsigned Index, uint64_t Offset)
Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...
Definition: DwarfExpression.cpp:689
llvm::DwarfExpression::cancelEntryValue
void cancelEntryValue()
Cancel the emission of an entry value.
Definition: DwarfExpression.cpp:422
llvm::None
const NoneType None
Definition: None.h:23
llvm::SmallString< 32 >
llvm::DwarfExpression::SavedLocationKind
unsigned SavedLocationKind
Definition: DwarfExpression.h:151
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::DwarfExpression::Register
@ Register
Definition: DwarfExpression.h:144
llvm::DwarfExpression::LocationFlags
unsigned LocationFlags
Definition: DwarfExpression.h:152
llvm::DwarfExpression::emitBaseTypeRef
virtual void emitBaseTypeRef(uint64_t Idx)=0
llvm::APFloat
Definition: APFloat.h:701
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::DwarfExpression::emitUnsigned
virtual void emitUnsigned(uint64_t Value)=0
Emit a raw unsigned value.
uint64_t
llvm::DwarfExpression::maskSubRegister
void maskSubRegister()
Add masking operations to stencil out a subregister.
Definition: DwarfExpression.cpp:636
llvm::DwarfExpression::disableTemporaryBuffer
virtual void disableTemporaryBuffer()=0
Disable emission to the temporary buffer.
llvm::DIEDwarfExpression
DwarfExpression implementation for singular DW_AT_location.
Definition: DwarfExpression.h:405
llvm::DwarfExpression::isIndirect
bool isIndirect() const
Definition: DwarfExpression.h:169
llvm::DwarfExpression::beginEntryValueExpression
void beginEntryValueExpression(DIExpressionCursor &ExprCursor)
Begin emission of an entry value dwarf operation.
Definition: DwarfExpression.cpp:389
llvm::DIExpressionCursor::end
DIExpression::expr_op_iterator end() const
Definition: DwarfExpression.h:88
llvm::DIELoc
DIELoc - Represents an expression location.
Definition: DIE.h:922
ArrayRef.h
llvm::DwarfExpression::Register::DwarfRegNo
int DwarfRegNo
Definition: DwarfExpression.h:110
llvm::DwarfExpression::EntryValue
@ EntryValue
Definition: DwarfExpression.h:148
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::DwarfExpression::addBReg
void addBReg(int DwarfReg, int Offset)
Emit a DW_OP_breg operation.
Definition: DwarfExpression.cpp:55
llvm::DwarfExpression::addSignedConstant
void addSignedConstant(int64_t Value)
Emit a signed constant.
Definition: DwarfExpression.cpp:190
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
ByteStreamer.h
llvm::DwarfExpression::isUnknownLocation
bool isUnknownLocation() const
Definition: DwarfExpression.h:159
llvm::ArrayRef< uint64_t >
llvm::DwarfExpression::isEntryValue
bool isEntryValue() const
Definition: DwarfExpression.h:167
None.h
llvm::DIEDwarfExpression::DIEDwarfExpression
DIEDwarfExpression(const AsmPrinter &AP, DwarfCompileUnit &CU, DIELoc &DIE)
Definition: DwarfUnit.cpp:48
llvm::DwarfExpression::addMachineReg
bool addMachineReg(const TargetRegisterInfo &TRI, llvm::Register MachineReg, unsigned MaxSize=~1U)
Emit a partial DWARF register operation.
Definition: DwarfExpression.cpp:99
llvm::DwarfExpression::CallSiteParamValue
@ CallSiteParamValue
Definition: DwarfExpression.h:148
llvm::DIExpressionCursor::peekNext
Optional< DIExpression::ExprOperand > peekNext() const
Return the next operation.
Definition: DwarfExpression.h:73
llvm::DwarfExpression::Register::createRegister
static Register createRegister(int RegNo, const char *Comment)
Create a full register, no extra DW_OP_piece operators necessary.
Definition: DwarfExpression.h:115
llvm::DIExpressionCursor::peek
Optional< DIExpression::ExprOperand > peek() const
Return the current operation.
Definition: DwarfExpression.h:66
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::DIExpression::expr_op_iterator
An iterator for expression operands.
Definition: DebugInfoMetadata.h:2674
llvm::DwarfExpression::CU
DwarfCompileUnit & CU
Definition: DwarfExpression.h:131
llvm::dwarf::TypeKind
TypeKind
Definition: Dwarf.h:150
llvm::DwarfExpression::IsEmittingEntryValue
bool IsEmittingEntryValue
Whether we are currently emitting an entry value operation.
Definition: DwarfExpression.h:129
llvm::DwarfExpression::isRegisterLocation
bool isRegisterLocation() const
Definition: DwarfExpression.h:163
llvm::DwarfExpression::addFragmentOffset
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
Definition: DwarfExpression.cpp:655
llvm::DIExpressionCursor::DIExpressionCursor
DIExpressionCursor(const DIExpression *Expr)
Definition: DwarfExpression.h:41
llvm::DIExpressionCursor::DIExpressionCursor
DIExpressionCursor(ArrayRef< uint64_t > Expr)
Definition: DwarfExpression.h:50
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:321
llvm::DwarfExpression::DwarfExpression
DwarfExpression(unsigned DwarfVersion, DwarfCompileUnit &CU)
Definition: DwarfExpression.h:286
llvm::DwarfExpression::emitOp
virtual void emitOp(uint8_t Op, const char *Comment=nullptr)=0
Output a dwarf operand and an optional assembler comment.
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::BufferByteStreamer
Definition: ByteStreamer.h:76
llvm::DwarfExpression::Register::createSubRegister
static Register createSubRegister(int RegNo, unsigned SizeInBits, const char *Comment)
Create a subregister that needs a DW_OP_piece operator with SizeInBits.
Definition: DwarfExpression.h:120
llvm::DwarfExpression::addAnd
void addAnd(unsigned Mask)
Emit a bitwise and dwarf operation.
Definition: DwarfExpression.cpp:94
SmallVector.h
llvm::DebugLocDwarfExpression
DwarfExpression implementation for .debug_loc entries.
Definition: DwarfExpression.h:367
llvm::DIExpressionCursor
Holds a DIExpression and keeps track of how many operands have been consumed so far.
Definition: DwarfExpression.h:37
llvm::DwarfExpression::addExpression
void addExpression(DIExpressionCursor &&Expr, unsigned FragmentOffsetInBits=0)
Emit all remaining operations in the DIExpressionCursor.
Definition: DwarfExpression.cpp:466
N
#define N
llvm::DwarfExpression::emitLegacyZExt
void emitLegacyZExt(unsigned FromBits)
Definition: DwarfExpression.cpp:682
llvm::DwarfExpression::Unknown
@ Unknown
Definition: DwarfExpression.h:144
llvm::DIExpression::expr_op_end
expr_op_iterator expr_op_end() const
Definition: DebugInfoMetadata.h:2730
llvm::DwarfExpression::Register::isSubRegister
bool isSubRegister() const
Definition: DwarfExpression.h:125
llvm::DwarfExpression::~DwarfExpression
~DwarfExpression()=default
llvm::ByteStreamer
Definition: ByteStreamer.h:24
CU
Definition: AArch64AsmBackend.cpp:501
llvm::DebugLocDwarfExpression::DebugLocDwarfExpression
DebugLocDwarfExpression(unsigned DwarfVersion, BufferByteStreamer &BS, DwarfCompileUnit &CU)
Definition: DwarfExpression.h:399
llvm::DwarfExpression::isParameterValue
bool isParameterValue()
Definition: DwarfExpression.h:171
llvm::DwarfExpression::Indirect
@ Indirect
Definition: DwarfExpression.h:148
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::DwarfExpression::addOpPiece
void addOpPiece(unsigned SizeInBits, unsigned OffsetInBits=0)
Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.
Definition: DwarfExpression.cpp:72
llvm::DwarfExpression::addStackValue
void addStackValue()
Emit a DW_OP_stack_value, if supported.
Definition: DwarfExpression.cpp:185
llvm::DwarfExpression::addReg
void addReg(int DwarfReg, const char *Comment=nullptr)
Emit a DW_OP_reg operation.
Definition: DwarfExpression.cpp:42
llvm::DwarfExpression::getTemporaryBufferSize
virtual unsigned getTemporaryBufferSize()=0
Return the emitted size, in number of bytes, for the data stored in the temporary buffer.
llvm::DIExpressionCursor::take
Optional< DIExpression::ExprOperand > take()
Consume one operation.
Definition: DwarfExpression.h:56
llvm::DIExpression::getFragmentInfo
Optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
Definition: DebugInfoMetadata.h:2760
llvm::DwarfExpression::SubRegisterOffsetInBits
unsigned SubRegisterOffsetInBits
Definition: DwarfExpression.h:141
llvm::DIExpression::expr_op_begin
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
Definition: DebugInfoMetadata.h:2727