blob: aa3f522c91957a5ed4e218c5f4ab1ca1695e5f68 [file] [log] [blame]
Chris Lattner9efd1182010-04-04 19:09:29 +00001//===-- AsmPrinterDwarf.cpp - AsmPrinter Dwarf Support --------------------===//
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//
10// This file implements the Dwarf emissions parts of AsmPrinter.
11//
12//===----------------------------------------------------------------------===//
13
Eric Christopher29e874d2014-03-07 22:40:37 +000014#include "ByteStreamer.h"
Chris Lattner9efd1182010-04-04 19:09:29 +000015#include "llvm/CodeGen/AsmPrinter.h"
Eric Christopher698a8ab2014-03-07 01:44:14 +000016#include "llvm/ADT/SmallBitVector.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000017#include "llvm/ADT/Twine.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000018#include "llvm/IR/DataLayout.h"
Chris Lattner9efd1182010-04-04 19:09:29 +000019#include "llvm/MC/MCAsmInfo.h"
Chris Lattner70a4fce2010-04-04 23:25:33 +000020#include "llvm/MC/MCSection.h"
Chris Lattner9efd1182010-04-04 19:09:29 +000021#include "llvm/MC/MCStreamer.h"
Chris Lattner70a4fce2010-04-04 23:25:33 +000022#include "llvm/MC/MCSymbol.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000023#include "llvm/MC/MachineLocation.h"
24#include "llvm/Support/Dwarf.h"
25#include "llvm/Support/ErrorHandling.h"
Anton Korobeynikov2f931282011-01-10 12:39:04 +000026#include "llvm/Target/TargetFrameLowering.h"
Chris Lattnere619c0d2010-04-04 20:20:50 +000027#include "llvm/Target/TargetLoweringObjectFile.h"
28#include "llvm/Target/TargetMachine.h"
Chris Lattneraabc6042010-04-04 23:41:46 +000029#include "llvm/Target/TargetRegisterInfo.h"
Chris Lattner9efd1182010-04-04 19:09:29 +000030using namespace llvm;
31
Chandler Carruth1b9dde02014-04-22 02:02:50 +000032#define DEBUG_TYPE "asm-printer"
33
Chris Lattneraabc6042010-04-04 23:41:46 +000034//===----------------------------------------------------------------------===//
35// Dwarf Emission Helper Routines
36//===----------------------------------------------------------------------===//
37
Chris Lattner9efd1182010-04-04 19:09:29 +000038/// EmitSLEB128 - emit the specified signed leb128 value.
David Blaikie5acff7e2013-06-23 18:31:11 +000039void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const {
Chris Lattner9efd1182010-04-04 19:09:29 +000040 if (isVerbose() && Desc)
41 OutStreamer.AddComment(Desc);
Chris Lattner9efd1182010-04-04 19:09:29 +000042
Benjamin Kramerc74798d2011-11-05 11:52:44 +000043 OutStreamer.EmitSLEB128IntValue(Value);
Chris Lattner9efd1182010-04-04 19:09:29 +000044}
45
46/// EmitULEB128 - emit the specified signed leb128 value.
David Blaikie5acff7e2013-06-23 18:31:11 +000047void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc,
Chris Lattner9efd1182010-04-04 19:09:29 +000048 unsigned PadTo) const {
49 if (isVerbose() && Desc)
50 OutStreamer.AddComment(Desc);
Rafael Espindola38d07562010-11-04 18:17:08 +000051
Eric Christopherbf7bc492013-01-09 03:52:05 +000052 OutStreamer.EmitULEB128IntValue(Value, PadTo);
Chris Lattner9efd1182010-04-04 19:09:29 +000053}
54
Chris Lattnerbaf2be02010-04-04 20:01:25 +000055/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
56void AsmPrinter::EmitCFAByte(unsigned Val) const {
57 if (isVerbose()) {
Eric Christopher596077b2013-12-04 22:26:43 +000058 if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset + 64)
Eric Christopher1d6bd412012-11-20 20:34:47 +000059 OutStreamer.AddComment("DW_CFA_offset + Reg (" +
Eric Christopher596077b2013-12-04 22:26:43 +000060 Twine(Val - dwarf::DW_CFA_offset) + ")");
Chris Lattnerbaf2be02010-04-04 20:01:25 +000061 else
62 OutStreamer.AddComment(dwarf::CallFrameString(Val));
63 }
Eric Christopherce0cfce2013-01-09 01:35:34 +000064 OutStreamer.EmitIntValue(Val, 1);
Chris Lattnerbaf2be02010-04-04 20:01:25 +000065}
66
Chris Lattnerb75af3c2010-04-04 20:04:21 +000067static const char *DecodeDWARFEncoding(unsigned Encoding) {
68 switch (Encoding) {
Eric Christopher596077b2013-12-04 22:26:43 +000069 case dwarf::DW_EH_PE_absptr:
70 return "absptr";
71 case dwarf::DW_EH_PE_omit:
72 return "omit";
73 case dwarf::DW_EH_PE_pcrel:
74 return "pcrel";
75 case dwarf::DW_EH_PE_udata4:
76 return "udata4";
77 case dwarf::DW_EH_PE_udata8:
78 return "udata8";
79 case dwarf::DW_EH_PE_sdata4:
80 return "sdata4";
81 case dwarf::DW_EH_PE_sdata8:
82 return "sdata8";
83 case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4:
84 return "pcrel udata4";
85 case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4:
86 return "pcrel sdata4";
87 case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8:
88 return "pcrel udata8";
89 case dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8:
90 return "pcrel sdata8";
91 case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata4
92 :
Chris Lattnerb75af3c2010-04-04 20:04:21 +000093 return "indirect pcrel udata4";
Eric Christopher596077b2013-12-04 22:26:43 +000094 case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
95 :
Chris Lattnerb75af3c2010-04-04 20:04:21 +000096 return "indirect pcrel sdata4";
Eric Christopher596077b2013-12-04 22:26:43 +000097 case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8
98 :
Chris Lattnerb75af3c2010-04-04 20:04:21 +000099 return "indirect pcrel udata8";
Eric Christopher596077b2013-12-04 22:26:43 +0000100 case dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8
101 :
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000102 return "indirect pcrel sdata8";
103 }
Eric Christopher1d6bd412012-11-20 20:34:47 +0000104
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000105 return "<unknown encoding>";
106}
107
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000108/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
109/// encoding. If verbose assembly output is enabled, we output comments
110/// describing the encoding. Desc is an optional string saying what the
111/// encoding is specifying (e.g. "LSDA").
Chris Lattneraabc6042010-04-04 23:41:46 +0000112void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) const {
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000113 if (isVerbose()) {
Eric Christophercb7119e2013-12-04 22:29:02 +0000114 if (Desc)
Eric Christopher596077b2013-12-04 22:26:43 +0000115 OutStreamer.AddComment(Twine(Desc) + " Encoding = " +
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000116 Twine(DecodeDWARFEncoding(Val)));
117 else
Eric Christopher596077b2013-12-04 22:26:43 +0000118 OutStreamer.AddComment(Twine("Encoding = ") + DecodeDWARFEncoding(Val));
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000119 }
Eric Christopher1d6bd412012-11-20 20:34:47 +0000120
Eric Christopherce0cfce2013-01-09 01:35:34 +0000121 OutStreamer.EmitIntValue(Val, 1);
Chris Lattnerb75af3c2010-04-04 20:04:21 +0000122}
123
Chris Lattnere619c0d2010-04-04 20:20:50 +0000124/// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
125unsigned AsmPrinter::GetSizeOfEncodedValue(unsigned Encoding) const {
126 if (Encoding == dwarf::DW_EH_PE_omit)
127 return 0;
Eric Christopher1d6bd412012-11-20 20:34:47 +0000128
Chris Lattnere619c0d2010-04-04 20:20:50 +0000129 switch (Encoding & 0x07) {
Eric Christopher596077b2013-12-04 22:26:43 +0000130 default:
131 llvm_unreachable("Invalid encoded value.");
132 case dwarf::DW_EH_PE_absptr:
133 return TM.getDataLayout()->getPointerSize();
134 case dwarf::DW_EH_PE_udata2:
135 return 2;
136 case dwarf::DW_EH_PE_udata4:
137 return 4;
138 case dwarf::DW_EH_PE_udata8:
139 return 8;
Chris Lattnere619c0d2010-04-04 20:20:50 +0000140 }
141}
142
Eric Christopher1d6bd412012-11-20 20:34:47 +0000143void AsmPrinter::EmitTTypeReference(const GlobalValue *GV,
144 unsigned Encoding) const {
Anton Korobeynikov097b0e92012-11-19 21:17:20 +0000145 if (GV) {
146 const TargetLoweringObjectFile &TLOF = getObjFileLowering();
Eric Christopher1d6bd412012-11-20 20:34:47 +0000147
Anton Korobeynikov097b0e92012-11-19 21:17:20 +0000148 const MCExpr *Exp =
Rafael Espindoladaeafb42014-02-19 17:23:20 +0000149 TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI, OutStreamer);
Eric Christopherce0cfce2013-01-09 01:35:34 +0000150 OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
Anton Korobeynikov097b0e92012-11-19 21:17:20 +0000151 } else
Eric Christopherce0cfce2013-01-09 01:35:34 +0000152 OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
Chris Lattnere619c0d2010-04-04 20:20:50 +0000153}
Chris Lattner70a4fce2010-04-04 23:25:33 +0000154
155/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
156/// section. This can be done with a special directive if the target supports
157/// it (e.g. cygwin) or by emitting it as an offset from a label at the start
158/// of the section.
159///
160/// SectionLabel is a temporary label emitted at the start of the section that
161/// Label lives in.
162void AsmPrinter::EmitSectionOffset(const MCSymbol *Label,
163 const MCSymbol *SectionLabel) const {
164 // On COFF targets, we have to emit the special .secrel32 directive.
Matt Arsenault034ca0f2013-04-22 22:49:11 +0000165 if (MAI->needsDwarfSectionOffsetDirective()) {
Rafael Espindolad3df3d32011-12-17 01:14:52 +0000166 OutStreamer.EmitCOFFSecRel32(Label);
Chris Lattner70a4fce2010-04-04 23:25:33 +0000167 return;
168 }
Eric Christopher1d6bd412012-11-20 20:34:47 +0000169
Chris Lattner70a4fce2010-04-04 23:25:33 +0000170 // Get the section that we're referring to, based on SectionLabel.
171 const MCSection &Section = SectionLabel->getSection();
Eric Christopher1d6bd412012-11-20 20:34:47 +0000172
Chris Lattner70a4fce2010-04-04 23:25:33 +0000173 // If Label has already been emitted, verify that it is in the same section as
174 // section label for sanity.
175 assert((!Label->isInSection() || &Label->getSection() == &Section) &&
176 "Section offset using wrong section base for label");
Eric Christopher1d6bd412012-11-20 20:34:47 +0000177
Duncan Sandsb847bf52011-03-12 13:07:37 +0000178 // If the section in question will end up with an address of 0 anyway, we can
179 // just emit an absolute reference to save a relocation.
180 if (Section.isBaseAddressKnownZero()) {
Eric Christopherce0cfce2013-01-09 01:35:34 +0000181 OutStreamer.EmitSymbolValue(Label, 4);
Duncan Sandsb847bf52011-03-12 13:07:37 +0000182 return;
183 }
Eric Christopher1d6bd412012-11-20 20:34:47 +0000184
Chris Lattner70a4fce2010-04-04 23:25:33 +0000185 // Otherwise, emit it as a label difference from the start of the section.
186 EmitLabelDifference(Label, SectionLabel, 4);
187}
188
Eric Christopher698a8ab2014-03-07 01:44:14 +0000189/// Emit a dwarf register operation.
Eric Christopher29e874d2014-03-07 22:40:37 +0000190static void emitDwarfRegOp(ByteStreamer &Streamer, int Reg) {
Eric Christopher698a8ab2014-03-07 01:44:14 +0000191 assert(Reg >= 0);
192 if (Reg < 32) {
Eric Christopher29e874d2014-03-07 22:40:37 +0000193 Streamer.EmitInt8(dwarf::DW_OP_reg0 + Reg,
194 dwarf::OperationEncodingString(dwarf::DW_OP_reg0 + Reg));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000195 } else {
Eric Christopher29e874d2014-03-07 22:40:37 +0000196 Streamer.EmitInt8(dwarf::DW_OP_regx, "DW_OP_regx");
197 Streamer.EmitULEB128(Reg, Twine(Reg));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000198 }
199}
200
201/// Emit an (double-)indirect dwarf register operation.
Eric Christopher29e874d2014-03-07 22:40:37 +0000202static void emitDwarfRegOpIndirect(ByteStreamer &Streamer, int Reg, int Offset,
Eric Christopher5c303202014-03-07 21:27:42 +0000203 bool Deref) {
Eric Christopher698a8ab2014-03-07 01:44:14 +0000204 assert(Reg >= 0);
205 if (Reg < 32) {
Eric Christopher29e874d2014-03-07 22:40:37 +0000206 Streamer.EmitInt8(dwarf::DW_OP_breg0 + Reg,
207 dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000208 } else {
Eric Christopher29e874d2014-03-07 22:40:37 +0000209 Streamer.EmitInt8(dwarf::DW_OP_bregx, "DW_OP_bregx");
210 Streamer.EmitULEB128(Reg, Twine(Reg));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000211 }
Eric Christopher29e874d2014-03-07 22:40:37 +0000212 Streamer.EmitSLEB128(Offset);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000213 if (Deref)
Eric Christopher29e874d2014-03-07 22:40:37 +0000214 Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
Eric Christopher698a8ab2014-03-07 01:44:14 +0000215}
216
217/// Emit a dwarf register operation for describing
218/// - a small value occupying only part of a register or
219/// - a small register representing only part of a value.
Eric Christopher29e874d2014-03-07 22:40:37 +0000220static void emitDwarfOpPiece(ByteStreamer &Streamer, unsigned Size,
Eric Christopher5c303202014-03-07 21:27:42 +0000221 unsigned Offset) {
Eric Christopher698a8ab2014-03-07 01:44:14 +0000222 assert(Size > 0);
223 if (Offset > 0) {
Eric Christopher29e874d2014-03-07 22:40:37 +0000224 Streamer.EmitInt8(dwarf::DW_OP_bit_piece, "DW_OP_bit_piece");
225 Streamer.EmitULEB128(Size, Twine(Size));
226 Streamer.EmitULEB128(Offset, Twine(Offset));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000227 } else {
Eric Christopher29e874d2014-03-07 22:40:37 +0000228 Streamer.EmitInt8(dwarf::DW_OP_piece, "DW_OP_piece");
Eric Christopher698a8ab2014-03-07 01:44:14 +0000229 unsigned ByteSize = Size / 8; // Assuming 8 bits per byte.
Eric Christopher29e874d2014-03-07 22:40:37 +0000230 Streamer.EmitULEB128(ByteSize, Twine(ByteSize));
Eric Christopher698a8ab2014-03-07 01:44:14 +0000231 }
232}
233
234/// Some targets do not provide a DWARF register number for every
235/// register. This function attempts to emit a dwarf register by
236/// emitting a piece of a super-register or by piecing together
237/// multiple subregisters that alias the register.
Eric Christopher29e874d2014-03-07 22:40:37 +0000238static void EmitDwarfRegOpPiece(ByteStreamer &Streamer, const AsmPrinter &AP,
Eric Christopher698a8ab2014-03-07 01:44:14 +0000239 const MachineLocation &MLoc) {
240 assert(!MLoc.isIndirect());
241 const TargetRegisterInfo *TRI = AP.TM.getRegisterInfo();
242 int Reg = TRI->getDwarfRegNum(MLoc.getReg(), false);
243
244 // Walk up the super-register chain until we find a valid number.
245 // For example, EAX on x86_64 is a 32-bit piece of RAX with offset 0.
246 for (MCSuperRegIterator SR(MLoc.getReg(), TRI); SR.isValid(); ++SR) {
247 Reg = TRI->getDwarfRegNum(*SR, false);
248 if (Reg >= 0) {
249 unsigned Idx = TRI->getSubRegIndex(*SR, MLoc.getReg());
250 unsigned Size = TRI->getSubRegIdxSize(Idx);
251 unsigned Offset = TRI->getSubRegIdxOffset(Idx);
252 AP.OutStreamer.AddComment("super-register");
Eric Christopher29e874d2014-03-07 22:40:37 +0000253 emitDwarfRegOp(Streamer, Reg);
254 emitDwarfOpPiece(Streamer, Size, Offset);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000255 return;
256 }
257 }
258
259 // Otherwise, attempt to find a covering set of sub-register numbers.
260 // For example, Q0 on ARM is a composition of D0+D1.
261 //
262 // Keep track of the current position so we can emit the more
263 // efficient DW_OP_piece.
264 unsigned CurPos = 0;
265 // The size of the register in bits, assuming 8 bits per byte.
Eric Christopher5c303202014-03-07 21:27:42 +0000266 unsigned RegSize = TRI->getMinimalPhysRegClass(MLoc.getReg())->getSize() * 8;
Eric Christopher698a8ab2014-03-07 01:44:14 +0000267 // Keep track of the bits in the register we already emitted, so we
268 // can avoid emitting redundant aliasing subregs.
269 SmallBitVector Coverage(RegSize, false);
270 for (MCSubRegIterator SR(MLoc.getReg(), TRI); SR.isValid(); ++SR) {
271 unsigned Idx = TRI->getSubRegIndex(MLoc.getReg(), *SR);
272 unsigned Size = TRI->getSubRegIdxSize(Idx);
273 unsigned Offset = TRI->getSubRegIdxOffset(Idx);
274 Reg = TRI->getDwarfRegNum(*SR, false);
275
276 // Intersection between the bits we already emitted and the bits
277 // covered by this subregister.
278 SmallBitVector Intersection(RegSize, false);
Eric Christopher5c303202014-03-07 21:27:42 +0000279 Intersection.set(Offset, Offset + Size);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000280 Intersection ^= Coverage;
281
282 // If this sub-register has a DWARF number and we haven't covered
283 // its range, emit a DWARF piece for it.
284 if (Reg >= 0 && Intersection.any()) {
285 AP.OutStreamer.AddComment("sub-register");
Eric Christopher29e874d2014-03-07 22:40:37 +0000286 emitDwarfRegOp(Streamer, Reg);
287 emitDwarfOpPiece(Streamer, Size, Offset == CurPos ? 0 : Offset);
Eric Christopher5c303202014-03-07 21:27:42 +0000288 CurPos = Offset + Size;
Eric Christopher698a8ab2014-03-07 01:44:14 +0000289
290 // Mark it as emitted.
Eric Christopher5c303202014-03-07 21:27:42 +0000291 Coverage.set(Offset, Offset + Size);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000292 }
293 }
294
295 if (CurPos == 0) {
296 // FIXME: We have no reasonable way of handling errors in here.
Eric Christopher29e874d2014-03-07 22:40:37 +0000297 Streamer.EmitInt8(dwarf::DW_OP_nop,
298 "nop (could not find a dwarf register number)");
Eric Christopher698a8ab2014-03-07 01:44:14 +0000299 }
300}
301
302/// EmitDwarfRegOp - Emit dwarf register operation.
Eric Christopher29e874d2014-03-07 22:40:37 +0000303void AsmPrinter::EmitDwarfRegOp(ByteStreamer &Streamer,
304 const MachineLocation &MLoc,
Eric Christopher698a8ab2014-03-07 01:44:14 +0000305 bool Indirect) const {
306 const TargetRegisterInfo *TRI = TM.getRegisterInfo();
307 int Reg = TRI->getDwarfRegNum(MLoc.getReg(), false);
308 if (Reg < 0) {
309 // We assume that pointers are always in an addressable register.
310 if (Indirect || MLoc.isIndirect()) {
311 // FIXME: We have no reasonable way of handling errors in here. The
312 // caller might be in the middle of a dwarf expression. We should
313 // probably assert that Reg >= 0 once debug info generation is more
314 // mature.
Eric Christopher29e874d2014-03-07 22:40:37 +0000315 Streamer.EmitInt8(dwarf::DW_OP_nop,
316 "nop (invalid dwarf register number for indirect loc)");
Eric Christopher698a8ab2014-03-07 01:44:14 +0000317 return;
318 }
319
320 // Attempt to find a valid super- or sub-register.
321 if (!Indirect && !MLoc.isIndirect())
Eric Christopher29e874d2014-03-07 22:40:37 +0000322 return EmitDwarfRegOpPiece(Streamer, *this, MLoc);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000323 }
324
325 if (MLoc.isIndirect())
Eric Christopher29e874d2014-03-07 22:40:37 +0000326 emitDwarfRegOpIndirect(Streamer, Reg, MLoc.getOffset(), Indirect);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000327 else if (Indirect)
Eric Christopher29e874d2014-03-07 22:40:37 +0000328 emitDwarfRegOpIndirect(Streamer, Reg, 0, false);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000329 else
Eric Christopher29e874d2014-03-07 22:40:37 +0000330 emitDwarfRegOp(Streamer, Reg);
Eric Christopher698a8ab2014-03-07 01:44:14 +0000331}
332
Chris Lattneraabc6042010-04-04 23:41:46 +0000333//===----------------------------------------------------------------------===//
334// Dwarf Lowering Routines
335//===----------------------------------------------------------------------===//
Chris Lattner70a4fce2010-04-04 23:25:33 +0000336
Rafael Espindola227144c2013-05-13 01:16:13 +0000337void AsmPrinter::emitCFIInstruction(const MCCFIInstruction &Inst) const {
338 switch (Inst.getOperation()) {
339 default:
340 llvm_unreachable("Unexpected instruction");
341 case MCCFIInstruction::OpDefCfaOffset:
342 OutStreamer.EmitCFIDefCfaOffset(Inst.getOffset());
343 break;
344 case MCCFIInstruction::OpDefCfa:
345 OutStreamer.EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset());
346 break;
347 case MCCFIInstruction::OpDefCfaRegister:
348 OutStreamer.EmitCFIDefCfaRegister(Inst.getRegister());
349 break;
350 case MCCFIInstruction::OpOffset:
351 OutStreamer.EmitCFIOffset(Inst.getRegister(), Inst.getOffset());
352 break;
Venkatraman Govindaraju4c0cdd72013-09-26 15:11:00 +0000353 case MCCFIInstruction::OpRegister:
354 OutStreamer.EmitCFIRegister(Inst.getRegister(), Inst.getRegister2());
355 break;
Venkatraman Govindaraju3816d432013-09-26 14:49:40 +0000356 case MCCFIInstruction::OpWindowSave:
357 OutStreamer.EmitCFIWindowSave();
358 break;
Oliver Stannardb14c6252014-04-02 16:10:33 +0000359 case MCCFIInstruction::OpSameValue:
360 OutStreamer.EmitCFISameValue(Inst.getRegister());
361 break;
Rafael Espindolabeb74c32011-04-15 20:32:03 +0000362 }
363}