[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / lib / Target / AArch64 / MCTargetDesc / AArch64TargetStreamer.cpp
blobf70752f5303f30b1b0379e6b2438880ee0b3a257
1 //===- AArch64TargetStreamer.cpp - AArch64TargetStreamer class ------------===//
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 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"
18 using namespace llvm;
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
29 // implementations.
30 const MCExpr *AArch64TargetStreamer::addConstantPoolEntry(const MCExpr *Expr,
31 unsigned Size,
32 SMLoc Loc) {
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) {
44 char Buffer[4];
46 // We can't just use EmitIntValue here, as that will swap the
47 // endianness on big-endian systems (instructions are always
48 // little-endian).
49 for (unsigned I = 0; I < 4; ++I) {
50 Buffer[I] = uint8_t(Inst);
51 Inst >>= 8;
54 getStreamer().EmitBytes(StringRef(Buffer, 4));
57 namespace llvm {
59 MCTargetStreamer *
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);
66 return nullptr;
69 } // end namespace llvm