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