X86WinCOFFStreamer.cpp revision 353358
150476Speter//===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===// 226628Sache// 326628Sache// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 426628Sache// See https://llvm.org/LICENSE.txt for license information. 526628Sache// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 626628Sache// 726628Sache//===----------------------------------------------------------------------===// 826628Sache 926628Sache#include "X86MCTargetDesc.h" 1026628Sache#include "X86TargetStreamer.h" 1126628Sache#include "llvm/MC/MCAsmBackend.h" 1226628Sache#include "llvm/MC/MCCodeEmitter.h" 1326628Sache#include "llvm/MC/MCObjectWriter.h" 1426628Sache#include "llvm/MC/MCWin64EH.h" 1526628Sache#include "llvm/MC/MCWinCOFFStreamer.h" 1626628Sache 1726628Sacheusing namespace llvm; 1826628Sache 1926628Sachenamespace { 2026628Sacheclass X86WinCOFFStreamer : public MCWinCOFFStreamer { 2126628Sache Win64EH::UnwindEmitter EHStreamer; 2226628Sachepublic: 2326628Sache X86WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB, 2426628Sache std::unique_ptr<MCCodeEmitter> CE, 2526628Sache std::unique_ptr<MCObjectWriter> OW) 2626628Sache : MCWinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)) {} 2726628Sache 2826628Sache void EmitWinEHHandlerData(SMLoc Loc) override; 2926628Sache void EmitWindowsUnwindTables() override; 3026628Sache void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override; 3126628Sache void FinishImpl() override; 3226628Sache}; 3326628Sache 3426628Sachevoid X86WinCOFFStreamer::EmitWinEHHandlerData(SMLoc Loc) { 3526628Sache MCStreamer::EmitWinEHHandlerData(Loc); 3626628Sache 3726628Sache // We have to emit the unwind info now, because this directive 3826628Sache // actually switches to the .xdata section! 3926628Sache EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo()); 4026628Sache} 4126628Sache 4226628Sachevoid X86WinCOFFStreamer::EmitWindowsUnwindTables() { 4326628Sache if (!getNumWinFrameInfos()) 4426628Sache return; 4526628Sache EHStreamer.Emit(*this); 4626628Sache} 4726628Sache 4826628Sachevoid X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) { 4926628Sache X86TargetStreamer *XTS = 5026628Sache static_cast<X86TargetStreamer *>(getTargetStreamer()); 5126628Sache XTS->emitFPOData(ProcSym, Loc); 5226628Sache} 5326628Sache 5426628Sachevoid X86WinCOFFStreamer::FinishImpl() { 5526628Sache EmitFrames(nullptr); 5626628Sache EmitWindowsUnwindTables(); 5726628Sache 5826628Sache MCWinCOFFStreamer::FinishImpl(); 5926628Sache} 6026628Sache} 6126628Sache 6226628SacheMCStreamer *llvm::createX86WinCOFFStreamer(MCContext &C, 6326628Sache std::unique_ptr<MCAsmBackend> &&AB, 6426628Sache std::unique_ptr<MCObjectWriter> &&OW, 6526628Sache std::unique_ptr<MCCodeEmitter> &&CE, 6626628Sache bool RelaxAll, 6726628Sache bool IncrementalLinkerCompatible) { 6826628Sache X86WinCOFFStreamer *S = 6926628Sache new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)); 7026628Sache S->getAssembler().setRelaxAll(RelaxAll); 7126628Sache S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible); 7226628Sache return S; 7326628Sache} 7426628Sache 7526628Sache