13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H 14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H 30 class DwarfCompileUnit;
32 class TargetRegisterInfo;
50 : Start(Expr.
begin()), End(Expr.
end()) {}
62 void consume(
unsigned N) { std::advance(Start, N); }
84 operator bool()
const {
return Start != End; }
115 bool IsEmittingEntryValue =
false;
123 uint64_t OffsetInBits = 0;
133 enum { EntryValue = 1, CallSiteParamValue };
141 return LocationKind ==
Unknown;
145 return LocationKind ==
Memory;
157 return LocationFlags & EntryValue;
161 return LocationFlags & CallSiteParamValue;
170 assert(SizeInBits < 65536 && OffsetInBits < 65536);
171 SubRegisterSizeInBits = SizeInBits;
172 SubRegisterOffsetInBits = OffsetInBits;
176 void maskSubRegister();
179 virtual void emitOp(uint8_t
Op,
const char *Comment =
nullptr) = 0;
182 virtual void emitSigned(int64_t
Value) = 0;
185 virtual void emitUnsigned(uint64_t Value) = 0;
187 virtual void emitData1(uint8_t Value) = 0;
189 virtual void emitBaseTypeRef(uint64_t Idx) = 0;
194 virtual void enableTemporaryBuffer() = 0;
198 virtual void disableTemporaryBuffer() = 0;
202 virtual unsigned getTemporaryBufferSize() = 0;
205 virtual void commitTemporaryBuffer() = 0;
208 void emitConstu(uint64_t Value);
216 void addReg(
int DwarfReg,
const char *Comment =
nullptr);
219 void addBReg(
int DwarfReg,
int Offset);
222 void addFBReg(
int Offset);
240 unsigned MaxSize = ~1U);
245 void addOpPiece(
unsigned SizeInBits,
unsigned OffsetInBits = 0);
248 void addShr(
unsigned ShiftBy);
251 void addAnd(
unsigned Mask);
264 void addStackValue();
268 void finalizeEntryValue();
274 : CU(CU), SubRegisterSizeInBits(0), SubRegisterOffsetInBits(0),
276 DwarfVersion(DwarfVersion) {}
282 void addSignedConstant(int64_t Value);
285 void addUnsignedConstant(uint64_t Value);
288 void addUnsignedConstant(
const APInt &Value);
292 assert(isUnknownLocation());
298 LocationFlags |= EntryValue;
303 LocationFlags |= CallSiteParamValue;
318 unsigned FragmentOffsetInBits = 0);
332 unsigned FragmentOffsetInBits = 0);
338 void emitLegacySExt(
unsigned FromBits);
339 void emitLegacyZExt(
unsigned FromBits);
343 void addWasmLocation(
unsigned Index, int64_t Offset);
351 std::vector<std::string> Comments;
354 TempBuffer(
bool GenerateComments) : BS(Bytes, Comments, GenerateComments) {}
357 std::unique_ptr<TempBuffer> TmpBuf;
359 bool IsBuffering =
false;
362 ByteStreamer &getActiveStreamer() {
return IsBuffering ? TmpBuf->BS : OutBS; }
364 void emitOp(uint8_t
Op,
const char *Comment =
nullptr)
override;
365 void emitSigned(int64_t
Value)
override;
366 void emitUnsigned(uint64_t Value)
override;
367 void emitData1(uint8_t Value)
override;
368 void emitBaseTypeRef(uint64_t Idx)
override;
370 void enableTemporaryBuffer()
override;
371 void disableTemporaryBuffer()
override;
372 unsigned getTemporaryBufferSize()
override;
373 void commitTemporaryBuffer()
override;
376 unsigned MachineReg)
override;
388 bool IsBuffering =
false;
391 DIELoc &getActiveDIE() {
return IsBuffering ? TmpDIE : OutDIE; }
393 void emitOp(uint8_t
Op,
const char *Comment =
nullptr)
override;
394 void emitSigned(int64_t
Value)
override;
395 void emitUnsigned(uint64_t Value)
override;
396 void emitData1(uint8_t Value)
override;
397 void emitBaseTypeRef(uint64_t Idx)
override;
399 void enableTemporaryBuffer()
override;
400 void disableTemporaryBuffer()
override;
401 unsigned getTemporaryBufferSize()
override;
402 void commitTemporaryBuffer()
override;
405 unsigned MachineReg)
override;
417 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H DebugLocDwarfExpression(unsigned DwarfVersion, BufferByteStreamer &BS, DwarfCompileUnit &CU)
DIELoc - Represents an expression location.
This class represents lattice values for constants.
void setMemoryLocationKind()
Lock this down to become a memory location description.
This class provides various memory handling functions that manipulate MemoryBlock instances...
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
unsigned const TargetRegisterInfo * TRI
DwarfExpression(unsigned DwarfVersion, DwarfCompileUnit &CU)
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
void setCallSiteParamValueFlag()
Lock this down to become a call site parameter location.
Holds a DIExpression and keeps track of how many operands have been consumed so far.
DwarfExpression implementation for .debug_loc entries.
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...
expr_op_iterator expr_op_end() const
Optional< DIExpression::ExprOperand > peek() const
Return the current operation.
bool isImplicitLocation() const
bool isEntryValue() const
Optional< DIExpression::ExprOperand > peekNext() const
Return the next operation.
Optional< DIExpression::ExprOperand > take()
Consume one operation.
DIExpressionCursor(const DIExpression *Expr)
A structured debug information entry.
void setEntryValueFlag()
Lock this down to become an entry value location.
This class is intended to be used as a driving class for all asm writers.
Optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
bool isMemoryLocation() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned SubRegisterOffsetInBits
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isUnknownLocation() const
Promote Memory to Register
Class for arbitrary precision integers.
Optional< DIExpression::FragmentInfo > getFragmentInfo() const
Retrieve the fragment information, if any.
Optional< uint8_t > TagOffset
unsigned SubRegisterSizeInBits
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
void consume(unsigned N)
Consume N operations.
DIExpression::expr_op_iterator begin() const
void finalize()
This needs to be called last to commit any pending changes.
DIExpressionCursor(ArrayRef< uint64_t > Expr)
DwarfExpression implementation for singular DW_AT_location.
Holds information about all subregisters comprising a register location.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
expr_op_iterator getNext() const
Get the next iterator.
An iterator for expression operands.
SmallVector< Register, 2 > DwarfRegs
The register location, if any.
DIExpression::expr_op_iterator end() const
bool isRegisterLocation() const