1 //===- AArch64TargetStreamer.cpp - AArch64TargetStreamer class ------------===//
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 implements the AArch64TargetStreamer class.
11 //===----------------------------------------------------------------------===//
13 #include "AArch64TargetStreamer.h"
14 #include "llvm/MC/ConstantPools.h"
15 #include "llvm/MC/MCSection.h"
16 #include "llvm/MC/MCSubtargetInfo.h"
21 // AArch64TargetStreamer Implemenation
23 AArch64TargetStreamer::AArch64TargetStreamer(MCStreamer
&S
)
24 : MCTargetStreamer(S
), ConstantPools(new AssemblerConstantPools()) {}
26 AArch64TargetStreamer::~AArch64TargetStreamer() = default;
28 // The constant pool handling is shared by all AArch64TargetStreamer
30 const MCExpr
*AArch64TargetStreamer::addConstantPoolEntry(const MCExpr
*Expr
,
33 return ConstantPools
->addEntry(Streamer
, Expr
, Size
, Loc
);
36 void AArch64TargetStreamer::emitCurrentConstantPool() {
37 ConstantPools
->emitForCurrentSection(Streamer
);
40 // finish() - write out any non-empty assembler constant pools.
41 void AArch64TargetStreamer::finish() { ConstantPools
->emitAll(Streamer
); }
43 void AArch64TargetStreamer::emitInst(uint32_t Inst
) {
46 // We can't just use EmitIntValue here, as that will swap the
47 // endianness on big-endian systems (instructions are always
49 for (unsigned I
= 0; I
< 4; ++I
) {
50 Buffer
[I
] = uint8_t(Inst
);
54 getStreamer().EmitBytes(StringRef(Buffer
, 4));
60 createAArch64ObjectTargetStreamer(MCStreamer
&S
, const MCSubtargetInfo
&STI
) {
61 const Triple
&TT
= STI
.getTargetTriple();
62 if (TT
.isOSBinFormatELF())
63 return new AArch64TargetELFStreamer(S
);
64 if (TT
.isOSBinFormatCOFF())
65 return new AArch64TargetWinCOFFStreamer(S
);
69 } // end namespace llvm