/// Emit a dwarf register operation for describing /// - a small value occupying only part of a register or /// - a small register representing only part of a value. static void emitDwarfOpPiece(ByteStreamer &Streamer, unsigned Size, unsigned Offset) { assert(Size > 0); if (Offset > 0) { Streamer.EmitInt8(dwarf::DW_OP_bit_piece, "DW_OP_bit_piece"); Streamer.EmitULEB128(Size, Twine(Size)); Streamer.EmitULEB128(Offset, Twine(Offset)); } else { Streamer.EmitInt8(dwarf::DW_OP_piece, "DW_OP_piece"); unsigned ByteSize = Size / 8; // Assuming 8 bits per byte. Streamer.EmitULEB128(ByteSize, Twine(ByteSize)); } }
void AsmPrinter::EmitDwarfOpPiece(ByteStreamer &Streamer, unsigned SizeInBits, unsigned OffsetInBits) const { assert(SizeInBits > 0 && "piece has size zero"); const unsigned SizeOfByte = 8; if (OffsetInBits > 0 || SizeInBits % SizeOfByte) { Streamer.EmitInt8(dwarf::DW_OP_bit_piece, "DW_OP_bit_piece"); Streamer.EmitULEB128(SizeInBits, Twine(SizeInBits)); Streamer.EmitULEB128(OffsetInBits, Twine(OffsetInBits)); } else { Streamer.EmitInt8(dwarf::DW_OP_piece, "DW_OP_piece"); unsigned ByteSize = SizeInBits / SizeOfByte; Streamer.EmitULEB128(ByteSize, Twine(ByteSize)); } }
/// Emit a dwarf register operation. static void emitDwarfRegOp(ByteStreamer &Streamer, int Reg) { assert(Reg >= 0); if (Reg < 32) { Streamer.EmitInt8(dwarf::DW_OP_reg0 + Reg, dwarf::OperationEncodingString(dwarf::DW_OP_reg0 + Reg)); } else { Streamer.EmitInt8(dwarf::DW_OP_regx, "DW_OP_regx"); Streamer.EmitULEB128(Reg, Twine(Reg)); } }
/// Emit an (double-)indirect dwarf register operation. static void emitDwarfRegOpIndirect(ByteStreamer &Streamer, int Reg, int Offset, bool Deref) { assert(Reg >= 0); if (Reg < 32) { Streamer.EmitInt8(dwarf::DW_OP_breg0 + Reg, dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg)); } else { Streamer.EmitInt8(dwarf::DW_OP_bregx, "DW_OP_bregx"); Streamer.EmitULEB128(Reg, Twine(Reg)); } Streamer.EmitSLEB128(Offset); if (Deref) Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref"); }
/// Emit a shift-right dwarf expression. static void emitDwarfOpShr(ByteStreamer &Streamer, unsigned ShiftBy) { Streamer.EmitInt8(dwarf::DW_OP_constu, "DW_OP_constu"); Streamer.EmitULEB128(ShiftBy); Streamer.EmitInt8(dwarf::DW_OP_shr, "DW_OP_shr"); }