1 //===- lib/MC/MCXCOFFStreamer.cpp - XCOFF Object Output -------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file assembles .s files and emits XCOFF .o object files.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/MC/MCXCOFFStreamer.h"
14 #include "llvm/MC/MCAsmBackend.h"
15 #include "llvm/MC/MCCodeEmitter.h"
16 #include "llvm/MC/MCObjectWriter.h"
17 #include "llvm/MC/MCSymbolXCOFF.h"
18 #include "llvm/Support/TargetRegistry.h"
22 MCXCOFFStreamer::MCXCOFFStreamer(MCContext
&Context
,
23 std::unique_ptr
<MCAsmBackend
> MAB
,
24 std::unique_ptr
<MCObjectWriter
> OW
,
25 std::unique_ptr
<MCCodeEmitter
> Emitter
)
26 : MCObjectStreamer(Context
, std::move(MAB
), std::move(OW
),
27 std::move(Emitter
)) {}
29 bool MCXCOFFStreamer::EmitSymbolAttribute(MCSymbol
*Symbol
,
30 MCSymbolAttr Attribute
) {
31 report_fatal_error("Symbol attributes not implemented for XCOFF.");
34 void MCXCOFFStreamer::EmitCommonSymbol(MCSymbol
*Symbol
, uint64_t Size
,
35 unsigned ByteAlignment
) {
36 getAssembler().registerSymbol(*Symbol
);
37 Symbol
->setExternal(cast
<MCSymbolXCOFF
>(Symbol
)->getStorageClass() !=
39 Symbol
->setCommon(Size
, ByteAlignment
);
41 // Need to add this symbol to the current Fragment which will belong to the
43 auto *F
= dyn_cast_or_null
<MCDataFragment
>(getCurrentFragment());
44 assert(F
&& "Expected a valid section with a fragment set.");
45 Symbol
->setFragment(F
);
47 // Emit the alignment and storage for the variable to the section.
48 EmitValueToAlignment(ByteAlignment
);
52 void MCXCOFFStreamer::EmitZerofill(MCSection
*Section
, MCSymbol
*Symbol
,
53 uint64_t Size
, unsigned ByteAlignment
,
55 report_fatal_error("Zero fill not implemented for XCOFF.");
58 void MCXCOFFStreamer::EmitInstToData(const MCInst
&Inst
,
59 const MCSubtargetInfo
&) {
60 report_fatal_error("Instruction emission not implemented for XCOFF.");
63 MCStreamer
*llvm::createXCOFFStreamer(MCContext
&Context
,
64 std::unique_ptr
<MCAsmBackend
> &&MAB
,
65 std::unique_ptr
<MCObjectWriter
> &&OW
,
66 std::unique_ptr
<MCCodeEmitter
> &&CE
,
68 MCXCOFFStreamer
*S
= new MCXCOFFStreamer(Context
, std::move(MAB
),
69 std::move(OW
), std::move(CE
));
71 S
->getAssembler().setRelaxAll(true);
75 void MCXCOFFStreamer::EmitXCOFFLocalCommonSymbol(MCSymbol
*Symbol
, uint64_t Size
,
77 report_fatal_error("Emission of local commons not implemented yet.");