1 | //===- lib/MC/MCGOFFStreamer.cpp - GOFF Object Output ---------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file assembles .s files and emits GOFF .o object files. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "llvm/MC/MCGOFFStreamer.h" |
14 | #include "llvm/MC/MCAsmBackend.h" |
15 | #include "llvm/MC/MCAssembler.h" |
16 | #include "llvm/MC/MCCodeEmitter.h" |
17 | #include "llvm/MC/MCContext.h" |
18 | #include "llvm/MC/MCGOFFObjectWriter.h" |
19 | #include "llvm/MC/TargetRegistry.h" |
20 | |
21 | using namespace llvm; |
22 | |
23 | MCGOFFStreamer::~MCGOFFStreamer() {} |
24 | |
25 | GOFFObjectWriter &MCGOFFStreamer::getWriter() { |
26 | return static_cast<GOFFObjectWriter &>(getAssembler().getWriter()); |
27 | } |
28 | |
29 | // Make sure that all section are registered in the correct order. |
30 | static void registerSectionHierarchy(MCAssembler &Asm, MCSectionGOFF *Section) { |
31 | if (Section->isRegistered()) |
32 | return; |
33 | if (Section->getParent()) |
34 | registerSectionHierarchy(Asm, Section: Section->getParent()); |
35 | Asm.registerSection(Section&: *Section); |
36 | } |
37 | |
38 | void MCGOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) { |
39 | registerSectionHierarchy(Asm&: getAssembler(), |
40 | Section: static_cast<MCSectionGOFF *>(Section)); |
41 | MCObjectStreamer::changeSection(Section, Subsection); |
42 | } |
43 | |
44 | MCStreamer *llvm::createGOFFStreamer(MCContext &Context, |
45 | std::unique_ptr<MCAsmBackend> &&MAB, |
46 | std::unique_ptr<MCObjectWriter> &&OW, |
47 | std::unique_ptr<MCCodeEmitter> &&CE) { |
48 | MCGOFFStreamer *S = |
49 | new MCGOFFStreamer(Context, std::move(MAB), std::move(OW), std::move(CE)); |
50 | return S; |
51 | } |
52 | |