blob: d7540ce077da14acac585961ec7f48f17a92b557 [file] [log] [blame]
Kevin Enderby7cbf73a2010-07-28 20:55:35 +00001//===- lib/MC/MCDwarf.cpp - MCDwarf implementation ------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Rafael Espindola767b1be2010-12-04 00:31:13 +000010#include "llvm/MC/MCAsmInfo.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000011#include "llvm/MC/MCDwarf.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000012#include "llvm/MC/MCAssembler.h"
Rafael Espindolaad8aaa02010-11-22 11:53:17 +000013#include "llvm/MC/MCStreamer.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000014#include "llvm/MC/MCSymbol.h"
15#include "llvm/MC/MCExpr.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCObjectWriter.h"
18#include "llvm/ADT/SmallString.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000019#include "llvm/Support/Debug.h"
20#include "llvm/Support/raw_ostream.h"
Kevin Enderbyc0957932010-09-30 16:52:03 +000021#include "llvm/Target/TargetAsmBackend.h"
Kevin Enderby7cbf73a2010-07-28 20:55:35 +000022using namespace llvm;
23
Kevin Enderbyc0957932010-09-30 16:52:03 +000024// Given a special op, return the address skip amount (in units of
25// DWARF2_LINE_MIN_INSN_LENGTH.
26#define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE)
27
28// The maximum address skip amount that can be encoded with a special op.
29#define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255)
30
31// First special line opcode - leave room for the standard opcodes.
32// Note: If you want to change this, you'll have to update the
33// "standard_opcode_lengths" table that is emitted in DwarfFileTable::Emit().
34#define DWARF2_LINE_OPCODE_BASE 13
35
36// Minimum line offset in a special line info. opcode. This value
37// was chosen to give a reasonable range of values.
38#define DWARF2_LINE_BASE -5
39
40// Range of line offsets in a special line info. opcode.
41# define DWARF2_LINE_RANGE 14
42
43// Define the architecture-dependent minimum instruction length (in bytes).
44// This value should be rather too small than too big.
45# define DWARF2_LINE_MIN_INSN_LENGTH 1
46
47// Note: when DWARF2_LINE_MIN_INSN_LENGTH == 1 which is the current setting,
48// this routine is a nop and will be optimized away.
49static inline uint64_t ScaleAddrDelta(uint64_t AddrDelta)
50{
51 if (DWARF2_LINE_MIN_INSN_LENGTH == 1)
52 return AddrDelta;
53 if (AddrDelta % DWARF2_LINE_MIN_INSN_LENGTH != 0) {
54 // TODO: report this error, but really only once.
55 ;
56 }
57 return AddrDelta / DWARF2_LINE_MIN_INSN_LENGTH;
58}
59
60//
61// This is called when an instruction is assembled into the specified section
62// and if there is information from the last .loc directive that has yet to have
63// a line entry made for it is made.
64//
Rafael Espindola195a0ce2010-11-19 02:26:16 +000065void MCLineEntry::Make(MCStreamer *MCOS, const MCSection *Section) {
Kevin Enderbyc0957932010-09-30 16:52:03 +000066 if (!MCOS->getContext().getDwarfLocSeen())
67 return;
68
69 // Create a symbol at in the current section for use in the line entry.
70 MCSymbol *LineSym = MCOS->getContext().CreateTempSymbol();
71 // Set the value of the symbol to use for the MCLineEntry.
72 MCOS->EmitLabel(LineSym);
73
74 // Get the current .loc info saved in the context.
75 const MCDwarfLoc &DwarfLoc = MCOS->getContext().getCurrentDwarfLoc();
76
77 // Create a (local) line entry with the symbol and the current .loc info.
78 MCLineEntry LineEntry(LineSym, DwarfLoc);
79
80 // clear DwarfLocSeen saying the current .loc info is now used.
Kevin Enderby3f55c242010-10-04 20:17:24 +000081 MCOS->getContext().ClearDwarfLocSeen();
Kevin Enderbyc0957932010-09-30 16:52:03 +000082
83 // Get the MCLineSection for this section, if one does not exist for this
84 // section create it.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000085 const DenseMap<const MCSection *, MCLineSection *> &MCLineSections =
Kevin Enderbyc0957932010-09-30 16:52:03 +000086 MCOS->getContext().getMCLineSections();
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000087 MCLineSection *LineSection = MCLineSections.lookup(Section);
Kevin Enderbyc0957932010-09-30 16:52:03 +000088 if (!LineSection) {
89 // Create a new MCLineSection. This will be deleted after the dwarf line
90 // table is created using it by iterating through the MCLineSections
91 // DenseMap.
92 LineSection = new MCLineSection;
93 // Save a pointer to the new LineSection into the MCLineSections DenseMap.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +000094 MCOS->getContext().addMCLineSection(Section, LineSection);
Kevin Enderbyc0957932010-09-30 16:52:03 +000095 }
96
97 // Add the line entry to this section's entries.
98 LineSection->addLineEntry(LineEntry);
99}
100
101//
102// This helper routine returns an expression of End - Start + IntVal .
103//
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000104static inline const MCExpr *MakeStartMinusEndExpr(const MCStreamer &MCOS,
105 const MCSymbol &Start,
106 const MCSymbol &End,
107 int IntVal) {
Kevin Enderbyc0957932010-09-30 16:52:03 +0000108 MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
109 const MCExpr *Res =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000110 MCSymbolRefExpr::Create(&End, Variant, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000111 const MCExpr *RHS =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000112 MCSymbolRefExpr::Create(&Start, Variant, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000113 const MCExpr *Res1 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000114 MCBinaryExpr::Create(MCBinaryExpr::Sub, Res, RHS, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000115 const MCExpr *Res2 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000116 MCConstantExpr::Create(IntVal, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000117 const MCExpr *Res3 =
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000118 MCBinaryExpr::Create(MCBinaryExpr::Sub, Res1, Res2, MCOS.getContext());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000119 return Res3;
120}
121
Kevin Enderbyc0957932010-09-30 16:52:03 +0000122//
123// This emits the Dwarf line table for the specified section from the entries
124// in the LineSection.
125//
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000126static inline void EmitDwarfLineTable(MCStreamer *MCOS,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000127 const MCSection *Section,
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000128 const MCLineSection *LineSection,
Rafael Espindola32a006e2010-12-03 00:55:40 +0000129 const MCSection *DwarfLineSection) {
Kevin Enderbyc0957932010-09-30 16:52:03 +0000130 unsigned FileNum = 1;
131 unsigned LastLine = 1;
132 unsigned Column = 0;
133 unsigned Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
134 unsigned Isa = 0;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000135 MCSymbol *LastLabel = NULL;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000136
137 // Loop through each MCLineEntry and encode the dwarf line number table.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000138 for (MCLineSection::const_iterator
Kevin Enderbyc0957932010-09-30 16:52:03 +0000139 it = LineSection->getMCLineEntries()->begin(),
140 ie = LineSection->getMCLineEntries()->end(); it != ie; ++it) {
141
142 if (FileNum != it->getFileNum()) {
143 FileNum = it->getFileNum();
144 MCOS->EmitIntValue(dwarf::DW_LNS_set_file, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000145 MCOS->EmitULEB128IntValue(FileNum);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000146 }
147 if (Column != it->getColumn()) {
148 Column = it->getColumn();
149 MCOS->EmitIntValue(dwarf::DW_LNS_set_column, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000150 MCOS->EmitULEB128IntValue(Column);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000151 }
152 if (Isa != it->getIsa()) {
153 Isa = it->getIsa();
154 MCOS->EmitIntValue(dwarf::DW_LNS_set_isa, 1);
Rafael Espindola3ff57092010-11-02 17:22:24 +0000155 MCOS->EmitULEB128IntValue(Isa);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000156 }
157 if ((it->getFlags() ^ Flags) & DWARF2_FLAG_IS_STMT) {
158 Flags = it->getFlags();
159 MCOS->EmitIntValue(dwarf::DW_LNS_negate_stmt, 1);
160 }
161 if (it->getFlags() & DWARF2_FLAG_BASIC_BLOCK)
162 MCOS->EmitIntValue(dwarf::DW_LNS_set_basic_block, 1);
163 if (it->getFlags() & DWARF2_FLAG_PROLOGUE_END)
164 MCOS->EmitIntValue(dwarf::DW_LNS_set_prologue_end, 1);
165 if (it->getFlags() & DWARF2_FLAG_EPILOGUE_BEGIN)
166 MCOS->EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
167
Rafael Espindola64185cc2010-11-13 01:06:27 +0000168 int64_t LineDelta = static_cast<int64_t>(it->getLine()) - LastLine;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000169 MCSymbol *Label = it->getLabel();
170
171 // At this point we want to emit/create the sequence to encode the delta in
172 // line numbers and the increment of the address from the previous Label
173 // and the current Label.
Rafael Espindola32a006e2010-12-03 00:55:40 +0000174 MCOS->EmitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000175
176 LastLine = it->getLine();
177 LastLabel = Label;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000178 }
179
180 // Emit a DW_LNE_end_sequence for the end of the section.
181 // Using the pointer Section create a temporary label at the end of the
182 // section and use that and the LastLabel to compute the address delta
183 // and use INT64_MAX as the line delta which is the signal that this is
184 // actually a DW_LNE_end_sequence.
185
186 // Switch to the section to be able to create a symbol at its end.
187 MCOS->SwitchSection(Section);
188 // Create a symbol at the end of the section.
189 MCSymbol *SectionEnd = MCOS->getContext().CreateTempSymbol();
190 // Set the value of the symbol, as we are at the end of the section.
191 MCOS->EmitLabel(SectionEnd);
192
193 // Switch back the the dwarf line section.
194 MCOS->SwitchSection(DwarfLineSection);
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000195
Rafael Espindola32a006e2010-12-03 00:55:40 +0000196 MCOS->EmitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000197}
198
199//
200// This emits the Dwarf file and the line tables.
201//
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000202void MCDwarfFileTable::Emit(MCStreamer *MCOS,
Rafael Espindola767b1be2010-12-04 00:31:13 +0000203 const MCSection *DwarfLineSection) {
Kevin Enderbyc0957932010-09-30 16:52:03 +0000204 // Switch to the section where the table will be emitted into.
205 MCOS->SwitchSection(DwarfLineSection);
206
207 // Create a symbol at the beginning of this section.
208 MCSymbol *LineStartSym = MCOS->getContext().CreateTempSymbol();
209 // Set the value of the symbol, as we are at the start of the section.
210 MCOS->EmitLabel(LineStartSym);
211
212 // Create a symbol for the end of the section (to be set when we get there).
213 MCSymbol *LineEndSym = MCOS->getContext().CreateTempSymbol();
214
215 // The first 4 bytes is the total length of the information for this
216 // compilation unit (not including these 4 bytes for the length).
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000217 MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *LineEndSym,4),
Rafael Espindola0bbe0b42010-12-06 17:27:56 +0000218 4);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000219
220 // Next 2 bytes is the Version, which is Dwarf 2.
221 MCOS->EmitIntValue(2, 2);
222
223 // Create a symbol for the end of the prologue (to be set when we get there).
224 MCSymbol *ProEndSym = MCOS->getContext().CreateTempSymbol(); // Lprologue_end
225
226 // Length of the prologue, is the next 4 bytes. Which is the start of the
227 // section to the end of the prologue. Not including the 4 bytes for the
228 // total length, the 2 bytes for the version, and these 4 bytes for the
229 // length of the prologue.
Rafael Espindola5fad7a92010-12-09 23:08:35 +0000230 MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *ProEndSym,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000231 (4 + 2 + 4)),
Rafael Espindola5d4918d2010-12-04 03:21:47 +0000232 4, 0);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000233
234 // Parameters of the state machine, are next.
235 MCOS->EmitIntValue(DWARF2_LINE_MIN_INSN_LENGTH, 1);
236 MCOS->EmitIntValue(DWARF2_LINE_DEFAULT_IS_STMT, 1);
237 MCOS->EmitIntValue(DWARF2_LINE_BASE, 1);
238 MCOS->EmitIntValue(DWARF2_LINE_RANGE, 1);
239 MCOS->EmitIntValue(DWARF2_LINE_OPCODE_BASE, 1);
240
241 // Standard opcode lengths
242 MCOS->EmitIntValue(0, 1); // length of DW_LNS_copy
243 MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_pc
244 MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_line
245 MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_file
246 MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_column
247 MCOS->EmitIntValue(0, 1); // length of DW_LNS_negate_stmt
248 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_basic_block
249 MCOS->EmitIntValue(0, 1); // length of DW_LNS_const_add_pc
250 MCOS->EmitIntValue(1, 1); // length of DW_LNS_fixed_advance_pc
251 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_prologue_end
252 MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_epilogue_begin
253 MCOS->EmitIntValue(1, 1); // DW_LNS_set_isa
254
255 // Put out the directory and file tables.
256
257 // First the directory table.
258 const std::vector<StringRef> &MCDwarfDirs =
259 MCOS->getContext().getMCDwarfDirs();
260 for (unsigned i = 0; i < MCDwarfDirs.size(); i++) {
261 MCOS->EmitBytes(MCDwarfDirs[i], 0); // the DirectoryName
262 MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string
263 }
264 MCOS->EmitIntValue(0, 1); // Terminate the directory list
265
266 // Second the file table.
267 const std::vector<MCDwarfFile *> &MCDwarfFiles =
268 MCOS->getContext().getMCDwarfFiles();
269 for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {
270 MCOS->EmitBytes(MCDwarfFiles[i]->getName(), 0); // FileName
271 MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string
Rafael Espindola3ff57092010-11-02 17:22:24 +0000272 // the Directory num
273 MCOS->EmitULEB128IntValue(MCDwarfFiles[i]->getDirIndex());
Kevin Enderbyc0957932010-09-30 16:52:03 +0000274 MCOS->EmitIntValue(0, 1); // last modification timestamp (always 0)
275 MCOS->EmitIntValue(0, 1); // filesize (always 0)
276 }
277 MCOS->EmitIntValue(0, 1); // Terminate the file list
278
279 // This is the end of the prologue, so set the value of the symbol at the
280 // end of the prologue (that was used in a previous expression).
281 MCOS->EmitLabel(ProEndSym);
282
283 // Put out the line tables.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000284 const DenseMap<const MCSection *, MCLineSection *> &MCLineSections =
Kevin Enderbyc0957932010-09-30 16:52:03 +0000285 MCOS->getContext().getMCLineSections();
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000286 const std::vector<const MCSection *> &MCLineSectionOrder =
287 MCOS->getContext().getMCLineSectionOrder();
288 for (std::vector<const MCSection*>::const_iterator it =
289 MCLineSectionOrder.begin(), ie = MCLineSectionOrder.end(); it != ie;
290 ++it) {
291 const MCSection *Sec = *it;
292 const MCLineSection *Line = MCLineSections.lookup(Sec);
Rafael Espindola32a006e2010-12-03 00:55:40 +0000293 EmitDwarfLineTable(MCOS, Sec, Line, DwarfLineSection);
Kevin Enderbyc0957932010-09-30 16:52:03 +0000294
295 // Now delete the MCLineSections that were created in MCLineEntry::Make()
296 // and used to emit the line table.
Rafael Espindola17fd7bd2010-11-19 07:41:23 +0000297 delete Line;
Kevin Enderbyc0957932010-09-30 16:52:03 +0000298 }
299
Rafael Espindola767b1be2010-12-04 00:31:13 +0000300 if (MCOS->getContext().getAsmInfo().getLinkerRequiresNonEmptyDwarfLines()
301 && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) {
Rafael Espindolaa8de83c2010-12-03 23:36:59 +0000302 // The darwin9 linker has a bug (see PR8715). For for 32-bit architectures
303 // it requires:
304 // total_length >= prologue_length + 10
305 // We are 4 bytes short, since we have total_length = 51 and
306 // prologue_length = 45
Devang Patel5113cdb2010-12-03 00:10:48 +0000307
Rafael Espindolaa8de83c2010-12-03 23:36:59 +0000308 // The regular end_sequence should be sufficient.
309 MCDwarfLineAddr::Emit(MCOS, INT64_MAX, 0);
Devang Patel5113cdb2010-12-03 00:10:48 +0000310 }
311
Kevin Enderbyc0957932010-09-30 16:52:03 +0000312 // This is the end of the section, so set the value of the symbol at the end
313 // of this section (that was used in a previous expression).
314 MCOS->EmitLabel(LineEndSym);
315}
316
Kevin Enderbyc0957932010-09-30 16:52:03 +0000317/// Utility function to write the encoding to an object writer.
318void MCDwarfLineAddr::Write(MCObjectWriter *OW, int64_t LineDelta,
319 uint64_t AddrDelta) {
320 SmallString<256> Tmp;
321 raw_svector_ostream OS(Tmp);
322 MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS);
323 OW->WriteBytes(OS.str());
324}
325
326/// Utility function to emit the encoding to a streamer.
Rafael Espindola195a0ce2010-11-19 02:26:16 +0000327void MCDwarfLineAddr::Emit(MCStreamer *MCOS, int64_t LineDelta,
Kevin Enderbyc0957932010-09-30 16:52:03 +0000328 uint64_t AddrDelta) {
329 SmallString<256> Tmp;
330 raw_svector_ostream OS(Tmp);
331 MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS);
332 MCOS->EmitBytes(OS.str(), /*AddrSpace=*/0);
333}
334
335/// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
336void MCDwarfLineAddr::Encode(int64_t LineDelta, uint64_t AddrDelta,
337 raw_ostream &OS) {
338 uint64_t Temp, Opcode;
339 bool NeedCopy = false;
340
341 // Scale the address delta by the minimum instruction length.
342 AddrDelta = ScaleAddrDelta(AddrDelta);
343
344 // A LineDelta of INT64_MAX is a signal that this is actually a
345 // DW_LNE_end_sequence. We cannot use special opcodes here, since we want the
346 // end_sequence to emit the matrix entry.
347 if (LineDelta == INT64_MAX) {
348 if (AddrDelta == MAX_SPECIAL_ADDR_DELTA)
349 OS << char(dwarf::DW_LNS_const_add_pc);
350 else {
351 OS << char(dwarf::DW_LNS_advance_pc);
352 SmallString<32> Tmp;
353 raw_svector_ostream OSE(Tmp);
354 MCObjectWriter::EncodeULEB128(AddrDelta, OSE);
355 OS << OSE.str();
356 }
357 OS << char(dwarf::DW_LNS_extended_op);
358 OS << char(1);
359 OS << char(dwarf::DW_LNE_end_sequence);
360 return;
361 }
362
363 // Bias the line delta by the base.
364 Temp = LineDelta - DWARF2_LINE_BASE;
365
366 // If the line increment is out of range of a special opcode, we must encode
367 // it with DW_LNS_advance_line.
368 if (Temp >= DWARF2_LINE_RANGE) {
369 OS << char(dwarf::DW_LNS_advance_line);
370 SmallString<32> Tmp;
371 raw_svector_ostream OSE(Tmp);
372 MCObjectWriter::EncodeSLEB128(LineDelta, OSE);
373 OS << OSE.str();
374
375 LineDelta = 0;
376 Temp = 0 - DWARF2_LINE_BASE;
377 NeedCopy = true;
378 }
379
380 // Use DW_LNS_copy instead of a "line +0, addr +0" special opcode.
381 if (LineDelta == 0 && AddrDelta == 0) {
382 OS << char(dwarf::DW_LNS_copy);
383 return;
384 }
385
386 // Bias the opcode by the special opcode base.
387 Temp += DWARF2_LINE_OPCODE_BASE;
388
389 // Avoid overflow when addr_delta is large.
390 if (AddrDelta < 256 + MAX_SPECIAL_ADDR_DELTA) {
391 // Try using a special opcode.
392 Opcode = Temp + AddrDelta * DWARF2_LINE_RANGE;
393 if (Opcode <= 255) {
394 OS << char(Opcode);
395 return;
396 }
397
398 // Try using DW_LNS_const_add_pc followed by special op.
399 Opcode = Temp + (AddrDelta - MAX_SPECIAL_ADDR_DELTA) * DWARF2_LINE_RANGE;
400 if (Opcode <= 255) {
401 OS << char(dwarf::DW_LNS_const_add_pc);
402 OS << char(Opcode);
403 return;
404 }
405 }
406
407 // Otherwise use DW_LNS_advance_pc.
408 OS << char(dwarf::DW_LNS_advance_pc);
409 SmallString<32> Tmp;
410 raw_svector_ostream OSE(Tmp);
411 MCObjectWriter::EncodeULEB128(AddrDelta, OSE);
412 OS << OSE.str();
413
414 if (NeedCopy)
415 OS << char(dwarf::DW_LNS_copy);
416 else
417 OS << char(Temp);
418}
419
Kevin Enderby7cbf73a2010-07-28 20:55:35 +0000420void MCDwarfFile::print(raw_ostream &OS) const {
421 OS << '"' << getName() << '"';
422}
423
424void MCDwarfFile::dump() const {
425 print(dbgs());
426}
Kevin Enderbyc0957932010-09-30 16:52:03 +0000427