29 emitOp(dwarf::DW_OP_lit0 + Value);
36 emitOp(dwarf::DW_OP_constu);
42 assert(DwarfReg >= 0 &&
"invalid negative dwarf register number");
44 "location description already locked down");
47 emitOp(dwarf::DW_OP_reg0 + DwarfReg, Comment);
49 emitOp(dwarf::DW_OP_regx, Comment);
55 assert(DwarfReg >= 0 &&
"invalid negative dwarf register number");
58 emitOp(dwarf::DW_OP_breg0 + DwarfReg);
60 emitOp(dwarf::DW_OP_bregx);
67 emitOp(dwarf::DW_OP_fbreg);
75 const unsigned SizeOfByte = 8;
76 if (OffsetInBits > 0 || SizeInBits % SizeOfByte) {
77 emitOp(dwarf::DW_OP_bit_piece);
81 emitOp(dwarf::DW_OP_piece);
82 unsigned ByteSize = SizeInBits / SizeOfByte;
85 this->OffsetInBits += SizeInBits;
99 unsigned MachineReg,
unsigned MaxSize) {
154 CurSubReg.
set(Offset, Offset + Size);
158 if (CurSubReg.
test(Coverage)) {
161 DwarfRegs.push_back({-1, Offset - CurPos,
"no DWARF register encoding"});
163 {
Reg, std::min<unsigned>(
Size, MaxSize -
Offset),
"sub-register"});
164 if (Offset >= MaxSize)
168 Coverage.
set(Offset, Offset + Size);
169 CurPos = Offset +
Size;
176 if (CurPos < RegSize)
177 DwarfRegs.push_back({-1, RegSize - CurPos,
"no DWARF register encoding"});
183 emitOp(dwarf::DW_OP_stack_value);
189 emitOp(dwarf::DW_OP_consts);
209 while (Offset < Size) {
211 if (Offset == 0 && Size <= 64)
214 addOpPiece(std::min(Size - Offset, 64u), Offset);
222 unsigned FragmentOffsetInBits) {
224 if (!
addMachineReg(TRI, MachineReg, Fragment ? Fragment->SizeInBits : ~1U)) {
229 bool HasComplexExpression =
false;
230 auto Op = ExprCursor.
peek();
232 HasComplexExpression =
true;
238 if (HasComplexExpression &&
DwarfRegs.size() > 1) {
247 if (
Reg.DwarfRegNo >= 0)
258 return Op.
getOp() == dwarf::DW_OP_stack_value;
268 int SignedOffset = 0;
269 assert(Reg.Size == 0 &&
"subregister has same size as superregister");
273 if (Op && (Op->
getOp() == dwarf::DW_OP_plus_uconst)) {
274 SignedOffset = Op->
getArg(0);
281 if (Op && Op->
getOp() == dwarf::DW_OP_constu) {
283 if (
N && (
N->getOp() == dwarf::DW_OP_plus ||
286 SignedOffset = (
N->getOp() == dwarf::DW_OP_minus) ? -Offset : Offset;
294 addBReg(Reg.DwarfRegNo, SignedOffset);
302 auto Op = ExprCursor.
take();
303 switch (
Op->getOp()) {
304 case dwarf::DW_OP_deref:
315 unsigned FragmentOffsetInBits) {
318 auto N = ExprCursor.peek();
323 auto Op = ExprCursor.take();
324 switch (
Op->getOp()) {
326 unsigned SizeInBits =
Op->getArg(1);
327 unsigned FragmentOffset =
Op->getArg(0);
354 case dwarf::DW_OP_plus_uconst:
356 emitOp(dwarf::DW_OP_plus_uconst);
359 case dwarf::DW_OP_plus:
360 case dwarf::DW_OP_minus:
361 case dwarf::DW_OP_mul:
362 case dwarf::DW_OP_div:
363 case dwarf::DW_OP_mod:
364 case dwarf::DW_OP_or:
365 case dwarf::DW_OP_and:
366 case dwarf::DW_OP_xor:
367 case dwarf::DW_OP_shl:
368 case dwarf::DW_OP_shr:
369 case dwarf::DW_OP_shra:
370 case dwarf::DW_OP_lit0:
371 case dwarf::DW_OP_not:
372 case dwarf::DW_OP_dup:
375 case dwarf::DW_OP_deref:
382 emitOp(dwarf::DW_OP_deref);
384 case dwarf::DW_OP_constu:
388 case dwarf::DW_OP_stack_value:
391 case dwarf::DW_OP_swap:
393 emitOp(dwarf::DW_OP_swap);
395 case dwarf::DW_OP_xderef:
397 emitOp(dwarf::DW_OP_xderef);
435 "overlapping or duplicate fragments");
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
void addShr(unsigned ShiftBy)
Emit a shift-right dwarf operation.
This class represents lattice values for constants.
void addUnsignedConstant(uint64_t Value)
Emit an unsigned constant.
void emitConstu(uint64_t Value)
Emit a normalized unsigned constant.
This class provides various memory handling functions that manipulate MemoryBlock instances...
unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const
For a given register pair, return the sub-register index if the second register is a sub-register of ...
unsigned const TargetRegisterInfo * TRI
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool test(unsigned Idx) const
MCSuperRegIterator enumerates all super-registers of Reg.
void addBReg(int DwarfReg, int Offset)
Emit a DW_OP_breg operation.
void addFBReg(int Offset)
Emit DW_OP_fbreg <Offset>.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
Only used in LLVM metadata.
Holds a DIExpression and keeps track of how many operands have been consumed so far.
This file implements a class to represent arbitrary precision integral constant values and operations...
void addReg(int DwarfReg, const char *Comment=nullptr)
Emit a DW_OP_reg operation.
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...
Optional< DIExpression::ExprOperand > peek() const
Return the current operation.
static Optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
void maskSubRegister()
Add masking operations to stencil out a subregister.
uint64_t getArg(unsigned I) const
Get an argument to the operand.
Optional< DIExpression::ExprOperand > peekNext() const
Return the next operation.
virtual void emitUnsigned(uint64_t Value)=0
Emit a raw unsigned value.
Optional< DIExpression::ExprOperand > take()
Consume one operation.
uint64_t getOp() const
Get the operand code.
virtual void emitOp(uint8_t Op, const char *Comment=nullptr)=0
Output a dwarf operand and an optional assembler comment.
A lightweight wrapper around an expression operand.
uint64_t OffsetInBits
Current Fragment Offset in Bits.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
virtual void emitSigned(int64_t Value)=0
Emit a raw signed value.
bool isMemoryLocation() const
unsigned getSubRegIdxOffset(unsigned Idx) const
Get the offset of the bit range covered by a sub-register index.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned SubRegisterOffsetInBits
void addExpression(DIExpressionCursor &&Expr, unsigned FragmentOffsetInBits=0)
Emit all remaining operations in the DIExpressionCursor.
bool addMachineReg(const TargetRegisterInfo &TRI, unsigned MachineReg, unsigned MaxSize=~1U)
Emit a partial DWARF register operation.
void addStackValue()
Emit a DW_OP_stack_value, if supported.
enum llvm::DwarfExpression::@340 LocationKind
The kind of location description being produced.
This file contains constants used for implementing Dwarf debug support.
Class for arbitrary precision integers.
void addAnd(unsigned Mask)
Emit a bitwise and dwarf operation.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
Optional< DIExpression::FragmentInfo > getFragmentInfo() const
Retrieve the fragment information, if any.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
unsigned SubRegisterSizeInBits
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
void consume(unsigned N)
Consume N operations.
void finalize()
This needs to be called last to commit any pending changes.
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
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...
Holds information about all subregisters comprising a register location.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void addOpPiece(unsigned SizeInBits, unsigned OffsetInBits=0)
Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.
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.
void addSignedConstant(int64_t Value)
Emit a signed constant.
unsigned getSubRegIdxSize(unsigned Idx) const
Get the size of the bit range covered by a sub-register index.
SmallVector< Register, 2 > DwarfRegs
The register location, if any.
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
bool isFragment() const
Return whether this is a piece of an aggregate variable.
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, unsigned MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg)=0
Return whether the given machine register is the frame register in the current function.