xref: /aosp_15_r20/external/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- AsmPrinterDwarf.cpp - AsmPrinter Dwarf Support --------------------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file implements the Dwarf emissions parts of AsmPrinter.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #include "ByteStreamer.h"
15*9880d681SAndroid Build Coastguard Worker #include "DwarfDebug.h"
16*9880d681SAndroid Build Coastguard Worker #include "DwarfExpression.h"
17*9880d681SAndroid Build Coastguard Worker #include "llvm/ADT/Twine.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/AsmPrinter.h"
19*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/DIE.h"
20*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFunction.h"
21*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineModuleInfo.h"
22*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/DataLayout.h"
23*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCAsmInfo.h"
24*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCRegisterInfo.h"
25*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCSection.h"
26*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCStreamer.h"
27*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCSymbol.h"
28*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MachineLocation.h"
29*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/Dwarf.h"
30*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/ErrorHandling.h"
31*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLoweringObjectFile.h"
32*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetMachine.h"
33*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetSubtargetInfo.h"
34*9880d681SAndroid Build Coastguard Worker using namespace llvm;
35*9880d681SAndroid Build Coastguard Worker 
36*9880d681SAndroid Build Coastguard Worker #define DEBUG_TYPE "asm-printer"
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
39*9880d681SAndroid Build Coastguard Worker // Dwarf Emission Helper Routines
40*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker /// EmitSLEB128 - emit the specified signed leb128 value.
EmitSLEB128(int64_t Value,const char * Desc) const43*9880d681SAndroid Build Coastguard Worker void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const {
44*9880d681SAndroid Build Coastguard Worker   if (isVerbose() && Desc)
45*9880d681SAndroid Build Coastguard Worker     OutStreamer->AddComment(Desc);
46*9880d681SAndroid Build Coastguard Worker 
47*9880d681SAndroid Build Coastguard Worker   OutStreamer->EmitSLEB128IntValue(Value);
48*9880d681SAndroid Build Coastguard Worker }
49*9880d681SAndroid Build Coastguard Worker 
50*9880d681SAndroid Build Coastguard Worker /// EmitULEB128 - emit the specified unsigned leb128 value.
EmitULEB128(uint64_t Value,const char * Desc,unsigned PadTo) const51*9880d681SAndroid Build Coastguard Worker void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc,
52*9880d681SAndroid Build Coastguard Worker                              unsigned PadTo) const {
53*9880d681SAndroid Build Coastguard Worker   if (isVerbose() && Desc)
54*9880d681SAndroid Build Coastguard Worker     OutStreamer->AddComment(Desc);
55*9880d681SAndroid Build Coastguard Worker 
56*9880d681SAndroid Build Coastguard Worker   OutStreamer->EmitULEB128IntValue(Value, PadTo);
57*9880d681SAndroid Build Coastguard Worker }
58*9880d681SAndroid Build Coastguard Worker 
DecodeDWARFEncoding(unsigned Encoding)59*9880d681SAndroid Build Coastguard Worker static const char *DecodeDWARFEncoding(unsigned Encoding) {
60*9880d681SAndroid Build Coastguard Worker   switch (Encoding) {
61*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_absptr:
62*9880d681SAndroid Build Coastguard Worker     return "absptr";
63*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_omit:
64*9880d681SAndroid Build Coastguard Worker     return "omit";
65*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_pcrel:
66*9880d681SAndroid Build Coastguard Worker     return "pcrel";
67*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_udata4:
68*9880d681SAndroid Build Coastguard Worker     return "udata4";
69*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_udata8:
70*9880d681SAndroid Build Coastguard Worker     return "udata8";
71*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_sdata4:
72*9880d681SAndroid Build Coastguard Worker     return "sdata4";
73*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_sdata8:
74*9880d681SAndroid Build Coastguard Worker     return "sdata8";
75*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
76*9880d681SAndroid Build Coastguard Worker     return "pcrel udata4";
77*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
78*9880d681SAndroid Build Coastguard Worker     return "pcrel sdata4";
79*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
80*9880d681SAndroid Build Coastguard Worker     return "pcrel udata8";
81*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
82*9880d681SAndroid Build Coastguard Worker     return "pcrel sdata8";
83*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4
84*9880d681SAndroid Build Coastguard Worker       :
85*9880d681SAndroid Build Coastguard Worker     return "indirect pcrel udata4";
86*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
87*9880d681SAndroid Build Coastguard Worker       :
88*9880d681SAndroid Build Coastguard Worker     return "indirect pcrel sdata4";
89*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8
90*9880d681SAndroid Build Coastguard Worker       :
91*9880d681SAndroid Build Coastguard Worker     return "indirect pcrel udata8";
92*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8
93*9880d681SAndroid Build Coastguard Worker       :
94*9880d681SAndroid Build Coastguard Worker     return "indirect pcrel sdata8";
95*9880d681SAndroid Build Coastguard Worker   }
96*9880d681SAndroid Build Coastguard Worker 
97*9880d681SAndroid Build Coastguard Worker   return "<unknown encoding>";
98*9880d681SAndroid Build Coastguard Worker }
99*9880d681SAndroid Build Coastguard Worker 
100*9880d681SAndroid Build Coastguard Worker /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
101*9880d681SAndroid Build Coastguard Worker /// encoding.  If verbose assembly output is enabled, we output comments
102*9880d681SAndroid Build Coastguard Worker /// describing the encoding.  Desc is an optional string saying what the
103*9880d681SAndroid Build Coastguard Worker /// encoding is specifying (e.g. "LSDA").
EmitEncodingByte(unsigned Val,const char * Desc) const104*9880d681SAndroid Build Coastguard Worker void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) const {
105*9880d681SAndroid Build Coastguard Worker   if (isVerbose()) {
106*9880d681SAndroid Build Coastguard Worker     if (Desc)
107*9880d681SAndroid Build Coastguard Worker       OutStreamer->AddComment(Twine(Desc) + " Encoding = " +
108*9880d681SAndroid Build Coastguard Worker                               Twine(DecodeDWARFEncoding(Val)));
109*9880d681SAndroid Build Coastguard Worker     else
110*9880d681SAndroid Build Coastguard Worker       OutStreamer->AddComment(Twine("Encoding = ") + DecodeDWARFEncoding(Val));
111*9880d681SAndroid Build Coastguard Worker   }
112*9880d681SAndroid Build Coastguard Worker 
113*9880d681SAndroid Build Coastguard Worker   OutStreamer->EmitIntValue(Val, 1);
114*9880d681SAndroid Build Coastguard Worker }
115*9880d681SAndroid Build Coastguard Worker 
116*9880d681SAndroid Build Coastguard Worker /// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
GetSizeOfEncodedValue(unsigned Encoding) const117*9880d681SAndroid Build Coastguard Worker unsigned AsmPrinter::GetSizeOfEncodedValue(unsigned Encoding) const {
118*9880d681SAndroid Build Coastguard Worker   if (Encoding == dwarf::DW_EH_PE_omit)
119*9880d681SAndroid Build Coastguard Worker     return 0;
120*9880d681SAndroid Build Coastguard Worker 
121*9880d681SAndroid Build Coastguard Worker   switch (Encoding & 0x07) {
122*9880d681SAndroid Build Coastguard Worker   default:
123*9880d681SAndroid Build Coastguard Worker     llvm_unreachable("Invalid encoded value.");
124*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_absptr:
125*9880d681SAndroid Build Coastguard Worker     return MF->getDataLayout().getPointerSize();
126*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_udata2:
127*9880d681SAndroid Build Coastguard Worker     return 2;
128*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_udata4:
129*9880d681SAndroid Build Coastguard Worker     return 4;
130*9880d681SAndroid Build Coastguard Worker   case dwarf::DW_EH_PE_udata8:
131*9880d681SAndroid Build Coastguard Worker     return 8;
132*9880d681SAndroid Build Coastguard Worker   }
133*9880d681SAndroid Build Coastguard Worker }
134*9880d681SAndroid Build Coastguard Worker 
EmitTTypeReference(const GlobalValue * GV,unsigned Encoding) const135*9880d681SAndroid Build Coastguard Worker void AsmPrinter::EmitTTypeReference(const GlobalValue *GV,
136*9880d681SAndroid Build Coastguard Worker                                     unsigned Encoding) const {
137*9880d681SAndroid Build Coastguard Worker   if (GV) {
138*9880d681SAndroid Build Coastguard Worker     const TargetLoweringObjectFile &TLOF = getObjFileLowering();
139*9880d681SAndroid Build Coastguard Worker 
140*9880d681SAndroid Build Coastguard Worker     const MCExpr *Exp =
141*9880d681SAndroid Build Coastguard Worker         TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI,
142*9880d681SAndroid Build Coastguard Worker                                      *OutStreamer);
143*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
144*9880d681SAndroid Build Coastguard Worker   } else
145*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
146*9880d681SAndroid Build Coastguard Worker }
147*9880d681SAndroid Build Coastguard Worker 
emitDwarfSymbolReference(const MCSymbol * Label,bool ForceOffset) const148*9880d681SAndroid Build Coastguard Worker void AsmPrinter::emitDwarfSymbolReference(const MCSymbol *Label,
149*9880d681SAndroid Build Coastguard Worker                                           bool ForceOffset) const {
150*9880d681SAndroid Build Coastguard Worker   if (!ForceOffset) {
151*9880d681SAndroid Build Coastguard Worker     // On COFF targets, we have to emit the special .secrel32 directive.
152*9880d681SAndroid Build Coastguard Worker     if (MAI->needsDwarfSectionOffsetDirective()) {
153*9880d681SAndroid Build Coastguard Worker       OutStreamer->EmitCOFFSecRel32(Label);
154*9880d681SAndroid Build Coastguard Worker       return;
155*9880d681SAndroid Build Coastguard Worker     }
156*9880d681SAndroid Build Coastguard Worker 
157*9880d681SAndroid Build Coastguard Worker     // If the format uses relocations with dwarf, refer to the symbol directly.
158*9880d681SAndroid Build Coastguard Worker     if (MAI->doesDwarfUseRelocationsAcrossSections()) {
159*9880d681SAndroid Build Coastguard Worker       OutStreamer->EmitSymbolValue(Label, 4);
160*9880d681SAndroid Build Coastguard Worker       return;
161*9880d681SAndroid Build Coastguard Worker     }
162*9880d681SAndroid Build Coastguard Worker   }
163*9880d681SAndroid Build Coastguard Worker 
164*9880d681SAndroid Build Coastguard Worker   // Otherwise, emit it as a label difference from the start of the section.
165*9880d681SAndroid Build Coastguard Worker   EmitLabelDifference(Label, Label->getSection().getBeginSymbol(), 4);
166*9880d681SAndroid Build Coastguard Worker }
167*9880d681SAndroid Build Coastguard Worker 
emitDwarfStringOffset(DwarfStringPoolEntryRef S) const168*9880d681SAndroid Build Coastguard Worker void AsmPrinter::emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
169*9880d681SAndroid Build Coastguard Worker   if (MAI->doesDwarfUseRelocationsAcrossSections()) {
170*9880d681SAndroid Build Coastguard Worker     emitDwarfSymbolReference(S.getSymbol());
171*9880d681SAndroid Build Coastguard Worker     return;
172*9880d681SAndroid Build Coastguard Worker   }
173*9880d681SAndroid Build Coastguard Worker 
174*9880d681SAndroid Build Coastguard Worker   // Just emit the offset directly; no need for symbol math.
175*9880d681SAndroid Build Coastguard Worker   EmitInt32(S.getOffset());
176*9880d681SAndroid Build Coastguard Worker }
177*9880d681SAndroid Build Coastguard Worker 
178*9880d681SAndroid Build Coastguard Worker /// EmitDwarfRegOp - Emit dwarf register operation.
EmitDwarfRegOp(ByteStreamer & Streamer,const MachineLocation & MLoc) const179*9880d681SAndroid Build Coastguard Worker void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
180*9880d681SAndroid Build Coastguard Worker                                 const MachineLocation &MLoc) const {
181*9880d681SAndroid Build Coastguard Worker   DebugLocDwarfExpression Expr(getDwarfDebug()->getDwarfVersion(), Streamer);
182*9880d681SAndroid Build Coastguard Worker   const MCRegisterInfo *MRI = MMI->getContext().getRegisterInfo();
183*9880d681SAndroid Build Coastguard Worker   int Reg = MRI->getDwarfRegNum(MLoc.getReg(), false);
184*9880d681SAndroid Build Coastguard Worker   if (Reg < 0) {
185*9880d681SAndroid Build Coastguard Worker     // We assume that pointers are always in an addressable register.
186*9880d681SAndroid Build Coastguard Worker     if (MLoc.isIndirect())
187*9880d681SAndroid Build Coastguard Worker       // FIXME: We have no reasonable way of handling errors in here. The
188*9880d681SAndroid Build Coastguard Worker       // caller might be in the middle of a dwarf expression. We should
189*9880d681SAndroid Build Coastguard Worker       // probably assert that Reg >= 0 once debug info generation is more
190*9880d681SAndroid Build Coastguard Worker       // mature.
191*9880d681SAndroid Build Coastguard Worker       return Expr.EmitOp(dwarf::DW_OP_nop,
192*9880d681SAndroid Build Coastguard Worker                          "nop (could not find a dwarf register number)");
193*9880d681SAndroid Build Coastguard Worker 
194*9880d681SAndroid Build Coastguard Worker     // Attempt to find a valid super- or sub-register.
195*9880d681SAndroid Build Coastguard Worker     if (!Expr.AddMachineRegPiece(*MF->getSubtarget().getRegisterInfo(),
196*9880d681SAndroid Build Coastguard Worker                                  MLoc.getReg()))
197*9880d681SAndroid Build Coastguard Worker       Expr.EmitOp(dwarf::DW_OP_nop,
198*9880d681SAndroid Build Coastguard Worker                   "nop (could not find a dwarf register number)");
199*9880d681SAndroid Build Coastguard Worker     return;
200*9880d681SAndroid Build Coastguard Worker   }
201*9880d681SAndroid Build Coastguard Worker 
202*9880d681SAndroid Build Coastguard Worker   if (MLoc.isIndirect())
203*9880d681SAndroid Build Coastguard Worker     Expr.AddRegIndirect(Reg, MLoc.getOffset());
204*9880d681SAndroid Build Coastguard Worker   else
205*9880d681SAndroid Build Coastguard Worker     Expr.AddReg(Reg);
206*9880d681SAndroid Build Coastguard Worker }
207*9880d681SAndroid Build Coastguard Worker 
208*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
209*9880d681SAndroid Build Coastguard Worker // Dwarf Lowering Routines
210*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
211*9880d681SAndroid Build Coastguard Worker 
emitCFIInstruction(const MCCFIInstruction & Inst) const212*9880d681SAndroid Build Coastguard Worker void AsmPrinter::emitCFIInstruction(const MCCFIInstruction &Inst) const {
213*9880d681SAndroid Build Coastguard Worker   switch (Inst.getOperation()) {
214*9880d681SAndroid Build Coastguard Worker   default:
215*9880d681SAndroid Build Coastguard Worker     llvm_unreachable("Unexpected instruction");
216*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpDefCfaOffset:
217*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIDefCfaOffset(Inst.getOffset());
218*9880d681SAndroid Build Coastguard Worker     break;
219*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpAdjustCfaOffset:
220*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIAdjustCfaOffset(Inst.getOffset());
221*9880d681SAndroid Build Coastguard Worker     break;
222*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpDefCfa:
223*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset());
224*9880d681SAndroid Build Coastguard Worker     break;
225*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpDefCfaRegister:
226*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIDefCfaRegister(Inst.getRegister());
227*9880d681SAndroid Build Coastguard Worker     break;
228*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpOffset:
229*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIOffset(Inst.getRegister(), Inst.getOffset());
230*9880d681SAndroid Build Coastguard Worker     break;
231*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpRegister:
232*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIRegister(Inst.getRegister(), Inst.getRegister2());
233*9880d681SAndroid Build Coastguard Worker     break;
234*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpWindowSave:
235*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIWindowSave();
236*9880d681SAndroid Build Coastguard Worker     break;
237*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpSameValue:
238*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFISameValue(Inst.getRegister());
239*9880d681SAndroid Build Coastguard Worker     break;
240*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpGnuArgsSize:
241*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIGnuArgsSize(Inst.getOffset());
242*9880d681SAndroid Build Coastguard Worker     break;
243*9880d681SAndroid Build Coastguard Worker   case MCCFIInstruction::OpEscape:
244*9880d681SAndroid Build Coastguard Worker     OutStreamer->EmitCFIEscape(Inst.getValues());
245*9880d681SAndroid Build Coastguard Worker     break;
246*9880d681SAndroid Build Coastguard Worker   }
247*9880d681SAndroid Build Coastguard Worker }
248*9880d681SAndroid Build Coastguard Worker 
emitDwarfDIE(const DIE & Die) const249*9880d681SAndroid Build Coastguard Worker void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
250*9880d681SAndroid Build Coastguard Worker   // Emit the code (index) for the abbreviation.
251*9880d681SAndroid Build Coastguard Worker   if (isVerbose())
252*9880d681SAndroid Build Coastguard Worker     OutStreamer->AddComment("Abbrev [" + Twine(Die.getAbbrevNumber()) + "] 0x" +
253*9880d681SAndroid Build Coastguard Worker                             Twine::utohexstr(Die.getOffset()) + ":0x" +
254*9880d681SAndroid Build Coastguard Worker                             Twine::utohexstr(Die.getSize()) + " " +
255*9880d681SAndroid Build Coastguard Worker                             dwarf::TagString(Die.getTag()));
256*9880d681SAndroid Build Coastguard Worker   EmitULEB128(Die.getAbbrevNumber());
257*9880d681SAndroid Build Coastguard Worker 
258*9880d681SAndroid Build Coastguard Worker   // Emit the DIE attribute values.
259*9880d681SAndroid Build Coastguard Worker   for (const auto &V : Die.values()) {
260*9880d681SAndroid Build Coastguard Worker     dwarf::Attribute Attr = V.getAttribute();
261*9880d681SAndroid Build Coastguard Worker     assert(V.getForm() && "Too many attributes for DIE (check abbreviation)");
262*9880d681SAndroid Build Coastguard Worker 
263*9880d681SAndroid Build Coastguard Worker     if (isVerbose()) {
264*9880d681SAndroid Build Coastguard Worker       OutStreamer->AddComment(dwarf::AttributeString(Attr));
265*9880d681SAndroid Build Coastguard Worker       if (Attr == dwarf::DW_AT_accessibility)
266*9880d681SAndroid Build Coastguard Worker         OutStreamer->AddComment(
267*9880d681SAndroid Build Coastguard Worker             dwarf::AccessibilityString(V.getDIEInteger().getValue()));
268*9880d681SAndroid Build Coastguard Worker     }
269*9880d681SAndroid Build Coastguard Worker 
270*9880d681SAndroid Build Coastguard Worker     // Emit an attribute using the defined form.
271*9880d681SAndroid Build Coastguard Worker     V.EmitValue(this);
272*9880d681SAndroid Build Coastguard Worker   }
273*9880d681SAndroid Build Coastguard Worker 
274*9880d681SAndroid Build Coastguard Worker   // Emit the DIE children if any.
275*9880d681SAndroid Build Coastguard Worker   if (Die.hasChildren()) {
276*9880d681SAndroid Build Coastguard Worker     for (auto &Child : Die.children())
277*9880d681SAndroid Build Coastguard Worker       emitDwarfDIE(Child);
278*9880d681SAndroid Build Coastguard Worker 
279*9880d681SAndroid Build Coastguard Worker     OutStreamer->AddComment("End Of Children Mark");
280*9880d681SAndroid Build Coastguard Worker     EmitInt8(0);
281*9880d681SAndroid Build Coastguard Worker   }
282*9880d681SAndroid Build Coastguard Worker }
283*9880d681SAndroid Build Coastguard Worker 
emitDwarfAbbrev(const DIEAbbrev & Abbrev) const284*9880d681SAndroid Build Coastguard Worker void AsmPrinter::emitDwarfAbbrev(const DIEAbbrev &Abbrev) const {
285*9880d681SAndroid Build Coastguard Worker   // Emit the abbreviations code (base 1 index.)
286*9880d681SAndroid Build Coastguard Worker   EmitULEB128(Abbrev.getNumber(), "Abbreviation Code");
287*9880d681SAndroid Build Coastguard Worker 
288*9880d681SAndroid Build Coastguard Worker   // Emit the abbreviations data.
289*9880d681SAndroid Build Coastguard Worker   Abbrev.Emit(this);
290*9880d681SAndroid Build Coastguard Worker }
291