LLVM API Documentation

X86WinCOFFStreamer.cpp
Go to the documentation of this file.
00001 //===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "X86MCTargetDesc.h"
00011 #include "llvm/MC/MCWin64EH.h"
00012 #include "llvm/MC/MCWinCOFFStreamer.h"
00013 
00014 using namespace llvm;
00015 
00016 namespace {
00017 class X86WinCOFFStreamer : public MCWinCOFFStreamer {
00018   Win64EH::UnwindEmitter EHStreamer;
00019 public:
00020   X86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB, MCCodeEmitter *CE,
00021                      raw_ostream &OS)
00022     : MCWinCOFFStreamer(C, AB, *CE, OS) { }
00023 
00024   void EmitWinEHHandlerData() override;
00025   void EmitWindowsUnwindTables() override;
00026   void FinishImpl() override;
00027 };
00028 
00029 void X86WinCOFFStreamer::EmitWinEHHandlerData() {
00030   MCStreamer::EmitWinEHHandlerData();
00031 
00032   // We have to emit the unwind info now, because this directive
00033   // actually switches to the .xdata section!
00034   EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
00035 }
00036 
00037 void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
00038   if (!getNumWinFrameInfos())
00039     return;
00040   EHStreamer.Emit(*this);
00041 }
00042 
00043 void X86WinCOFFStreamer::FinishImpl() {
00044   EmitFrames(nullptr);
00045   EmitWindowsUnwindTables();
00046 
00047   MCWinCOFFStreamer::FinishImpl();
00048 }
00049 }
00050 
00051 namespace llvm {
00052 MCStreamer *createX86WinCOFFStreamer(MCContext &C, MCAsmBackend &AB,
00053                                      MCCodeEmitter *CE, raw_ostream &OS,
00054                                      bool RelaxAll) {
00055   X86WinCOFFStreamer *S = new X86WinCOFFStreamer(C, AB, CE, OS);
00056   S->getAssembler().setRelaxAll(RelaxAll);
00057   return S;
00058 }
00059 }
00060